Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am using robot framework. How can I test if a checkbox is selected? I want to run a keyword if a checkbox is selected like:

 ${checked} =   Checkbox Should Not Be Selected  xpath=.//*[@id='0,1,1,6']/td[11]/input
    Run Keyword if  '${checked}'  Click Element  xpath=.//*[@id='0,1,1,6']/td[11]/input  and wait

i.e. to click there if is not already clicked.

(The code of above is wrong, I know)

share|improve this question
add comment

2 Answers

From: http://rtomac.github.com/robotframework-selenium2library/doc/Selenium2Library.html

Keyword: Checkbox Should Be Selected

Arguments: locator

Documentation: Verifies checkbox identified by locator is selected/checked. Key attributes for checkboxes are id and name. See introduction for details about locating elements.

share|improve this answer
    
Thanks for answering. As you can see I am using "Checkbox should be selected" in my code (in fact I am using the negation). This command works like an assertion and not a question. When the assertion fails the test stops. I want to ask if the checkbox is checked and not to assert that the checkbox should be checked. –  Luixv Feb 24 '13 at 7:24
add comment

Use Run Keyword And Return Status

It runs the given keyword with given arguments and returns the status as a Boolean value. This keyword returns True if the keyword that is executed succeeds and False if it fails. This is useful, for example, in combination with Run Keyword If. If you are interested in the error message or return value, use Run Keyword And Ignore Error instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.