【发布时间】:2017-01-20 04:15:30
【问题描述】:
我正在尝试确定页面加载时复选框的状态,如果未选中,请检查它们。我的目标是在继续测试页面之前建立一个已知状态。
我正在使用带有变量的run keyword unless 关键字:
***Variable***
${checked1} checkbox should be selected xpath=(//input[@name='allowfields'])[2]
${checked2} checkbox should be selected xpath=(//input[@name='allowsharing'])[2]
***Test Cases***
Validate checkbox initial state
Run Keyword unless ${checked1} Click Element xpath=(//input[@name='allowfields'])[2]
Run Keyword unless ${checked2} Click Element xpath=(//input[@name='allowsharing'])[2]
测试目前正在出错,并显示以下消息:
评估表达式'checkbox should be selected xpath=(//input[@name='allowfields'])[2]' failed: SyntaxError: invalid syntax (, line 1)
谁能指出我正确的方向?
在下面编辑... 感谢@Mohanapriya,我能够解析代码并提出部分解决方案。自动化运行并返回 PASS,但不会将复选框的状态从未选中更改为选中。
这是我的部分工作:
*** Keyword ***
Configure Checkbox
[Arguments] ${Status_Locator} ${Checkbox_Locator} ${Excel_Value}
${Is_Checkbox_Selected} Run Keyword And Return Status Checkbox Should Be Selected ${Status_Locator} ${Actual_Chkbx_Value} Run Keyword If '${Is_Checkbox_Selected}'== 'True' Set Variable Yes else if '${Is_Checkbox_Selected}'== 'False' Set Variable No Log ${Actual_Chkbx_Value} Run Keyword If '${Excel_Value}'!='${Actual_Chkbx_Value}' Click Element ${Checkbox_Locator}
Click Button css=button.primary.success
在故障点,骑行日志显示:Starting test: Tests.Validate checkbox state
20170117 12:29:16.968 : FAIL : Variable '${Is_Checkbox_Selected}' not found.
20170117 12:29:16.969 : INFO : ${Is_Checkbox_Selected} = False
20170117 12:29:16.971 : INFO : Clicking button 'css=button.primary.success'.
关于如何纠正此问题的任何反馈?
【问题讨论】:
标签: selenium checkbox robotframework