Reputation: 1875
*** Variables ***
${URL} http://myurl
*** Test Cases *** username password
#Here I'm getting problem How should i write test cases for radio button
*** Keywords ***
Go To First Chapter
Go To ${URL}
Find Radio Buttons
Select Radio Button ID True
I dont know correct keyword or way to do this (as i'm beginner for this robotframework)
Upvotes: 0
Views: 4073
Reputation: 2732
*** Test Cases ***
Answer False To All Questions On First Chapter
[Setup] Go To First Chapter
Select Radio Button SProgIntro_QSProgIntro_1 False
Select Radio Button SProgIntro_QSProgIntro_1 False
Select Radio Button SProgIntro_QSProgIntro_1 False
Element Should Be Visible SProgIntro_QSProgIntro_1_expl
Element Should Be Visible SProgIntro_QSProgIntro_2_expl
Element Should Be Visible SProgIntro_QSProgIntro_3_expl
Will select false on all three questions and check that the element which indicates wrong answer is visible. Almost always your tests should have structure like
http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html has documentation about the different keywords of Selenium2Library and https://code.google.com/p/robotframework/wiki/HowToWriteGoodTestCases will teach you something about how to write good test cases in RF.
Upvotes: 1
Reputation: 648
I'm not sure I understand your question right. How exactly do you want to test the radio buttons? Do you want to just assert they do exists and click on them?
Maybe you could consider using Helium - Python Selenium WebDriver wrapper which makes things easier:
from helium.api import *
start_chrome("http://pythoneval.zyante.com/ch01-introduction")
# scroll down to view the radio buttons
scroll_down(10)
# assert radio button True exists for question "1"
assert RadioButton("True", to_right_of=Text("1")).exists()
# assert radio button False exists for question "1"
assert RadioButton("False", to_right_of=Text("1")).exists()
# select the "True" answer for question number "1"
click(RadioButton("True", to_right_of=Text("1")))
# this displays the alert sometimes, if alert exists dismiss it by pressing ENTER
if Alert().exists():
press(ENTER)
Similarly you can refer to radio buttons for other questions - there is no need to use the IDs such as SProgIntro_QSProgIntro_1. You can also use Python's unittest library to write complete test cases classes and make more sophisticated assertions.
More info at heliumhq.com
Disclosure: I'm one of the Helium developers.
Upvotes: 0