Thursday, March 10, 2022

Selenium 4


 New Features and Updation in Selenium 4:

1. Selenium is now W3C compliant:

  • JSON wire protocol was used to communicate between the SE Webdriver API's and the browser native APIs
  • With W3C compliance. the communication happens directly without any encoding and decoding required
  • Any software following W3C standard protocol can be integrated with Selenium with no compatibility issues

2. Relative Locators:

  • Function to locate nearby elements by specifying directions
  • Existing locator strategy        

3. Better Window and Tab Management:

  • Work with multiple windows or tabs in the same session
  • Can now open multiple windows and tabs without creating a new driver object

4. Improved Selenium Grid:

    Selenium Grid helps in Distributed Test Execution
  • Enables test execution on different combinations of browsers, OS, and Machines
  • Enables parallel execution
    Selenium Grid is now redesigned

    Docker support
    Enables to spin up the containers. (No need to set up VMs)
    Enables to deploy the grid on Kubernetes for better scaling

    Easier Management - No need to set up and start hubs and nodes separately

    3 ways to run Se Grid

    Standalone Mode
    Hub and Node
    Distributed

    a. Standalone Mode:

    The new Selenium Server Jar contains all the functionalities needed to run a grid
                       java -jar selenium-server-4.0.0.jar standalone
   The Grid automatically identifies that the WebDriver for Chrome and Firefox are present on the system

    b. Hub and Node:

    The classical way of using the Grid for selenium test Automation consists of two major components i.e. Hub and Node
        start hub:             java -jar selenium-server-4.0.0.jar hub
        register node:      java -jar selenium-server-4.0.0.jar node --detect-drivers

    c. Distributed:

        Grid 4 can be started in a fully distributed manner, with each piece running in its own process
        Selenium Grid 4 consists of four processes: 
        Router,
        Distributor, 
        Session and 
        Node

5. Upgraded Selenium IDE:

        Record and Playback tool
        Available as an add-on - Firefox, Chrome, and MS Edge
    • More stable and reliable            
    • Improved GUI
    • SIDE runner - Se IDE runner for CMD execution, grid, and node projects
    • Better element locator strategy

6. New APIs for CDP (Chrome DevTools Protocol): 

        Chrome DevTools - Set of tools built directly into chromium-basedbrowsers like chrome, Opera, and Microsoft Edge to help developers to debug and investigate the websites
    • Inspects element in the DOM
    • Edit elements and CSS on the fly
    • Check and monitor the site's performance
    • Mock Faster/Slower network's speeds
    • Mock geolocations of the Users
    • Execute and debug JavaScript
    • View console logs
    • Se 4 comes with native support for Chrome DevTools API
    • Capture and monitor the network traffic
    • Simulate poor network conditions
    • Perform geolocation testing
    • Change device mode to do responsive design testing
    new ChromiumDriver class, which includes two methods to access chrome devTools
    1. getDevTools()
    2. executeCdpCommand()  

7. Deprecations of Desired Capabilities:

    Desired Capabilities were primarily used in the test scripts to define the test environment (browser name, version, and operating system) for execution on the Selenium Grid
    Capabilities objects are replaced with options:
    • Firefox - FirefoxOptions    
    • Chrome - ChromeOptions
    • IE - InternetExplorerOptions
    • Microsoft Edge - EdgeOptions
    • Safari - SafariOptions
    Cloud-based Selenium Grid setup

        ChromeOptions options = new ChromeOptions();
        options.setAcceptInsecureCerts(true);
 
        options.setCapability("build", "Testing Chrome Options [Selenium 4]");
        options.setCapability("name", "Testing Chrome Options [Selenium 4]");
        options.setCapability("platformName", "Windows 10");
        options.setCapability("browserName", "Chrome");
        options.setCapability("browserVersion", "latest");

7. Modifications in the Actions class: 

    Actions class in Selenium is used to simulate input actions from mouse and keyboard on specific web elements (e.g. Left Click, Right Click, Double Click etc)












No comments:

Post a Comment