select( ) method is a predefined method of Selenium Class which is used to select any list item from the drop down list.
Lets Implement This:
Pre-requisites:
1. Create a new Project say 'RC-Project6' 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_six' under the newly created project.
6. Create a Java Class file say 'Class6' 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 list item 'Selenium RC' from the drop down field shown in the above screen.
4. Using FireBug options, Inspect the drop down field 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 drop down field using ID locator i.e. using id=selecttype 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 list item in the identified drop down list. object1.select("Locator", "label=List Item Label") is the syntax we've to use for selecting the list item from the specified locator.
7. So after understanding the things in step6 and step7, its very clear that we've to write object1.select("id=selecttype", "label=Selenium RC"); to select the list item under the Drop down field as shown below:
8. Start the Selenium Standalone Server
9. Save and Run the 'Class6.java' file by selecting the 'JUnit Test' option and ensure that 'Selenium RC' list item is selected from the Drop down field 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 open( ) method to navigate to the Home page of the Provided Base URL will be explained in the next post.
No comments:
Post a Comment