33. Using click( ) predefined method to select a check box


click( ) is a predefined method of Selenium Class which can also be used to select a check box.

Lets Implement This:

Pre-requisites:

1. Create a new Project say 'RC-Project5' 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_five' under the newly created project.
6. Create a Java Class file say 'Class5' 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:



2. The above code will starts the Selenium RC Driver, opens the http://book.theautomatedtester.co.uk/chapter1 in the Test Browser window and finally it maximizes the Test Browser window as shown below:



3. Now lets write the Selenium RC Automation code using any Selenium Command that selects the check box  in the above screen. 

4. Using FireBug options, Inspect the check box 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 check box button using NAME locator i.e. using name=selected(1234)  in this case.
6. Also we've to use the above NAME locator in the Selenium RC Command which is used to select the specified check  box. object1.click("Locator") is the syntax we've to use for selecting the specified locator.
7. So after understanding the things in step5 and step6, its very clear that we've to write object1.click("name=selected(1234)"); to select the check box option as shown below:




8. Start the Selenium Standalone Server
9. Save and Run the 'Class5.java' file by selecting the 'JUnit Test' option and ensure that the check box 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.

Using select( ) method for selecting a list item from the drop down list will be explained in the next post.




No comments:

Post a Comment

Followers

Labels