Posted in Selenium

Impacts of Selenium 4.0 Version ?

In addition to these new capabilities, arriving of Selenium 4 may require few changes in your existing selenium 2.X/3.X tests, Let’s look at those areas of your tests that require to be updated with Selenium 4.

  • The getPosition & getSize methods were replaced by getRect method and the setPosition & setSize methods were replaced by setRect method.
  • Now you can configure the location of your Safari driver using the “webdriver.safari.driver” system property.
  • Element screenshotting is possible in Selenium 4.
  • Fullscreen and minimize methods have been added, so that the driver window can now be full screen or minimized and all window manipulation commands are now supported.
  • Added driver.switchTo().parentFrame() – We can use it to go from the child frame to the parent frame directly.
  • Changes added to Chrome driver –
    • sendDevToolsCommand() – The sendDevToolsCommand() method sends an arbitrary dev tools command to the browser and returns a promise that will be resolved when the command has finished.
    • setDownloadPath() – The setDownloadPath() method sends a DevTools command to change Chrome’s download directory and returns a promise that will be resolved when the command has finished.
  • Changes to Firefox driver – Added installAddon(path) method to install a new addon within the current session. This function will return an “id” that can be used to uninstall the addon using uninstallAddon() method.
  • Options class now extends Capabilities class for Chrome, Firefox, IE & Safari.
  • Changes wrt to Errors such as Added ElementClickInterceptedError, InsecureCertificateError & Removed ElementNotVisibleError.
  • Removed the firefox.profile class. All its functionality is now provided directly by firefox.options.
Posted in Selenium

Features of Selenium 4.0?

1. WebDriver became W3C (World Wide Web Consortium) standardization –
The change with Selenium 4 is the standardizing the WebDriver as per the W3C standards. W3C standards encourage compatibility across different software implementations of the WebDriver API and make the Framework much more stable & reduce compatibility issues across different Web Browsers.
A test in Selenium 3 communicates with the browser at the end node through the JSON wire protocol. Testing tools such as Appium and iOS Driver which are related to mobile testing heavily rely on JSON wire protocol. With Selenium 4 adapting W3C Protocol for communication between the driver and browser, Tests will now be able to directly communicate the browser without using API encoding/decoding. Which would help in mobile testing users

2.  Improved Selenium Grid – The Selenium Grid code has been modified with many changes and needed improvements; the console of the selenium grid has been restructured. It allows you to execute test cases in parallel on multiple browsers and systems as well as operating systems.

The UI for Selenium Grid is now with a more user-friendly UI that would have all the relevant information about the sessions running, capacity, etc.
And also, Basic support for utilizing Docker Containers with new Grid Server is been added.

3.   Support for browsers – Native support for Opera and PhantomJS going forward will be removed. Whereas users who want to test Opera can opt Chrome since Opera is based on Chromium and for PhantomJS users can use Chrome or Firefox in headless mode. And Selenium Server now no longer includes HtmlUnit by default.

4.   New Selenium 4 IDE (Chrome & Firefox) – Selenium IDE is a record and playback tool is now available with more advanced capabilities and features.

New plug-in: The new version plugin will allow you to run Selenium on any browser vendor and can declare our own locator strategy.
New CLI runner: The new CLI runner is completely based on node.js instead of old HTML-based runner and will have capabilities like WebDriver Playback and Parallel Execution to support for parallel execution and provide reports like passed and failed tests. The new Selenium IDE runner is completely based on WebDriver.

5.   Detailed Documentation – Selenium users face difficulties as there is no proper updated documentation of SelniumNow, SeleniumHQ promises to deliver us update documentation along with the 4.0 version.

6.   Better Analysis – Logging and debugging details will be improved to accelerate the resolution of script issues for testers.

Posted in Selenium

How To Resize Browser Window Using Selenium WebDriver?

To resize the browser window to particular dimensions, we use ‘Dimension’ class to resize the browser window.

//Create object of Dimensions class

        Dimension d = new Dimension(480,620);

        //Resize the current window to the given dimension