I am trying to determine the state of checkboxes on page load, and if they are not checked, to check them. My goal is to establish a known state before proceeding to test the page.
I am using a run keyword unless keyword with a variable:
***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]
The tests are currently erring out with a message of:
Evaluating expression 'checkbox should be selected xpath=(//input[@name='allowfields'])[2]' failed: SyntaxError: invalid syntax (, line 1)
Can anyone point me in the correct direction?
Edit Below... Thanks to @Mohanapriya I was able to parse through the code and came up with a partial solution. The automation runs and returns PASS, but does not change the state of the checkbox from unchecked to checked.
Here is what I have partially working:
*** 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
At the point of failure, ride log shows: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'.
Any feedback on how to correct this?