Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 使用Robot框架验证复选框的状态_Selenium_Checkbox_Robotframework - Fatal编程技术网

Selenium 使用Robot框架验证复选框的状态

Selenium 使用Robot框架验证复选框的状态,selenium,checkbox,robotframework,Selenium,Checkbox,Robotframework,我试图确定页面加载上复选框的状态,如果未选中,则选中它们。我的目标是在继续测试页面之前建立一个已知状态 我使用的是run关键字,除非带有变量的关键字: ***Variable*** ${checked1} checkbox should be selected xpath=(//input[@name='allowfields'])[2] ${checked2} checkbox should be selected xpath=(//input[@name='allowsharin

我试图确定页面加载上复选框的状态,如果未选中,则选中它们。我的目标是在继续测试页面之前建立一个已知状态

我使用的是
run关键字,除非带有变量的
关键字:

***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]  
测试当前出错,并显示一条消息:
计算表达式“应选中复选框xpath=(//输入[@name='allowfields'])[2]”失败:语法错误:语法无效(,第1行)

有人能给我指出正确的方向吗

编辑下面。。。 多亏了@Mohanapriya,我才能够解析代码,并找到了部分解决方案。自动化运行并返回PASS,但不会将复选框的状态从unchecked更改为checked

以下是我部分工作的内容:

*** 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
在故障点,行驶日志显示:
开始测试:测试。验证复选框状态
20170117 12:29:16.968:失败:未找到变量“${Is\u Checkbox\u Selected}”。
20170117 12:29:16.969:信息:${Is_Checkbox_Selected}=False
20170117 12:29:16.971:信息:单击按钮“css=button.primary.success”。

有没有关于如何纠正这一点的反馈

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}
在这段代码中,我传递了三个参数


在这段代码中,我传递了三个参数。

您好,Mohanapriya,“配置”复选框是本地库还是其他机器人库的一部分?您的代码格式很难确定。@CharlesRamsell,“配置”复选框是用户定义的关键字(本地库)您好,Mohanapriya,“配置”复选框是本地库还是其他robot库的一部分?您的代码格式很难确定。@CharlesRamsell,“配置”复选框是用户定义的关键字(本地库)