Saturday, 5 June 2021

Important New Features in Selenium 4?

 


Check Selenium Interviewquestions from 1 to 10 below:


Check Selenium-SDET-UIAutomation Questions set 11 to 20:
Qus Set - 11 to 20

Check Selenium-SDET-UIAutomation Questions set 21 to 30:
 
Check Selenium-SDET-UIAutomation Questions set 31 to 40:

 Question Set 31-40  

Check Selenium-SDET-UIAutomation Questions set 41-50:

Q&A Set 41-50

Better Window/Tab Management in Selenium 4

There are several instances in test automation wherein one might need to open a particular link in a new tab or window to perform certain actions. To achieve this in Selenium 3, QAs had to create a new driver object and then perform the switch operation using the WindowHandle method to perform subsequent steps.

This is set to change in Selenium 4 as it comes with a new API – newWindow that allows users to create and switch to a new window/tab without creating a new WebDriver object.

Sample code snippet to open a new window

driver.get("https://www.google.com/");
// Opens a new window and switches to new window
driver.switchTo().newWindow(WindowType.WINDOW);

// Opens BrowserStack homepage in the newly opened window
driver.navigate().to("https://www.browserstack.com/");

Sample code snippet to open a new tab within the same window

driver.get("https://www.google.com/");

// Opens a new tab in existing window
driver.switchTo().newWindow(WindowType.TAB);

// Opens Browserstack homepage in the newly opened tab
driver.navigate().to("https://www.browserstack.com/");

Deprecation of Desired Capabilities

Desired Capabilities were primarily used in the test scripts to define the 

test environment (browser name, version, operating system) for execution on the Selenium Grid.

In Selenium 4, capabilities objects are replaced with Options. 

This means testers now need to create an Options object, set test requirements, 

and pass the object to the Driver constructor.

Listed below are the Options objects to be used going forward for defining browser-specific capabilities:

  1. Firefox – FirefoxOptions
  2. Chrome – ChromeOptions
  3. Internet Explorer (IE) – InternetExplorerOptions
  4. Microsoft Edge – EdgeOptions
  5. Safari – SafariOptions

Modifications in the Actions Class

Actions class in Selenium is primarily used to simulate input actions from mouse 

and keyboard on specific web elements (For eg: Left click, Right click, Double click, etc)

In Selenium 4, several new methods have been added to the Actions class:

  • click(WebElement)

This method is added to Actions class to replace the moveToElement(onElement).click()

It is used to click on a certain web element.

  • clickAndHold(WebElement)

This method will replace the moveToElement(onElement).clickAndHold()

It is used to click on an element without releasing the click.

  • contextClick(WebElement)

This method will replace moveToElement(onElement).contextClick(). 

It will perform the right click operation.

  • doubleClick(WebElement)

This method is added to replace moveToElement(element).doubleClick()

It will perform a double click on an element.

  • release()

This method (user for releasing the pressed mouse button) was initially a part of org.openqa.selenium.interactions.ButtonReleaseAction class. 

Now with the updated version of Selenium, it has been moved to Actions class.

 Selenium 3 vs Selenium 4

Selenium 3Selenium 4
The Browser interaction is based on
JSON wire protocol due to which it
 needs encoding and decoding of the
API, and JWP connects with browser drivers
It follows the W3C standard
Protocol due to which driver and the
browser communication follows the standard
procedure, does not require encoding and decoding
of the API, so communication happens directly.
Suggested Post:

ALL ABOUT AUTOMATION FRAMEWORK DESIGN

Java Interview question Set-1:

SET-01 1-10

Java Interview question Set-2:

SET-02 10-20

Java Interview question Set-3:

SET-03 21-30

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions


No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...