【问题标题】:How do i get text from a element when the argument is passed传递参数时如何从元素中获取文本
【发布时间】:2019-08-26 02:48:18
【问题描述】:

我正在编写一个关键字,它将从警报框中返回两种可用的时间格式(时间 1 和时间 2)。现在,当我在测试用例中调用关键字时,我将只传递一个参数,即时间 1,它应该只返回文本时间1

[Arguments]  ${filename} ${uploadtime}=SKIP  ${updatetime}=SKIP

Selenium2Library.Wait Until Element is Visible       xpath=.//*[contains(text(),'${filename}')]
Selenium2Library.Wait Until Element is Visible       ${opt}
Selenium2Library.wait until element is visible       ${opt1}
Selenium2Library.Click Element                       ${opt1}
${uploadt}=  Get Text                                ${upload_time}
Run Keyword If    '${uploadtime}' != 'SKIP'      [Return]      ${uploadt}
${updatet}=  Get Text                                ${upload_time}
Run Keyword If    '${updatetime}' != 'SKIP'     [Return]      ${updatet}

参数说明无效:参数语法“${filename} ${uploadtime}”无效。

【问题讨论】:

  • 检查${filename} ${uploadtime}之间的空格应该是2或4个空格

标签: robotframework


【解决方案1】:

参数声明中存在语法错误 - ${filename}${uploadtime} 之间只有一个空格,这就是错误消息的内容。

至少放置 2 个(越多 - 可读性越好)来表示这些是 2 个单独的参数。

【讨论】:

    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 2021-05-25
    • 2021-05-28
    • 2021-04-11
    • 2023-01-26
    • 2021-03-25
    • 2021-09-04
    • 1970-01-01
    相关资源
    最近更新 更多