Activity: Resizing and Moving Windows with a Selenium Automation Script

Before You Begin

  • Make sure that you have followed the steps in the previous activity of this chapter.
  • Continue to work on the same file from the previous activity of this chapter.

Scenario

In An Overview of Frequently Used Methods, we used some of the WebDriver methods to start and finalize the script. In this activity, we will work on resizing and moving windows as a part of the test code.

Aim

To work on resizing and moving windows using a Selenium automation script.

Steps for Completion

  1. Using the driver.get() method in the ActivityLesson02 constructor, load https://www.packtpub.com/.
  2. Using the manage().window().setSize(Dimension) method, resize the current window.
  3. Using the manage().window().getSize() method, verify that the size of the window is equal to the size of the one that you set in step 2.
  4. Using the System.out.println method, display messages that indicate whether the verification was successful.
  5. Using the manage().window().maximize() method, maximize the current window.
  6. Using the manage().window().getSize() method, verify that the size of the window is different from the one that you set in step 2.
  7. Using the System.out.println method, display messages that indicate whether the verification was successful.
  8. Using the driver.switchTo().window(""); method, switch the focus to another window.
  9. Using the System.out.println method, display a message that indicates whether the focus is on the new window.
  10. Using the driver.close() method, close the new window.
  11. Compile and run the script.

To refer to the detailed steps, go to the Solutions section at the end of 
this book on Page no. 163.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.118.99