In order to implement close( ) and quit( ) WebDriver Commands and find out the different between these two commands, we have to launch more than one browser window using our Automation code.
Test Description:
Follow the below steps to understand the test description:
1. Open http://www.omayo.blogspot.com in a Browser as shown below:
2. Click on the 'Selenium-Tutorial' link as shown below:
3. Ensure that 'Selenium-Tutorial' link has opened http://www.Selenium143.blogspot.com in a new Window as shown below:
4. Now observe that we've two browser window opened i.e. One Browser window containing 'http://www.omayo.blogspot.com' URL page and other Browser window containing 'http://www.Selenium143.blogspot.com' URL Page.
Till now we have launched more than one Browser Windows manually. Lets implement this in Selenium Automation.
Lets Implement the Test on Eclipse IDE:
Pre-requisites:
1. Create a new Project say 'WebDriver-Project33' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package33' under the newly created project.
4. Create a Java Class file say 'Class33' 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. Write the test method 'clickSeleniumTutorialLink()' which uses CSS Path Statement for locating the link as shown below:
3. Ensure that you have not written @AfterClass specified method as shown below:
4. Save and Run the 'Class33.java' file by selecting the 'JUnit Test' option and ensure that our Automation Test has opened two Browser windows (i.e. One browser window holding Omayo Website and other Browser window holding Selenium143 website as shown in the below video:
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.
Click here to watch the video.
Download this Project:
Please comment below to feedback or ask questions.
Understanding how close( ) and quit( ) commands work when more than one window is opened will be explained in the next post.