click( ) is a predefined method of Selenium Class which can also be used to select Radio buttons.
Lets Implement This:
Pre-requisites:
1. Create a new Project say 'RC-Project4' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Start the Selenium Standalone Server
5. Create a package say 'package_four' under the newly created project.
6. Create a Java Class file say 'Class4' under the newly created package as shown below:
Actual Steps:
1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:
3. Now lets write the Selenium RC Automation code using any Selenium Command that selects the radio button in the above screen.
4. Using FireBug options, Inspect the radio button and identify the locator after observing the below code in the below screenshot:
5. After seeing the above html code in the screenshot, its very clear that we've to identify the radio button using ID locator i.e. using id=radiobutton in this case.
6. Also we've to use the above ID locator in the Selenium RC Command which is used to select the specified radio button. object1.click("Locator") is the syntax we've to use for selecting the specified locator.
7. So after understanding the things in step6 and step7, its very clear that we've to write object1.click("id=radiobutton"); to select the radio button as shown below:
8. Start the Selenium Standalone Server
9. Save and Run the 'Class4.java' file by selecting the 'JUnit Test' option and ensure that the radio button is selected in the 'chapter1' page as shown below:
Watch the below video:
Click here to watch the video.
Download this Project:
Click here to download this project and import into Eclipse IDE on your machine.
Please comment below to feedback or ask questions.
No comments:
Post a Comment