<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Shalini Baskaran</title>
    <description>The latest articles on Forem by Shalini Baskaran (@shalinibaskaran12).</description>
    <link>https://forem.com/shalinibaskaran12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F426073%2Fa88e3c39-dc69-4dc3-befb-3396e59b9923.png</url>
      <title>Forem: Shalini Baskaran</title>
      <link>https://forem.com/shalinibaskaran12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shalinibaskaran12"/>
    <language>en</language>
    <item>
      <title>Top 10 PHP Testing Frameworks for 2024</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Wed, 24 Apr 2024 12:48:42 +0000</pubDate>
      <link>https://forem.com/testmuai/top-10-php-testing-frameworks-for-2024-4gee</link>
      <guid>https://forem.com/testmuai/top-10-php-testing-frameworks-for-2024-4gee</guid>
      <description>&lt;p&gt;A framework is a collection or set of tools and processes that work together to support testing and developmental activities. It contains various utility libraries, reusable modules, test data setup, and other dependencies. Be it web development or testing, there are multiple frameworks that can enhance your team’s efficiency and productivity. Web testing, in particular, has a plethora of frameworks, and selecting a framework that suits your needs depends on your language of choice.&lt;/p&gt;

&lt;p&gt;Amongst all server-side programming languages, 76.5% of websites use PHP, and the right framework can make the job easier. We decided to dive deeper into PHP and find out what the best PHP testing frameworks are. In this blog, we will be focusing on automated testing frameworks and will be listing out the best PHP frameworks that will allow you to write your test cases in a standard format.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.lambdatest.com/test-site-on-mobile?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Testing website on different devices&lt;/a&gt; easily with LT Browser, free responsive testing tool. Just enter the URL in the mobile site tester to test site’s compatibility across 50+ device viewports.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Choosing The Best PHP Testing Frameworks
&lt;/h2&gt;

&lt;p&gt;If you want to pick the best framework, no matter whether its a new PHP framework or a well-known &lt;a href="https://www.lambdatest.com/blog/best-javascript-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JavaScript framework&lt;/a&gt;, it has to be structured in such a manner that it provides various benefits as listed below-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Maintains a well-defined code structure&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintains reusable modules and libraries which can effectively be used for testing, thereby achieving code reusability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enhances the speed of the testing process&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improves test efficiency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoids code duplication&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Analyzes test coverage as well as requirement coverage&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A framework is an integral part of testing, and hence it is crucial to select the framework type based on our project requirement. First of all, to set up a framework, one must know each framework’s pros and cons. Only then it will be easy to list out our requirements and select specific automated testing frameworks. Once you have an idea about your needs, you can go ahead and choose one amongst the best PHP testing frameworks.&lt;/p&gt;

&lt;p&gt;To help you in doing that, let’s take you through the best PHP frameworks in detail.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Find a &lt;a href="https://www.lambdatest.com/aws-device-farm-alternative?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;AWS Device Farm &lt;/a&gt;alternative for better performance, coverage &amp;amp; support at a fraction of cost. Try LambdaTest for free!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Best PHP Testing Frameworks Of 2024
&lt;/h2&gt;

&lt;p&gt;Several frameworks have been and are being used for development and testing purposes. But each one is unique in its own way and offers unique features. We will discuss how the best PHP testing frameworks approach &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; and what pros or cons they all offer. Without further ado, let’s look at the best PHP frameworks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;PHPUnit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Codeception&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Storyplayer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Selenium&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Behat&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Atoum&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SimpleTest&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PhpSpec&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Peridot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kahlan&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As promised above, we will now analyze each of these PHP testing frameworks in detail to help you make the final choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. PHPUnit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3786%2F0%2A1NYqDAffboWRxMDg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3786%2F0%2A1NYqDAffboWRxMDg.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PHPUnit is the most commonly used PHP testing framework, and it is considered a programmer-oriented framework. It is mostly preferred for unit testing. It was developed by Sebastian Bergmann and is an instance of the &lt;a href="https://www.lambdatest.com/blog/xunit-testing-tutorial-environment-setup/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;xUnit framework&lt;/a&gt; architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;There are a few prerequisites that must be satisfied before installing this framework. Firstly, you need to install a higher version of PHP for installing the latest version of PHPUnit. As per their official documentation, it is recommended to use PHP version 7.3 for PHPUnit 11, the latest PHPUnit version. Below are the steps to install PHPUnit in your system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; PHPUnit can be installed by downloading the PHAR (PHP Archive).&lt;/p&gt;

&lt;p&gt;PHAR has all the required PHPUnit dependencies bundled in a single file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; You may also install Composer which manages all the dependencies in the project.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Test your native app and website on real iOS and Android devices hosted on the cloud. LambdaTest is a convenient, cost-effective and centralised solution for running realtime and Automated &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test android app on real device&lt;/a&gt; cloud.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Advantages Of Using PHPUnit Framework
&lt;/h2&gt;

&lt;p&gt;PHPUnit is considered one of the best PHP frameworks due to several reasons. Listed below are some of the advantages of using PHPUnit for automated testing-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It is one of the frameworks which allows us to analyze the code coverage efficiently. Based on an in-depth analysis, it can also generate code coverage reports in HTML and also XML log files with more information. Sometimes there might be a few blocks of code that cannot be tested. In such cases, we can use different annotations like @codeCoverageIgnore, @codeCoverageIgnoreStart, and @codeCoverageIgnoreEnd, which are used to ignore certain code blocks while running through code coverage analysis. We can also run the code coverage analysis for certain code blocks by specifying them with @covers annotation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;While writing the test cases, some tests would be left without any implementations. When executed, those cases return a success message, but it isn’t very meaningful to have such a report. PHPUnit provides an interface that raises an exception when an unimplemented test is run.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;All the tests can be grouped together into a suite and run at once with the help of an XML configuration file.A simple XML configuration file would look like below-&lt;/p&gt;

&lt;p&gt;tests/FirstTest.php&lt;br&gt;
tests/SecondTest.php&lt;br&gt;
tests/ThirdTest.php&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are a PHP expert, you can acquire a benchmark industry certification specializing in core PHP programming skills and expand your opportunities to advance your career in &lt;a href="https://www.lambdatest.com/php-automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;PHP automation testing&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Perform browser compatibility testing on real &lt;a href="https://www.lambdatest.com/online-device-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;device farms&lt;/a&gt; on the cloud with thousands of mobile OS environments, like Apple, Samsung, OnePlus, &amp;amp; many more.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Codeception
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3786%2F0%2AKGYnZ4Y6F5tBTQa_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3786%2F0%2AKGYnZ4Y6F5tBTQa_.png" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Codeception is one of the most widely used PHP testing frameworks, and it has gained immense popularity because of ease of use and its ability to maintain the code modules. It supports three levels of testing, namely acceptance testing, functional testing, and unit testing. It provides multiple modules that can be utilized for testing purposes in a single framework.&lt;/p&gt;

&lt;p&gt;Let us see the steps to install Codeception and the advantages of using this automated testing framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;Before you install Codeception, you need to know if the prerequisites are met. You will need-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;PHP with version greater than 5.6 installed in your machine&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Curl has to be enabled&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you have met the prerequisites, you need to follow the below-mentioned steps to proceed further-&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Install composer which is used for managing the dependencies in PHP. It helps in declaring the libraries to be used in the project and manages them.&lt;/p&gt;

&lt;p&gt;You may install using a setup file or you can even do it manually. You can install the composer from their official website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Install PHAR, and you may install it from the official website of Codeception.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Harness the power of real device testing through the&lt;a href="https://www.lambdatest.com/mobile-testing-lab?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt; mobile device lab&lt;/a&gt;, showcasing a vast mobile device lab for genuine device testing scenarios.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Codeception Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It supports Unit testing, functional testing, as well as acceptance testing. We can opt for any of the three types of testing or sometimes can opt for all three to test the application effectively. If you are wondering, this is the exact reason why it is also known as a ‘full stack testing framework.’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It uses simple naming conventions, which helps everyone to understand the code. It contains action keywords, assertions, and grabbers. The actions keywords are used to perform user actions like clicking, pressing the keys, filling the input fields, etc. The assertion keywords are used to perform the verification like the one that is done using TestNG and Junit. The grabbers are used to extract the information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It also provides an option of running the user stories in BDD like JBehave and Cucumber.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides various database modules, which would be quite helpful in database testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has a WebDriver module, which could be used for acceptance testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has a REST module, which could be very helpful for testing web services. This module also validates the JSON responses, extracting data from specific JSON tags, verifying xml responses, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It helps integrate with continuous integration tools like &lt;a href="https://www.lambdatest.com/learning-hub/jenkins" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt; and Teamcity, which would help generate the test reports.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  3. Storyplayer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3798%2F0%2AarCeLcEtbG2hlKyo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3798%2F0%2AarCeLcEtbG2hlKyo.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Storyplayer is an open-source PHP testing framework which is used to perform end to end testing. It is best suited for API automation testing and testing web applications. It provides multiple programming language support, which is one reason behind its popularity as one of the best PHP frameworks.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Find a AWS Device Farm alternative for better performance, coverage &amp;amp; support at a fraction of cost. Try LambdaTest for better &lt;a href="https://www.lambdatest.com/aws-device-farm-alternative?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;aws device farm pricing&lt;/a&gt; !&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; As it is a PHP testing framework, it requires PHP to be installed before setting up this framework. Currently it supports only Apple OSX Yosemite and Ubuntu Linux Desktop 14.10.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; It is also required to add some extensions like CURL, JSON, OpenSSL etc. You can read further in their official website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Storyplayer Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It offers an open source framework, which is quite useful if you are a newbie in PHP web development. You don’t need to take a subscription or pay a fee to avail the services of Storyplayer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Another great advantage of using the Storyplayer PHP testing framework is the amazing support it provides for multiple programming languages. This makes PHP development and testing much easier and competitive.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  4. Selenium
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3790%2F0%2Anmkb8l1E_gQxM1LR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3790%2F0%2Anmkb8l1E_gQxM1LR.png" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; is the one of most popularly used automated testing frameworks that has been extensively used for testing web applications. It has 3 main components namely-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/selenium-ide?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium IDE&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/selenium-grid?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium Grid&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These components are designed for specific purposes, and the selection of the component purely depends upon our testing requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;To work with Selenium, you need to set up the latest version of PHP. Also, it is required to have Composer, which manages all the dependencies for our project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Selenium Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Selenium is an open source automation testing framework.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has an amazing support community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is easy to install, and test case implementation is quite easy as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It allows us to run our test cases in different browsers like Google Chrome, Firefox, Safari, Internet Explorer and allows seamless browser compatibility testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It executes our test scripts in parallel in multiple browsers and operating systems for faster test execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is also used to perform the keyboard and mouse interactions with the browser.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How To Overcome The Limitations Of Selenium With LambdaTest Selenium Grid?
&lt;/h2&gt;

&lt;p&gt;AI-powered test orchestration and execution platform like LambdaTest offers a great platform to run your PHP automation scripts on a &lt;a href="https://www.lambdatest.com/selenium-grid-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online Selenium Grid&lt;/a&gt; and achieve faster test execution. There are endless benefits of running the tests in the LambdaTest grid.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Quick and easy setup to run your automation scripts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute your tests in different browsers with different versions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integration with various continuous integration and deployment tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Allows to define various parameters like browser name, version of the browser, operating system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides the option to take screenshots and record videos while executing the test cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Most importantly, it provides 24X7 customer support and detailed documentation.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Below is the simple code to search a product on Google using LambdaTest grid-&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php 
require 'vendor/autoload.php';

class LambdaTestGrid{

  /*
      Setting up remote driver in LambdaTestGrid
      Params
      ----------
      platform : Supported platform - (Windows 10, Windows 8.1, Windows 8, Windows 7, macOS High Sierra, macOS Sierra, OS X El Capitan, OS X Yosemite, OS X Mavericks)
      browserName : Supported platform - (chrome, firefox, Internet Explorer, MicrosoftEdge, Safari)
      version :  Supported list of version can be found at https://www.lambdatest.com/capabilities-generator/
  */
  protected static $driver;

  public function searchTextOnGoogle() {
    # username: replace your username that can be found in your LambdaTest dashboard    
    $LT_USERNAME = "{username}";

    # accessKey:  replace your access token that has been generated once you signed up
    $LT_APPKEY = "{accessKey}";

    $LT_BROWSER = "chrome";
    $LT_BROWSER_VERSION ="70.0";
    $LT_PLATFORM = "windows 10";

    # URL: @hub.lambdatest.com/wd/hub"&amp;gt;https://{username}:{accessToken}@hub.lambdatest.com/wd/hub
    $url = "https://". $LT_USERNAME .":" . $LT_APPKEY ."@hub.lambdatest.com/wd/hub";       

    # setting desired capabilities for the test
    $desired_capabilities = new DesiredCapabilities();
        $desired_capabilities-&amp;gt;setCapability('browserName',$LT_BROWSER);
        $desired_capabilities-&amp;gt;setCapability('version', $LT_BROWSER_VERSION);
        $desired_capabilities-&amp;gt;setCapability('platform', $LT_PLATFORM);
        $desired_capabilities-&amp;gt;setCapability('name', "Php");
        $desired_capabilities-&amp;gt;setCapability('build', "Php Build");
        $desired_capabilities-&amp;gt;setCapability('network', true);
        $desired_capabilities-&amp;gt;setCapability('visual', true);
        $desired_capabilities-&amp;gt;setCapability('video ', true);
        $desired_capabilities-&amp;gt;setCapability('console', true);

        self::$driver = RemoteWebDriver::create($url, $desired_capabilities);      
      //specify the browser URL           
    self::$driver-&amp;gt;get("https://www.google.com/");
 //specify the locator of the search box
        $element = self::$driver-&amp;gt;findElement(WebDriverBy::name("q"));
    if($element) {
//type the name to be searched in the google search box
      $element-&amp;gt;sendKeys("IPhone");
      $element-&amp;gt;submit();
    }  
    print self::$driver-&amp;gt;getTitle();
    self::$driver-&amp;gt;quit();
  }    
}

?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once the tests have been executed, you can view the logs and other builds related information in the &lt;a href="https://automation.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Web Automation dashboard&lt;/a&gt;. Thus, running the tests in LambdaTest Grid improves the execution speed and also provides efficient results.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Don’t let internationalized domain names (IDNs) slow you down. Our free online &lt;a href="https://www.lambdatest.com/free-online-tools/json-stringify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;IDN Decode&lt;/a&gt; tool makes it easy to convert any IDN to its ASCII representation. Decode IDs in seconds!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  5. Behat
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3778%2F0%2AW70futrY9vpnu-xM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3778%2F0%2AW70futrY9vpnu-xM.png" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Behat is a &lt;a href="https://www.lambdatest.com/learning-hub/behavior-driven-development?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Behavior Driven Development&lt;/a&gt; (BDD) framework for PHP. It was built entirely for PHP, and it has many core PHP modules in it. The code is usually written in simple English language, easily understandable by all the stakeholders in the project. The BDD structure usually contains the Context, Action, and Outcome, and this format is called Gherkin. Below is a simple example of writing tests in the Gherkin language.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scenario: Login into Facebook and verify if the user is successfully logged in

Given the user enters his username and password
When the user clicks sign in button
Then the user should be successfully logged into his Facebook homepage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;These scenarios are written in a file with extension features. For example, loginTest.feature in the above case. Behat is an executable that is used to run the tests from the command line for testing the application exactly similar to the execution of feature files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;To setup &lt;a href="https://www.lambdatest.com/selenium-automation-testing-with-behat-framework?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Behat framework&lt;/a&gt; make sure you have installed the below prerequisites-&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; PHP latest version.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Composer which manages all the PHP dependencies for the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; If you don’t have a Composer, you can easily set up the framework by downloading the latest version of behat.phar.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Convert your XML files to JSON format without any hassle using our reliable and efficient &lt;a href="https://www.lambdatest.com/free-online-tools/xml-to-json-converter?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;XML to JSON converter&lt;/a&gt; tool. No installation or download required.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Behat Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Easy to install and implement.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to understand the test cases as everything is written in BDD. The tests are written in simple English language, which helps all the project stakeholders understand the requirement and the test cases mapped to it. The scenarios are written in a feature file and consist of the context, the subsequent action, and the final expected result. These are written using the Given, When and Then keywords in Gherkin language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Detailed documentation which helps everyone to implement the framework easily.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is an open source testing framework.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  6. Atoum
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3766%2F0%2AQXPWsozaFG0EKT7U.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3766%2F0%2AQXPWsozaFG0EKT7U.png" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Atoum is another one of the popular PHP testing frameworks which is used for Unit testing. It is very simple and easy to implement, and it is amongst the new PHP frameworks you will come across. Also, it’s among the best PHP frameworks. It provides various inbuilt execution engines such as the inline engine, isolation engine, and concurrent engines. Those are used to execute test cases one by one, one after another test case each time in a new process, and run all the test cases in parallel simultaneously in different processes separately. Atoum also provides advanced features that help to mock the build, minimizing the dependencies for running the tests.&lt;/p&gt;

&lt;p&gt;Now let us see the steps involved in the installation of the Atoum framework along with its advantages.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.lambdatest.com/free-online-tools/json-to-xml-converter?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JSON to XML Converter&lt;/a&gt; is a simple and fast tool that converts JSON to XML data. Use this tool to convert your JSON documents into valid XML for easy data exchange.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;Before installation, make sure you have the latest version of PHP installed in your system. You can set up an Atoum framework by either one of the ways.&lt;/p&gt;

&lt;p&gt;Step 1: By using Composer which can be downloaded from their official website.&lt;/p&gt;

&lt;p&gt;Step 2: By using a PHAR file which can be downloaded from this link.&lt;/p&gt;

&lt;p&gt;Step 3: By cloning from the Atoum GitHub Repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Atoum Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Easy to write test cases based on our convenience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides multiple assertions, which makes them highly effective when implemented in test cases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mocking can be quickly done using the Atoum framework, which reduces the waiting time for resolving our dependencies and makes test execution faster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate test reports in different formats.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Atoum Framework can also be integrated with continuous integration tools like Jenkins, Travis CI, CircleCI, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Several plugins can be added to this framework, thereby making the testing framework more stable. Some of the extensions are-&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;json-schema-extension — for validating the JSON tags&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;bdd-extension — for writing BDD style test cases which has better readability&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;reports-extension — for writing code coverage reports&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. SimpleTest
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3794%2F0%2AzqXFBE-5ZbBcQXrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3794%2F0%2AzqXFBE-5ZbBcQXrb.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SimpleTest is a PHP testing framework that could be used for unit testing. Apart from unit testing, it is also used for website testing and for mocking objects for PHP web development. This framework’s unique feature is that it has an inbuilt web browser that allows users to navigate to different web pages and perform testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Setting up the SimpleTest framework requires the latest version of PHP to be installed in the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Once it is done you may setup the framework by downloading from their official website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using SimpleTest Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;SimpleTest is very useful for unit testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides an extensive support for forms, SSL, frames, proxies, and basic authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has an inbuilt web browser, which helps in testing web applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using this PHP testing framework, tests can be executed through the browser as well as the command line.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can also be used in collaboration with PHPUnit, another one of the best PHP testing frameworks we discussed above.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SimpleTest is highly flexible as it allows result or output customization.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simplify the process of converting &lt;a href="https://www.lambdatest.com/free-online-tools/json-to-yaml?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;JSON to YAML&lt;/a&gt; with our online JSON to YAML converter tool to convert JSON files to YAML. No sign-up required. Get started now!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  8. Phpspec
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3794%2F0%2A1Q-92degXP6xFS_p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3794%2F0%2A1Q-92degXP6xFS_p.png" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Phpspec is another Behavior Driven Development (BDD) framework that is used to write and execute tests written in PHP. It is well-known for driving the design according to the specifications provided by the developer.&lt;/p&gt;

&lt;p&gt;A BDD framework contains specifications written in the English language, which helps in understanding the tests. It describes the behavior of the application using Gherkin language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Before installing Phpspec, you need to install PHP 5.6 or 7 in your system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Once done, you can install using Composer, which automatically manages all the project dependencies. While installing Composer, make sure that the autoload settings of the composer are correct. Phpspec won’t be able to detect classes unless the settings are correctly specified.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Once you have finished installing Composer, you can install Phpspec using the following command-&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require –dev Phpspec/Phpspec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After everything is done, you will notice that all your dependencies have been successfully installed in the vendor folder. And the executable file will be found in vendor/bin/phpspec.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Phpspec Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Phpspec automatically generates skeletons for the classes and the methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It also has a mocking framework.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides 14 in-built matchers to verify the results and describe how our tests should behave. Some of the commonly used matchers are comparison matchers, approximately matchers, type matchers, and identity matchers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This framework can be extended by configuring plugins like the DataProvider plugin, framework integration plugin, code generation plugin, and matchers plugin.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  9. Peridot
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3810%2F0%2ApDpOXgvdkynaZZUU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3810%2F0%2ApDpOXgvdkynaZZUU.png" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Peridot is another one of the widely used PHP testing frameworks, which is a type of BDD framework. Some developers even claim that it is one of the best PHP frameworks available for a BDD approach. The tests are written in describe-it syntax in Peridot, which makes it simpler to read, understand, and maintain. It is considered one of the fastest among the PHP framework as it loads and runs the test suites quickly and runs them concurrently.&lt;/p&gt;

&lt;p&gt;Below is a simple code for writing tests in Peridot using describe-it syntax&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe('Welcome page', function() {
    it(must have a welcome message, function() {
        $this-&amp;amp;gt;getPage('http://myTestWebsite.com');
        $message = $this-&amp;amp;gt;findElementById(welcmeMessage);
        assert($message-&amp;amp;gt;getText() === "Hello", "should be Hello");
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Need to convert BCD codes to Decimal quickly? Our &lt;a href="https://www.lambdatest.com/free-online-tools/bcd-to-decimal?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;BCD to Decimal&lt;/a&gt; Converter tool provides an easy way to convert BCD codes to Decimal. Try it now and save time!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Steps To Install
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; You can easily install this using Composer which will manage our project dependencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; It can also be installed manually by downloading the PHAR.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Peridot Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Peridot uses the familiar describe-it syntax to create a clear and readable testing language.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be extended with various types of plugins, which can be used for customizing our test framework.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be integrated with WebDriver and databases for executing the tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Peridot is lightweight and is faster when compared to other PHP frameworks like Phpspec and PHPUnit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It also helps in executing the integration tests at high speed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has many reporters like Peridot List reporter, concurrency reporter, and code coverage reporter, each of which are uniquely designed for specific purposes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  10. Kahlan
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3778%2F0%2AkiVPrqEhbspiuEvA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3778%2F0%2AkiVPrqEhbspiuEvA.png" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Kahlan is a unit and behavior-driven PHP framework that uses a describe-it syntax similar to peridot. Without any PHP extensions, we can directly stub or monkey patch our code. It is also an open source framework, which makes it highly preferable for testing purposes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So, what is a describe-it syntax?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Kahlan uses describe-it syntax for easy maintenance and understanding of the tests. The “describe” keyword usually contains the method specs. The “it” keyword” contains the code to be tested, which should be kept short and clear.&lt;/p&gt;

&lt;p&gt;Below is a simple code which provides a clear idea of the describe-it syntax&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe("myFunction", function() {&lt;br&gt;
    describe("::match()", function() {&lt;br&gt;
        it("passes if true === true", function() {&lt;br&gt;
            expect(true)-&amp;amp;gt; myFunction (true);&lt;br&gt;
        });&lt;br&gt;
    });&lt;br&gt;
});&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Steps To Install&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Installation of Kahlan requires PHP of version more than 5.5 to be installed in the system. If code coverage analysis is required, phpdbg or xdebug is also required. Xdebug is a PHP extension which could be used for debugging purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; As a PHP framework it is always recommended to install using Composer as it helps in managing the project dependencies.&lt;/p&gt;

&lt;p&gt;You can also manually set up the framework by referring to the official website of Kahlan.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages Of Using Kahlan Framework
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;It provides a lot of matchers that can be used for testing various scenarios.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides stub options which can be used to resolve the dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It has built in reporters and exporters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is easily extendable and can be customized as per our requirements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It allows us to use setUp and tearDown methods like beforeAll, beforeEach, afterEach, and afterAll.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Kahlan has inbuilt code coverage exporters, which can be used to get detailed information on the code coverage.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2448%2F0%2APAe3sgvlZwg5AC_m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2448%2F0%2APAe3sgvlZwg5AC_m.png" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up!
&lt;/h2&gt;

&lt;p&gt;In this blog, we have walked you through the importance of PHP frameworks, different types of PHP frameworks, steps to set up, and the advantages of using the framework. Depending on the requirements, you can choose the best PHP frameworks. These PHP testing frameworks can be used for both PHP web development as well as testing purposes. Thus, implementing the correct framework would help you to perform testing effectively.&lt;/p&gt;

&lt;p&gt;We hope you now have a clear idea of selecting a suitable PHP framework for your project. And now, we would like to hear from you — have you implemented any other PHP framework that has proved useful?&lt;/p&gt;

&lt;p&gt;If you found this blog valuable, we’d be grateful if you could share it on your LinkedIn or Twitter.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Need to convert &lt;a href="https://www.lambdatest.com/free-online-tools/hex-to-decimal?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=apr_24&amp;amp;utm_term=bh&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;hex to decimal&lt;/a&gt;? Our online Hex to Decimal Converter tool converts hexadecimal to decimal numbers quickly. Get your conversions done in no time.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>testing</category>
    </item>
    <item>
      <title>How To Deal With “Element is not clickable at point” Exception Using Selenium</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Tue, 28 Feb 2023 22:44:08 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-deal-with-element-is-not-clickable-at-point-exception-using-selenium-49h2</link>
      <guid>https://forem.com/testmuai/how-to-deal-with-element-is-not-clickable-at-point-exception-using-selenium-49h2</guid>
      <description>&lt;p&gt;Any automation testing using Selenium (or Cypress) involves interacting with the WebElements available in the DOM. &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Test automation&lt;/a&gt; framework underpins a diverse set of locators that are used to identify and interact with any type of element on the web page. For example, ID, name, className, XPath, cssSelector, tagName, linkText, and partialLinkText are some of the widely used that help you interact with the elements on the web page. These locators help you perform any type of web element interactions using Selenium.&lt;/p&gt;

&lt;p&gt;Identifying the elements may be an easy task, but your tests might fail due to the state of the WebElement (e.g., not visible, not clickable, etc.). As a test automation engineer, it is important to consider these things to build a fool-proof test automation strategy.&lt;/p&gt;

&lt;p&gt;In such cases, the tests might throw &lt;a href="https://www.lambdatest.com/blog/49-common-selenium-exceptions-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;different types of exceptions&lt;/a&gt; like NoSuchElementException, ElementNotVisibleException, etc. This is often caused as the WebElement on the web page is not found, not interactable, or could be another issue with the corresponding WebElement. In this part of the &lt;a href="https://www.lambdatest.com/blog/selenium-java-tutorial-how-to-test-login-process/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Java tutorial&lt;/a&gt;, we would look at one of those exceptions — “Element is not clickable at the point.” By the end of the tutorial, you would be in a position to handle this exception like a pro!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Learn more about &lt;a href="https://www.lambdatest.com/blog/automated-functional-testing-what-it-is-how-it-helps/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;functional testing&lt;/a&gt;, and how automating them can give you a faster release cycle!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the “Element is not clickable at point” exception?
&lt;/h2&gt;

&lt;p&gt;The exception “Element is not clickable at point” usually occurs when the WebElement we want to interact with (or click) is not clickable at that point. This essentially means that the click operation on the WebElement would result in an exception. So, what are the causes of the exception? First, let’s deep dive into the various causes behind the “Element is not clickable at point” exception.&lt;/p&gt;

&lt;p&gt;There is a higher probability of getting this exception with the Chrome browser, as Chrome never calculates the exact location of any WebElement. Instead, it tries to perform a click in the middle of the WebElement. Hence, you might get the “Element is not clickable at point.” exception when running tests on Chrome.&lt;/p&gt;

&lt;p&gt;Does this mean that there is zero probability of witnessing this exception when running &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation tests&lt;/a&gt; on Firefox, Microsoft Edge, or any other web browser? The underlying implementation differs from one browser to another. Hence, sometimes you may encounter this exception when clicking an element at a specific point (or coordinate).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/usability-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Usability Testing&lt;/a&gt;: A Comprehensive Guide With Examples And Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the causes of the “Element is not clickable at point” exception?
&lt;/h2&gt;

&lt;p&gt;In this section of the Selenium Java tutorial, let us understand the major causes of the “Element is not clickable at point” exception.&lt;/p&gt;

&lt;p&gt;Below are the major causes of the exception:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;WebElement to be clicked is disabled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebElement is not yet available (or loaded) on the web page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebElements overlap with each other.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Failure in locating WebElement using coordinates on the page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let us see the above causes in detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cause 1: WebElement to be clicked is disabled
&lt;/h2&gt;

&lt;p&gt;In a web application, if you skip filling any mandatory fields in a form or while creating an account, you would come across the Submit (or Create Account) in a disabled state.&lt;/p&gt;

&lt;p&gt;When trying to interact with such a WebElement, the “Element is not clickable at point” exception pops up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Jest Tutorial: Complete Guide to &lt;a href="https://www.lambdatest.com/jest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Jest Testing&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cause 2: WebElement is not yet available (or loaded) on the web page
&lt;/h2&gt;

&lt;p&gt;Most websites use AJAX for the dynamic loading of web content. Therefore, the test cases should be implemented considering this dynamism. You will encounter the said exception if the test script is trying to interact with the WebElement, which is not yet available in the DOM.&lt;/p&gt;

&lt;p&gt;Read — &lt;a href="https://www.lambdatest.com/blog/implicit-explicit-wait-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How To Handle Synchronization In Selenium PHP Using Implicit and Explicit Wait?&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cause 3: WebElements overlap with each other
&lt;/h2&gt;

&lt;p&gt;You might have overlapping WebElements on a webpage which poses significant challenges when running Selenium automation tests on the page. For example, when trying to interact with an element with another element overlapping it, it would throw the exception “Element is not clickable at point.”&lt;br&gt;
Since this makes an interesting scenario, let’s look at a cross browser testing example which we would run on cloud-based Selenium Grid by LambdaTest. Running Selenium tests on a LambdaTest helps you attain better browser coverage, expedited test execution, and faster product release via integration with &lt;a href="https://www.lambdatest.com/blog/best-ci-cd-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;popular CI/CD tools.&lt;/a&gt; Furthermore, &lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing&lt;/a&gt; is one of the major advantages of running tests on a cloud-based Grid like LambdaTest.&lt;/p&gt;

&lt;p&gt;Read — &lt;a href="https://www.lambdatest.com/blog/cloud-testing-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Everything You Need To Know About Cloud Testing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For demonstration, we navigate to &lt;a href="https://www.freecrm.com/" rel="noopener noreferrer"&gt;https://www.freecrm.com/&lt;/a&gt; and log in by clicking the “Login” button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7pikrwyzehsmmjlfkz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7pikrwyzehsmmjlfkz3.png" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the code snippet that helps you realize the test scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  package Pages;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.*;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.support.ui.ExpectedCondition;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.testng.annotations.*;
    import java.net.MalformedURLException;

    public class First
    {
        public static void main(String[] args)
        {
            WebDriver driver = null;

            /* Get username and access key from https://accounts.lambdatest.com/detail/profile */
            String username = "lambdatest_user_name";
            String access_key = "lambdatest_access_key";

            /* For local WebDriver */
            /* System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver\\chromedriver.exe"); */
            /* WebDriver driver = new ChromeDriver(); */

            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("build", "[Java] How to Deal with Element is not clickable at point Exception");
            capabilities.setCapability("name", "[Java] How to Deal with Element is not clickable at point Exception");
            capabilities.setCapability("platform", "Windows 10");
            capabilities.setCapability("browserName", "Chrome");
            capabilities.setCapability("version","latest");
            capabilities.setCapability("tunnel",false);
            capabilities.setCapability("network",true);
            capabilities.setCapability("console",true);
            capabilities.setCapability("visual",true);

            try
            {
                driver = new RemoteWebDriver(new URL("http://" + username + ":" + access_key + "@hub.lambdatest.com/wd/hub"), capabilities);
            }
            catch (MalformedURLException e)
            {
                System.out.println("Invalid grid URL");
            }
            System.out.println("Started session");

            driver.get("https://www.freecrm.com/");
            WebElement element = driver.findElement(By.xpath("//span[text()='Log In']"));

            /* Click on the button */
            element.click();

            /* Close the browser instance */
            driver.close();
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When running the above test, we encountered the “Element is not clickable at point” as the Login button is overlapped with another element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faebmiqgqhc6yqw4vjjdj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faebmiqgqhc6yqw4vjjdj.png" width="800" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the stack trace of the exception:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element &amp;lt;span&amp;gt;...&amp;lt;/span&amp;gt; is not clickable at point (961, 45). Other element would receive the click: &amp;lt;button style="border-color: rgb(0, 0, 0); font-size: 0.9em;"&amp;gt;...&amp;lt;/button&amp;gt;
      (Session info: chrome=91.0.4472.114)
    Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Run &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt; mobile testing of native and web apps. Improve your app quality with instant access to real devices on LambdaTest.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Cause 4: Failure in locating WebElement using coordinates on the page
&lt;/h2&gt;

&lt;p&gt;Many times, you would need to identify the locators using their coordinates. The coordinates of the elements would differ depending upon the window size. Hence, it is a good practice to maximize the browser window when performing Selenium automation testing. You can read our detailed blog on &lt;a href="https://www.lambdatest.com/blog/selenium-best-practices-for-web-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Best Practices For Web Automation Testing&lt;/a&gt; to avoid issues you might frequently encounter when running Selenium tests.&lt;/p&gt;

&lt;p&gt;Now that we have covered the different causes of the “Element is not clickable at point” exception, it’s time to deep dive into the potential solutions to avoid this exception.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9xu4utym2tzv1rdod3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9xu4utym2tzv1rdod3p.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Test your native, hybrid, and web apps across all legacy and latest mobile operating systems on the most powerful &lt;a href="https://www.lambdatest.com/intl/en-in/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Android emulator&lt;/a&gt; online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to fix the “Element Is Not Clickable at Point” exception?
&lt;/h2&gt;

&lt;p&gt;There are some simple yet effective ways to resolve this exception. Let’s look at some of the ways to get rid of this exception in this part of the Selenium Java tutorial:&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution 1: Adding Waits To Selenium Tests
&lt;/h2&gt;

&lt;p&gt;To handle elements that take some time to load on the web page, you may add waits in Selenium. The added delay helps ensure that the WebElement to be interacted with is available on the web page. Have a look at the &lt;a href="https://www.lambdatest.com/blog/types-of-waits-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;different Waits in Selenium&lt;/a&gt; that can help you achieve this task.&lt;/p&gt;

&lt;p&gt;You can consider adding implicit waits, explicit waits, or fluent waits, depending upon the requirement. This would add some wait time for the WebElement(s) to load before performing interactions on the same.&lt;/p&gt;

&lt;p&gt;For example, we can add explicit wait for a specific element so that it loads completely and is identified to be clickable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  WebDriverWait wait = new WebDriverWait(driver, 10);
    wait.until(ExpectedConditions.elementToBeClickable(By.id("Login")));
    driver.findElement(By.id("Login")).click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Watch this video to learn what are waits in Selenium and how to handle them using different methods like hard-coded pauses and by combining explicit waits with different design patterns.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cgErlkHg_cI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Run your &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation&lt;/a&gt; Testing scripts on the LambdatTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution 2: Maximizing the browser window
&lt;/h2&gt;

&lt;p&gt;When coordinates are used to identify the elements in the tests, it is always considered good practice to maximize your browser window. This ensures that the coordinates defined in your tests match with those on the page, as the browser is in the maximized state. Here is how you can avert the “Element is not clickable at point” exception by simply maximizing the web browser window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   System.setProperty("webdriver.chrome.driver", "Path_To_Chrome_Driver");
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution 3: Using JavascriptExecutor for performing mouse clicks
&lt;/h2&gt;

&lt;p&gt;When the waits don’t help resolve the problem, you can use the &lt;a href="https://www.lambdatest.com/blog/how-to-use-javascriptexecutor-in-selenium-webdriver/" rel="noopener noreferrer"&gt;JavascriptExecutor&lt;/a&gt; to perform the click operation.&lt;/p&gt;

&lt;p&gt;JavaScriptExecutor is a key interface that allows you to execute JavaScript on the window or page of the browser using &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;. In addition, it provides methods to run JavaScript against the window (or page) from your test script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    WebElement element = driver.findElement(By.id("Login"));
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript(“arguments[0].click();”, element);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution 4: Using Actions class in Selenium
&lt;/h2&gt;

&lt;p&gt;The exception “Element is not clickable at point” might be thrown when the element is not under focus or the action is being performed on the incorrect WebElement. In such cases, you have to switch to the actual element and perform the click action.&lt;/p&gt;

&lt;p&gt;To handle this scenario, use the &lt;a href="https://www.lambdatest.com/blog/what-is-actions-class-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Actions class in Selenium&lt;/a&gt; to switch to the specific element and performing the click operation as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  WebElement element = driver.findElement(By.id("Login"));
    Actions actions = new Actions(driver);
    actions.moveToElement(element).click().build().perform();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also log onto the &lt;a href="https://community.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=community" rel="noopener noreferrer"&gt;LambdaTest Community&lt;/a&gt; to get answers to questions like the “&lt;a href="https://community.lambdatest.com/t/element-is-not-clickable-at-point-error/6160?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=community" rel="noopener noreferrer"&gt;Element is not clickable at point” error&lt;/a&gt; and more. It’s time to leverage the expertise of the community to solve technical problems at an expedited pace!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvm5mgou8uhbmkpiwnmh5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvm5mgou8uhbmkpiwnmh5.jpg" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For faster and improved test results, I would recommend a cloud-based Selenium Grid. LambdaTest is one such platform that provides &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on all major browsers and 3000+ operating systems online.&lt;/p&gt;

&lt;p&gt;Read — &lt;a href="https://www.lambdatest.com/blog/common-challenges-in-selenium-automation-how-to-fix-them/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Common Challenges In Selenium Automation &amp;amp; How To Fix Them?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Parallel Testing With JUnit 5 And Selenium [Tutorial]</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Tue, 28 Feb 2023 12:33:24 +0000</pubDate>
      <link>https://forem.com/testmuai/parallel-testing-with-junit-5-and-selenium-tutorial-38ej</link>
      <guid>https://forem.com/testmuai/parallel-testing-with-junit-5-and-selenium-tutorial-38ej</guid>
      <description>&lt;p&gt;Parallel test execution with Selenium is one of the major factors that can affect the test execution speed. Serial execution in &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; can be effective only if the tests have to be run on a small number of browser and OS combinations. Therefore, parallel execution should be leveraged at the early stages of QA testing to expedite test execution rapidly.&lt;/p&gt;

&lt;p&gt;Though you can reap the benefits of &lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing in Selenium&lt;/a&gt; using a local Selenium Grid, it might not be a feasible option if you want to perform testing on umpteen combinations of browsers, operating systems, and devices. This is where testing on a cloud-based Selenium Grid like LamdaTest can be super advantageous. It can further help in expediting parallel test execution by leveraging the benefits offered by the Selenium Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0bf69u2vt5mr0mclhawg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0bf69u2vt5mr0mclhawg.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a Java developer, I am extensively using the features offered by the JUnit 5 framework for different test scenarios, including parallel testing with Selenium. JUnit 5 differs greatly from its predecessor (i.e., JUnit 4), with the differentiation starting with its core architecture. In case you are getting started with JUnit 5, I would recommend having a close look at the &lt;a href="https://www.lambdatest.com/blog/junit5-extensions/#Architecture?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit 5 architecture&lt;/a&gt; so that you can closely follow how to run tests with the framework.&lt;/p&gt;

&lt;p&gt;In this JUnit 5 tutorial, we deep dive into how to perform parallel test execution with the JUnit 5 framework. A number of features in JUnit 5 are in the experimental phase, including parallel test execution. But, like a good samaritan, you can also provide your valuable feedback to the JUnit team so that they can promote the feature and take it out of the experimental phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: A Complete &lt;a href="https://www.lambdatest.com/learning-hub/end-to-end-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;End to End (E2E) Testing&lt;/a&gt; Tutorial: Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to JUnit 5 Framework
&lt;/h2&gt;

&lt;p&gt;Before I deep dive into the essentials of the JUnit 5 parallel test execution, let me do a quick rundown of the basics of the JUnit 5 framework. In the JUnit 4 framework, all the functionalities are wrapped in a single package. On the other hand, JUnit 5 comprises three distinct sub-components — JUnit Platform, JUnit Jupiter, and JUnit Vintage.&lt;/p&gt;

&lt;p&gt;There is a significant difference as far as JUnit 5 annotations, and JUnit 4 annotations are concerned. Though some annotations in JUnit 5 have changed from a naming standpoint, annotations like @Rule and @ClassRule are removed, whereas new annotations like @ExtendWith and @RegisterExtension are added in the JUnit 5 framework.&lt;/p&gt;

&lt;p&gt;If you are coming from the JUnit 4 background, you can check out &lt;a href="https://www.lambdatest.com/blog/execute-junit4-tests-with-junit5/#JUnit5vsJUnit4?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit 4 vs JUnit 5 comparison&lt;/a&gt; to understand the differences between the two JUnit versions. Although there are umpteen reasons where JUnit 5 has a huge upper hand over JUnit 4, do check out &lt;a href="https://www.lambdatest.com/blog/junit5-extensions/#JUnit5?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;why to use JUnit 5&lt;/a&gt; that deep dives into the major advantages of the JUnit 5 framework.&lt;/p&gt;

&lt;p&gt;Shown below is the architectural view of the JUnit 5 framework:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsy7zhezcyinlnssjphd3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsy7zhezcyinlnssjphd3.png" width="512" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;JUnit 5 Architecture&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Overall, JUnit 5 is much more extensible due to its unique architecture, provides the flexibility to use multiple runners, and provides a set of useful annotations that enhance the tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Appium Tutorial: A Detailed Guide To &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium automation&lt;/a&gt; Testing&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  JUnit 5 Parallel Test Execution
&lt;/h2&gt;

&lt;p&gt;Now that we have covered the essentials of the JUnit 5 framework, we look at how to perform parallel test execution with JUnit 5 from a Selenium automation testing point of view. For running the tests, you would need a working setup of JUnit on your machine. Make sure to check out our blog on &lt;a href="https://www.lambdatest.com/blog/setup-junit-environment/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;how to set up a JUnit environment&lt;/a&gt; where the steps mentioned in the blog remain unchanged for JUnit 5.&lt;/p&gt;

&lt;p&gt;Let’s get to the million-dollar question ‘How to run JUnit 5 tests in parallel’? For starters, JUnit 5 parallel execution is still in the experimental feature and is expected to become mainstream in the upcoming version of JUnit 5. So, to enable parallel test execution in JUnit 5, set junit.jupiter.execution.parallel.enabled to true in junit-platform.properties file.&lt;/p&gt;

&lt;p&gt;Read — &lt;a href="https://www.lambdatest.com/blog/execute-junit4-tests-with-junit5/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How to execute JUnit 4 tests with JUnit 5&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even after setting the above property to true, test classes and test methods would still execute sequentially. SAME_THREAD and CONCURRENT are the two modes that let you control the sequence of test execution. As specified in the official JUnit 5 user documentation, SAME_THREAD (default execution mode) forces the execution in the same thread that the parent uses. On the other hand, CONCURRENT lets you execute concurrently unless a resource lock forces execution in the same thread.&lt;/p&gt;

&lt;p&gt;Here are the configuration parameters for executing all the JUnit 5 tests in parallel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   junit.jupiter.execution.parallel.enabled = true
    junit.jupiter.execution.parallel.mode.default = concurrent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the parallel execution property is set (or enabled), the JUnit Jupiter engine will run the tests in parallel as per the configurations provided with the synchronization mechanisms. In the further section of this JUnit 5 tutorial, we will deep dive into the practical implementation of JUnit 5 parallel test execution for Selenium automation testing.&lt;/p&gt;

&lt;p&gt;If you are a Java expert, you can gain recognition for your Java knowledge and help accelerate your career with this free JUnit certification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Facy0kugdwikisbhwd3vu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Facy0kugdwikisbhwd3vu.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This JUnit certification establishes testing standards for those who wish to advance their careers in Selenium automation testing with JUnit.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the JUnit certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fWsCwrtElAw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/black-box-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Black Box Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demonstration: JUnit 5 Parallel Test Execution for Selenium Automation Testing
&lt;/h2&gt;

&lt;p&gt;Let’s get our hands dirty for demonstrating parallel test execution with JUnit 5. First, we take a simple Java example that comprises two classes executed in parallel using the JUnit 5 framework.&lt;/p&gt;

&lt;p&gt;Let us look at a simple example of running the JUnit 5 tests in parallel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FileName — Test1.java

    package SimpleTest;

    import org.junit.jupiter.api.*;

    public class Test1 {

       @BeforeAll
       public static void start() {
           System.out.println("=======Starting junit 5 tests========");
       }

       @BeforeEach
       public void setup() {
           System.out.println("=======Setting up the prerequisites========");

       }
       @Test
       void test1_FirstTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }

       @Test
       void test1_SecondTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }

       @Test
       void test1_ThirdTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }
       @Test
       void test1_FourthTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }


       @AfterEach
       public void tearDown() {
           System.out.println("Tests ended");
       }

       @AfterAll
       public static void end() {
           System.out.println("All the tests are executed");

       }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  FileName — Test2.java
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  package SimpleTest;
    import org.junit.jupiter.api.*;

    public class Test2 {
       @BeforeAll
       public static void start() {
           System.out.println("=======Starting junit 5 tests========");
       }
       @BeforeEach
       public void setup() {
           System.out.println("=======Setting up the prerequisites========");
       }

       @Test
       void test2_FirstTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }
       @Test
       void test2_SecondTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }

       @Test
       void test2_ThirdTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }
       @Test
       void test2_FourthTest() {
           System.out.println(Thread.currentThread().getStackTrace()[1]
                   .getMethodName()+" =&amp;gt; executed successfully");
       }
       @AfterEach
       public void tearDown() {
           System.out.println("Tests ended");
       }
       @AfterAll
       public static void end() {
           System.out.println("All the tests are executed");
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  FileName — pom.xml
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
       &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

       &amp;lt;groupId&amp;gt;org.example&amp;lt;/groupId&amp;gt;
       &amp;lt;artifactId&amp;gt;ParallelTest&amp;lt;/artifactId&amp;gt;
       &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

       &amp;lt;properties&amp;gt;
           &amp;lt;maven.compiler.source&amp;gt;1.8&amp;lt;/maven.compiler.source&amp;gt;
           &amp;lt;maven.compiler.target&amp;gt;${maven.compiler.source}&amp;lt;/maven.compiler.target&amp;gt;
           &amp;lt;junit.jupiter.version&amp;gt;5.7.1&amp;lt;/junit.jupiter.version&amp;gt;
       &amp;lt;/properties&amp;gt;

       &amp;lt;dependencies&amp;gt;
           &amp;lt;dependency&amp;gt;
               &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
               &amp;lt;artifactId&amp;gt;junit-jupiter-engine&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;${junit.jupiter.version}&amp;lt;/version&amp;gt;
               &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
           &amp;lt;/dependency&amp;gt;
           &amp;lt;dependency&amp;gt;
               &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
               &amp;lt;artifactId&amp;gt;junit-jupiter-api&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;${junit.jupiter.version}&amp;lt;/version&amp;gt;
               &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
           &amp;lt;/dependency&amp;gt;
           &amp;lt;dependency&amp;gt;
               &amp;lt;groupId&amp;gt;org.seleniumhq.selenium&amp;lt;/groupId&amp;gt;
               &amp;lt;artifactId&amp;gt;selenium-java&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;3.141.59&amp;lt;/version&amp;gt;
           &amp;lt;/dependency&amp;gt;
           &amp;lt;dependency&amp;gt;
               &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
               &amp;lt;artifactId&amp;gt;junit-jupiter-params&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
               &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
           &amp;lt;/dependency&amp;gt;
       &amp;lt;/dependencies&amp;gt;
    &amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now how do we run JUnit 5 test cases in parallel? The JUnit 5 framework provides two distinct mechanisms through which you can run tests in parallel:&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 1: Add VM arguments under Run configuration
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Right-click on the folder which contains the tests that you intend to run in parallel. Click on &lt;strong&gt;Create Tests&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F712tprof9xaq8o4a6i74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F712tprof9xaq8o4a6i74.png" width="512" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; In the Create Run configuration, add the below arguments in VM options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    -Djunit.jupiter.execution.parallel.enabled=true
    -Djunit.jupiter.execution.parallel.mode.default=concurrent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvlz7t8n4b57i3346cxle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvlz7t8n4b57i3346cxle.png" width="512" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Click OK and run the Tests.&lt;/p&gt;

&lt;p&gt;From the execution output, it is evident that the JUnit 5 tests are running in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frztws0akyg7up3bk9c4u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frztws0akyg7up3bk9c4u.png" width="512" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0syfulxdzuomwvjwlm13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0syfulxdzuomwvjwlm13.png" width="512" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This JUnit Tutorial for beginners and professionals will help you learn how to performing parallel testing using JUnit framework and Selenium.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/IBWJCk2SHYk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 2: JUnit 5 parallel test execution using Maven
&lt;/h3&gt;

&lt;p&gt;In this particular method, parallel execution options are added in the pom.xml file. If you are new to Maven, you can have a quick look at the &lt;a href="https://www.lambdatest.com/blog/getting-started-with-maven-for-selenium-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven tutorial for Selenium&lt;/a&gt; that helps you get started with Maven for Eclipse IDE.&lt;/p&gt;

&lt;p&gt;For demonstration, we have used the earlier example where two tests in different Java files were executed in parallel. Follow the below mentioned steps to realize parallel execution in JUnit 5 using the said approach:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Set junit.jupiter.execution.parallel.enabled to true and junit.jupiter.execution.parallel.mode.default to concurrent in pom.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;build&amp;gt;
       &amp;lt;plugins&amp;gt;
           &amp;lt;plugin&amp;gt;
               &amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;2.22.1&amp;lt;/version&amp;gt;
               &amp;lt;configuration&amp;gt;
                   &amp;lt;properties&amp;gt;
                       &amp;lt;configurationParameters&amp;gt;
                           junit.jupiter.execution.parallel.enabled=true
                           junit.jupiter.execution.parallel.mode.default=concurrent
                       &amp;lt;/configurationParameters&amp;gt;
                   &amp;lt;/properties&amp;gt;
               &amp;lt;/configuration&amp;gt;
           &amp;lt;/plugin&amp;gt;
       &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Run the Maven command mvn clean test to run the tests from the command line. In case you are intrigued to know about command-line execution with Maven for JUnit, make sure to check out our detailed blog that demonstrates running &lt;a href="https://www.lambdatest.com/blog/run-junit-from-command-line/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit tests from the command line.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Shown below is the execution snapshot, which indicates that the test execution has been completed successfully:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhlohs037bi4d6id5unu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhlohs037bi4d6id5unu.png" width="512" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Till now, we have demonstrated parallel execution using JUnit 5 without any involvement of Selenium in it. In the further section of this JUnit 5 tutorial, we look at leveraging parallel test execution with JUnit 5 for expediting Selenium tests.&lt;/p&gt;

&lt;p&gt;If you are curious to learn more about the other essentials of the JUnit framework, head over to the detailed &lt;a href="https://www.lambdatest.com/learning-hub/junit-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;JUnit tutorial&lt;/a&gt; on LambdaTest learning hub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0rl0a6f0mi38zmevjywh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0rl0a6f0mi38zmevjywh.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/exploratory-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Exploratory Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to perform JUnit 5 parallel test execution using Selenium
&lt;/h2&gt;

&lt;p&gt;The true potential of parallel testing in Selenium can be exploited by shifting the tests from a local Selenium Grid to a &lt;a href="https://www.lambdatest.com/blog/cloud-testing-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cloud Selenium Grid&lt;/a&gt; like LambdaTest. You can check out our cloud testing tutorial to understand the major benefits offered by a cloud-based Grid.&lt;/p&gt;

&lt;p&gt;LambdaTest provides an excellent platform to run Selenium tests across 2,000+ browsers and operating systems, all in the cloud! Furthermore, since the code changes are majorly involved on the infrastructure front, it is easy to port an existing implementation that works on a local Selenium Grid to a cloud-based Selenium Grid.&lt;/p&gt;

&lt;p&gt;Once you have created an account on LambdaTest, make sure to note the username and access key that is available on the &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest profile&lt;/a&gt; page. Then, you can generate the desired capabilities for browser and platform combinations using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest capabilities generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Below is the code for running our Junit 5 tests on a cloud-based Selenium Grid like LambdaTest:&lt;/p&gt;

&lt;p&gt;FileName — RunningTestsInParallelInGrid.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  import org.openqa.selenium.By;
    import org.junit.jupiter.api.*;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.List;
    import java.util.concurrent.TimeUnit;
    public class RunningTestsInParallelInGrid {
      String username = "YOUR_USERNAME"; //Enter your username
      String accesskey = "YOUR_ACCESS_KEY"; //Enter your accesskey
      static RemoteWebDriver driver = null;
      String gridURL = "@hub.lambdatest.com/wd/hub";
      String urlToTest = "https://www.lambdatest.com/";
      @BeforeAll
      public static void start() {
          System.out.println("=======Running junit 5 tests in parallel in LambdaTest Grid has started========");
      }
      @BeforeEach
      public void setup() {
          System.out.println("Setting up the drivers and browsers");
          DesiredCapabilities capabilities = new DesiredCapabilities();
          capabilities.setCapability("browserName", "chrome");   //To specify the browser
          capabilities.setCapability("version", "70.0");    //To specify the browser version
          capabilities.setCapability("platform", "win10");      // To specify the OS
          capabilities.setCapability("build", "Running_ParallelJunit5Tests_In_Grid");               //To identify the test
          capabilities.setCapability("name", "Parallel_JUnit5Tests");
          capabilities.setCapability("network", true);      // To enable network logs
          capabilities.setCapability("visual", true);          // To enable step by step screenshot
          capabilities.setCapability("video", true);       // To enable video recording
          capabilities.setCapability("console", true);         // To capture console logs
          try {
              driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
          } catch (MalformedURLException e) {
              System.out.println("Invalid grid URL");
          } catch (Exception e) {
              System.out.println(e.getMessage());
          }
      }
      @Test
      @DisplayName("Title_Test")
      @Tag("Sanity")
      public void launchAndVerifyTitle_Test() {
          String methodName = Thread.currentThread()
                  .getStackTrace()[1]
                  .getMethodName();
          System.out.println("********Execution of "+methodName+" has been started********");
          System.out.println("Launching LambdaTest website started..");
          driver.get(urlToTest);
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          String actualTitle = driver.getTitle();
          System.out.println("The page title is "+actualTitle);
          String expectedTitle ="Most Powerful Cross Browser Testing Tool Online | LambdaTest";
          System.out.println("Verifying the title of the webpage started");
          Assertions.assertEquals(expectedTitle, actualTitle);
          System.out.println("The webpage has been launched and the title of the webpage has been veriified successfully");
          System.out.println("********Execution of "+methodName+" has ended********");
      }
      @Test
      @DisplayName("Login_Test")
      @Tag("Sanity")
      public void login_Test() {
          String methodName = Thread.currentThread()
                  .getStackTrace()[1]
                  .getMethodName();
          System.out.println("********Execution of "+methodName+" has been started********");
          System.out.println("Launching LambdaTest website started..");
          driver.get(urlToTest);
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          WebElement login = driver.findElement(By.xpath("//a[text()='Login']"));
          login.click();
          WebElement username = driver.findElement(By.xpath("//input[@name=\"email\"]"));
          WebElement password = driver.findElement(By.xpath("//input[@name=\"password\"]"));
          WebDriverWait wait = new WebDriverWait(driver,20);
          wait.until(ExpectedConditions.visibilityOf(username));
          username.clear();
          username.sendKeys("acvdd@gmail.com");
          password.clear();
          password.sendKeys("abc@123");
          WebElement loginButton = driver.findElement(By.xpath("//button[text()='Login']"));
          loginButton.click();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          String actual = driver.getTitle();
          String expected = "Welcome - LambdaTest";
          Assertions.assertEquals(expected, actual);
          System.out.println("The user has been successfully logged in");
          System.out.println("********Execution of "+methodName+" has ended********");
      }
      @Test
      @DisplayName("Logo_Test")
      public void logo_Test() {
          String methodName = Thread.currentThread()
                  .getStackTrace()[1]
                  .getMethodName();
          System.out.println("********Execution of "+methodName+" has been started********");
          System.out.println("Launching LambdaTest website started..");
          driver.get(urlToTest);
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          System.out.println("Verifying of webpage logo started..");
          WebElement logo = driver.findElement(By.xpath("//*[@id=\"header\"]/nav/div/div/div[1]/div/a/img"));
          boolean is_logo_present = logo.isDisplayed();
          if(is_logo_present) {
              System.out.println("The logo of LambdaTest is displayed");
          }
          else {
              Assertions.assertFalse(is_logo_present,"Logo is not present");
          }
          System.out.println("********Execution of "+methodName+" has ended********");
      }
      @Test
      @DisplayName("Blog_Test")
      public void blogPage_Test() {
          String methodName = Thread.currentThread()
                  .getStackTrace()[1]
                  .getMethodName();
          System.out.println("********Execution of "+methodName+" has been started********");
          System.out.println("Launching LambdaTest website started..");
          driver.get(urlToTest);
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          WebElement resources = driver.findElement(By.xpath("//*[text()='Resources ']"));
          List&amp;lt;WebElement&amp;gt; options_under_resources = driver.findElements(By.xpath("//*[text()='Resources ']/../ul/a"));
          boolean flag = resources.isDisplayed();
          if(flag) {
              System.out.println("Resources header is visible in the webpage");
              Actions action = new Actions(driver);
              action.moveToElement(resources).build().perform();
              WebDriverWait wait=new WebDriverWait(driver, 20);
              wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources));
              for(WebElement element : options_under_resources) {
                  if(element.getText().equals("Blog")){
                      System.out.println("Clicking Blog option has started");
                      element.click();
                      System.out.println("Clicking Blog option has ended");
                      driver.manage().timeouts().pageLoadTimeout(20,TimeUnit.SECONDS);
                      Assertions.assertEquals("LambdaTest Blogs", driver.getTitle());
                      break;
                  }
                  else
                      Assertions.fail("Blogs option is not available");
              }
          }
          else {
              Assertions.fail("Resources header is not visible");
          }
          System.out.println("********Execution of "+methodName+" has ended********");
      }
      @Test
      @DisplayName("Cerification_Test")
      public void certificationPage_Test() {
          String methodName = Thread.currentThread()
                  .getStackTrace()[1]
                  .getMethodName();
          System.out.println("********Execution of "+methodName+" has been started********");
          System.out.println("Launching LambdaTest website started..");
          driver.get(urlToTest);
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          WebElement resources = driver.findElement(By.xpath("//*[text()='Resources ']"));
          List&amp;lt;WebElement&amp;gt; options_under_resources = driver.findElements(By.xpath("//*[text()='Resources ']/../ul/a"));
          boolean flag = resources.isDisplayed();
          if(flag) {
              System.out.println("Resources header is visible in the webpage");
              Actions action = new Actions(driver);
              action.moveToElement(resources).build().perform();
              WebDriverWait wait = new WebDriverWait(driver, 20);
              wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources));
              for (int i = 0; i &amp;lt; options_under_resources.size(); i++) {
                  String value = options_under_resources.get(i).getText();
                  if (value.equals("Certifications")) {
                      System.out.println("Clicking Certifications option has started");
                      action.moveToElement(options_under_resources.get(i)).build().perform();
                      options_under_resources.get(i).click();
                      System.out.println("Clicking Certifications option has ended");
                      driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
                      String expectedCertificationPageTitle = "LambdaTest Selenium Certifications - Best Certifications For Automation Testing Professionals";
                      String actualCertificationPageTitle = driver.getTitle();
                      Assertions.assertEquals(expectedCertificationPageTitle, actualCertificationPageTitle);
                      break;
                  }
              }
          }
          System.out.println("********Execution of "+methodName+" has ended********");
      }
      @Test
      @DisplayName("Support_Test")
      public void supportPage_Test() {
          String methodName = Thread.currentThread()
                  .getStackTrace()[1]
                  .getMethodName();
          System.out.println("********Execution of "+methodName+" has been started********");
          System.out.println("Launching LambdaTest website started..");
          driver.get(urlToTest);
          driver.manage().window().maximize();
          driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
          WebElement supportHeader = driver.findElement(By.xpath("(//div//*[text()='Support'])[1]"));
          boolean flag = supportHeader.isDisplayed();
          if(flag) {
              System.out.println("support header is visible in the webpage");
              supportHeader.click();
          }
          else {
              Assertions.fail("support header is not visible");
          }
          System.out.println("********Execution of "+methodName+" has ended********");
      }
      @AfterEach
      public void tearDown() {
          System.out.println("Quitting the browsers has started");
          driver.quit();
          System.out.println("Quitting the browsers has ended");
      }
      @AfterAll
      public static void end() {
          System.out.println("Tests ended");
      }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As mentioned earlier, JUnit 5 parallel execution test execution can be achieved by adding the arguments in VM options in Run configuration or running through Maven by adding the plugin in the pom.xml file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rather than doing a detailed code walkthrough, we would touch upon the important aspects of the source code.&lt;/p&gt;

&lt;p&gt;To get started, we create a Remote WebDriver instance using the browser and platform capabilities added in the setup() method. Then, as seen below, a pair of username and access key is used to access the LambdaTest Grid.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   driver = new RemoteWebDriver(new URL(“https://” + username + “:” + accesskey + gridURL), capabilities);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The class comprises 6 test methods, with each test method using relevant &lt;a href="https://www.lambdatest.com/blog/locators-in-selenium-webdriver-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;locators in Selenium&lt;/a&gt; to locate the relevant WebElements. For example, in the test method login_Test(), the XPath Selenium locator is used to locate the page’s email and password elements. In case you need a quick recap of XPath, make sure to check out our detailed guide for using &lt;a href="https://www.lambdatest.com/blog/complete-guide-for-using-xpath-in-selenium-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;XPath locators in Selenium.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   WebElement username = driver.findElement(By.xpath("//input[@name=\"email\"]"));
    WebElement password = driver.findElement(By.xpath("//input[@name=\"password\"]"));     

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When running the test, there is a possibility that dynamically loaded content (or WebElement) might not be present on the page. Interacting with an Element that is not yet a part of the DOM could lead to exceptions. Since handling dynamic content is one of the major &lt;a href="https://www.lambdatest.com/blog/common-challenges-in-selenium-automation-how-to-fix-them/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation challenges&lt;/a&gt;, it needs to be addressed by adding appropriate delay(s) to make the relevant WebElement available for access in the DOM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/expected-conditions-in-selenium-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Expected conditions in Selenium WebDriver&lt;/a&gt; are used at appropriate places in the implementation for ensuring that the WebElements being interacted with are visible, interactable, etc. For example, in the test method blogPage_Test(), a wait is performed on the expected condition visibilityOfAllElements. Then, if the corresponding elements are visible, appropriate actions are performed on those elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit asserts with Selenium&lt;/a&gt; are used in all the test methods to assert wherever failures are encountered during the process of Selenium automation testing. Some of the same asserts from a few test methods are mentioned below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Assertions.assertEquals(expectedCertificationPageTitle, actualCertificationPageTitle);
    Assertions.assertFalse(is_logo_present,"Logo is not present");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shown below is the execution snapshot, which indicates that the tests are executing in parallel:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4cce99qq0cxk123d8nc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4cce99qq0cxk123d8nc.png" width="494" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As seen below, we can see that the test execution has been completed successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwry9ed49u3bexek19w0v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwry9ed49u3bexek19w0v.png" width="512" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To check the test execution status, navigate to the &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest automation dashboard&lt;/a&gt;, where you can even check the video of the test execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7v1ft5xb8tem4uw478jh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7v1ft5xb8tem4uw478jh.png" width="512" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;UI Testing&lt;/a&gt; Tutorial: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to perform JUnit 5 parallel test execution using parameterization in Selenium
&lt;/h2&gt;

&lt;p&gt;In the earlier section, we executed six different tests on a single browser and platform combination. However, the approach can falter if tests have to be performed on ’N’ different test combinations.&lt;/p&gt;

&lt;p&gt;This is where &lt;a href="https://www.lambdatest.com/blog/junit-parameterized-test-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parameterized test with JUnit in Selenium&lt;/a&gt; can be super effective as the relevant test combinations can be passed as parameters to parameterized test methods. Like its predecessor, JUnit 5 also provides flexibility to leverage parameterization in Selenium to reduce LOC (Lines of Code) and achieve better test coverage with lesser code.&lt;/p&gt;

&lt;p&gt;Add the following dependency in pom.xml so that you can parameterize tests using the JUnit 5 framework:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;dependency&amp;gt;
       &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
       &amp;lt;artifactId&amp;gt;junit-jupiter-params&amp;lt;/artifactId&amp;gt;
       &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
       &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
    &amp;lt;/dependency&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For demonstration, we would be performing tests on Chrome and Firefox browsers on the LambdaTest Selenium Grid. The browser and platform combinations are generated using the LambdaTest capabilities generator.&lt;/p&gt;

&lt;p&gt;FileName — crossBrowserTests.java&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package crossBrowserTests;

    import org.junit.jupiter.api.*;
    import org.junit.jupiter.params.ParameterizedTest;
    import org.junit.jupiter.params.provider.Arguments;
    import org.junit.jupiter.params.provider.MethodSource;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;
    import java.util.stream.Stream;

    import static org.junit.jupiter.params.provider.Arguments.arguments;

    public class crossBrowserTest {

       String username = "user_name"; //Enter your username
       String accesskey = "access_key"; //Enter your accesskey

       static RemoteWebDriver driver = null;
       String gridURL = "@hub.lambdatest.com/wd/hub";
       String urlToTest = "https://www.lambdatest.com/";

       @BeforeAll
       public static void start() {
           System.out.println("=======Starting junit 5 tests in LambdaTest Grid========");
       }

       @BeforeEach
       public void setup(){
           System.out.println("=======Setting up drivers and browser========");
       }

       public void browser_setup(String browser) {
           System.out.println("Setting up the drivers and browsers");
           DesiredCapabilities capabilities = new DesiredCapabilities();

           if(browser.equalsIgnoreCase("Chrome")) {
               capabilities.setCapability("browserName", "chrome");    //To specify the browser
               capabilities.setCapability("version", "70.0");        //To specify the browser version
               capabilities.setCapability("platform", "win10");        // To specify the OS
               capabilities.setCapability("build", "Running_Junit5Tests_In_Grid_Chrome");               //To identify the test
               capabilities.setCapability("name", "JUnit5Tests_Chrome");
               capabilities.setCapability("network", true);        // To enable network logs
               capabilities.setCapability("visual", true);            // To enable step by step screenshot
               capabilities.setCapability("video", true);            // To enable video recording
               capabilities.setCapability("console", true);            // To capture console logs
           }
           if(browser.equalsIgnoreCase("Firefox")) {
               capabilities.setCapability("browserName", "Firefox");  //To specify the browser
               capabilities.setCapability("version", "76.0");    //To specify the browser version
               capabilities.setCapability("platform", "win10");   // To specify the OS
               capabilities.setCapability("build", "Running_Junit5Tests_In_Grid_Firefox");    //To identify the test
               capabilities.setCapability("name", "JUnit5Tests_Firefox");
               capabilities.setCapability("network", true);      // To enable network logs
               capabilities.setCapability("visual", true);       // To enable step by step screenshot
               capabilities.setCapability("video", true);        // To enable video recording
               capabilities.setCapability("console", true);      // To capture console logs

           }
           try {
               driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
           } catch (MalformedURLException e) {
               System.out.println("Invalid grid URL");
           } catch (Exception e) {
               System.out.println(e.getMessage());
           }

       }

       @ParameterizedTest
       @MethodSource("browser")
       public void launchAndVerifyTitle_Test(String browser) {
           browser_setup(browser);
           String methodName = Thread.currentThread()
                   .getStackTrace()[1]
                   .getMethodName();
           System.out.println("********Execution of "+methodName+" has been started********");
           System.out.println("Launching LambdaTest website started..");
           driver.get(urlToTest);
           driver.manage().window().maximize();
           driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
           String actualTitle = driver.getTitle();
           System.out.println("The page title is "+actualTitle);
           String expectedTitle ="Most Powerful Cross Browser Testing Tool Online | LambdaTest";
           System.out.println("Verifying the title of the webpage started");
           Assertions.assertEquals(expectedTitle, actualTitle);
           System.out.println("The webpage has been launched and the title of the webpage has been veriified successfully");
           System.out.println("********Execution of "+methodName+" has ended********");
       }

       @ParameterizedTest
       @MethodSource("browser")
       public void login_Test(String browser) {
           browser_setup(browser);

           String methodName = Thread.currentThread()
                   .getStackTrace()[1]
                   .getMethodName();
           System.out.println("********Execution of "+methodName+" has been started********");
           System.out.println("Launching LambdaTest website started..");
           driver.get(urlToTest);
           driver.manage().window().maximize();
           driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
           WebElement login = driver.findElement(By.xpath("//a[text()='Login']"));
           login.click();
           WebElement username = driver.findElement(By.xpath("//input[@name='email']"));
           WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
           WebDriverWait wait = new WebDriverWait(driver,20);
           wait.until(ExpectedConditions.visibilityOf(username));
           username.clear();
           username.sendKeys("abcwdwd@gmail.com");
           password.clear();
           password.sendKeys("abc@123");
           WebElement loginButton = driver.findElement(By.xpath("//button[text()='Login']"));
           loginButton.click();
           driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
           String actual = driver.getTitle();
           String expected = "Welcome - LambdaTest";
           Assertions.assertEquals(expected, actual);
           System.out.println("The user has been successfully logged in");
           System.out.println("********Execution of "+methodName+" has ended********");
       }

       @ParameterizedTest
       @MethodSource("browser")
       public void logo_Test(String browser) {
           browser_setup(browser);
           String methodName = Thread.currentThread()
                   .getStackTrace()[1]
                   .getMethodName();
           System.out.println("********Execution of "+methodName+" has been started********");
           System.out.println("Launching LambdaTest website started..");
           driver.get(urlToTest);
           driver.manage().window().maximize();
           driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
           System.out.println("Verifying of webpage logo started..");

           WebElement logo = driver.findElement(By.xpath("//*[@id=\"header\"]/nav/div/div/div[1]/div/a/img"));
           boolean is_logo_present = logo.isDisplayed();
           if(is_logo_present) {
               System.out.println("The logo of LambdaTest is displayed");
           }
           else {
               Assertions.assertFalse(is_logo_present,"Logo is not present");
           }
           System.out.println("********Execution of "+methodName+" has ended********");
       }

       @AfterEach
       public void tearDown() {
           System.out.println("Quitting the browsers has started");
           driver.quit();
           System.out.println("Quitting the browsers has ended");
       }

       @AfterAll
       public static void end() {
           System.out.println("Tests ended");
       }

       static Stream&amp;lt;Arguments&amp;gt; browser() {
           return Stream.of(
                   arguments("Chrome"),
                   arguments("Firefox")
           );
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since we are using parameterization in JUnit 5, the necessary package is imported at the beginning of the implementation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; import org.junit.jupiter.params.ParameterizedTest;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The org.junit.jupiter.params.provider package is also imported since the stream of physical arguments would be used as input to the annotated @ParameterizedTest method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    import static org.junit.jupiter.params.provider.Arguments.arguments;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The stream of Browser arguments is defined in the manner shown below. Each test method uses ‘browser’ as the input argument against which the test methods are run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    static Stream&amp;lt;Arguments&amp;gt; browser() {
           return Stream.of(
                   arguments("Chrome"),
                   arguments("Firefox")
           );
       }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each test method calls the browser_setup() method, where the relevant browser and platform capabilities are set depending on the corresponding test combination. For example, remote Chrome Driver is instantiated if the parameter (i.e., browser) is set to Chrome. The same principle also applies to the Firefox browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public void browser_setup(String browser) {
           System.out.println("Setting up the drivers and browsers");
           DesiredCapabilities capabilities = new DesiredCapabilities();

           if(browser.equalsIgnoreCase("Chrome")) {
         .............................................
               .............................................
               .............................................
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since each test method is a parameterized one, it is defined under the @ParameterizedTest annotation. Similarly, the @MethodSource annotation is used to access the values returned from the factory methods of the class under which the annotation is declared.&lt;/p&gt;

&lt;p&gt;As seen below, @MethodSource provides access to the value “browser” that is a stream of arguments (i.e. Stream&amp;lt; Arguments &amp;gt;). Hence, three test methods [i.e. launchAndVerifyTitle_Test(), login_Test(), and logo_Test()] would be run across two browser (i.e. Chrome and Firefox) combinations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  @ParameterizedTest
       @MethodSource("browser")
       public void launchAndVerifyTitle_Test(String browser) {
           browser_setup(browser);
           String methodName = Thread.currentThread()
                   .getStackTrace()[1]
                   .getMethodName();
           ...................................
           ...................................
           ...................................

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hence, you should see six test scenarios executing in parallel on the LambdaTest Selenium Grid. Apart from these code modifications, the rest of the implementation logic remains the same, as mentioned earlier.&lt;/p&gt;

&lt;p&gt;The tearDown() method defined under the @AfterEach annotation is executed after each test run so that the subsequent tests are run on a fresh browser and OS combination.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  @AfterEach
    public void tearDown() {
           System.out.println("Quitting the browsers has started");
           driver.quit();
           System.out.println("Quitting the browsers has ended");
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method defined under @AfterAll annotation is run only after all the tests have completed execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   @AfterAll
    public static void end() {
       System.out.println("Tests ended");
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shown below is the execution snapshot, which indicates that parallel test execution using JUnit 5 was carried out on Chrome and Firefox browsers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4usd95adtqp5jeanygcl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4usd95adtqp5jeanygcl.png" width="512" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Shown below is the snapshot of the LambdaTest automation dashboard, which indicates that three test methods were run against two different browser combinations (i.e., Chrome and Firefox). The build title being shown in the dashboard was set when setting the desired browser capabilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   apabilities.setCapability("build", "Running_Junit5Tests_In_Grid_Chrome");              
     //To identify the test
    capabilities.setCapability("name", "JUnit5Tests_Chrome");

    .............................................
    .............................................
    .............................................
    capabilities.setCapability("build", "Running_Junit5Tests_In_Grid_Firefox");   
     //To identify the test
    capabilities.setCapability("name", "JUnit5Tests_Firefox");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fapkertxvrtzu76hghadz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fapkertxvrtzu76hghadz.png" width="512" height="123"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The IntelliJ execution console shows that the three tests were executed successfully against two different browser combinations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy3a8d5wruuugf2izrgpu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy3a8d5wruuugf2izrgpu.png" width="512" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/learning-hub/ad-hoc-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb28_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Ad Hoc Testing&lt;/a&gt;: A Comprehensive Guide With Examples and Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fob57ai0gtvpepfzebxpv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fob57ai0gtvpepfzebxpv.gif" width="435" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this JUnit 5 tutorial, we have seen how to perform parallel test execution with the JUnit 5 framework using different ways. To carry out our tests, we have also leveraged the LambdaTest cloud grid, which supports 3000+ browsers and various platforms. I hope you find this article helpful in understanding the parallel test execution using JUnit 5. I would love to hear your comments on this.&lt;/p&gt;

&lt;p&gt;Keep exploring ..!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foicmqzodvtqf8kyot7n6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foicmqzodvtqf8kyot7n6.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>How To Run JUnit Tests In Jupiter? [JUnit Jupiter Tutorial]</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Mon, 27 Feb 2023 07:48:27 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-run-junit-tests-in-jupiter-junit-jupiter-tutorial-3p3m</link>
      <guid>https://forem.com/testmuai/how-to-run-junit-tests-in-jupiter-junit-jupiter-tutorial-3p3m</guid>
      <description>&lt;p&gt;JUnit Jupiter is a perfect blend of the JUnit 5 programming model and extension model for writing tests and extensions. The Jupiter sub-project provides a TestEngine for running Jupiter-based tests on the platform. It also defines the TestEngine API for developing new testing frameworks that run on the platform.&lt;/p&gt;

&lt;p&gt;The Jupiter programming model is derived from &lt;a href="https://www.lambdatest.com/blog/tutorial-on-junit-annotations-in-selenium-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JUnit 4’s annotations&lt;/a&gt; and assumptions about how you structure your test code. So, if you are familiar with JUnit 4, then it will be pretty simple to grasp Jupiter concepts.&lt;/p&gt;

&lt;p&gt;With this article on JUnit Jupiter, let’s explore the basic usage of Jupiter, its unit testing capabilities, and how you can run JUnit tests in Jupiter.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is JUnit?
&lt;/h2&gt;

&lt;p&gt;JUnit is one of the most powerful &lt;a href="https://www.lambdatest.com/blog/11-best-unit-testing-frameworks-for-selenium-automation/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;unit testing frameworks&lt;/a&gt; that has been widely used for carrying out unit tests. JUnit 5 is the latest version of JUnit consisting of three different sub-components, namely JUnit Platform, JUnit Jupiter, and JUnit Vintage. JUnit 5 requires Java version 8 or any other higher version, which makes it stand out from its previous versions. But surprisingly, the unit tests written in JUnit4 or previous versions can still be compiled and tested with JUnit 5. Now let us understand the three sub-components of JUnit 5.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also Read&lt;/strong&gt; — &lt;a href="https://www.lambdatest.com/blog/execute-junit4-tests-with-junit5/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How to execute JUnit 4 tests with JUnit 5 [Tutorial]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58yb0hwv5gaqmib3vpm9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F58yb0hwv5gaqmib3vpm9.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  JUnit 5 — The next generation testing framework
&lt;/h2&gt;

&lt;p&gt;JUnit 5 is the latest, modular and highly extensible version of JUnit. The JUnit platform is the basic foundation of the testing framework, which helps in framework development. The JUnit framework is made up of three modules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JUnit Platform&lt;/strong&gt; provides a clean and functional API for managing, executing, and reporting the results of tests. Tools built with the JUnit Platform can rely on the JUnit tooling ecosystem to discover, run, report, and diagnose test execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JUnit Jupiter&lt;/strong&gt; is used for writing the tests and the Jupiter sub-project provides a TestEngine for running Jupiter-based tests on the platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JUnit Vintage&lt;/strong&gt; is used for running earlier versions of JUnit tests such as JUnit 3 and JUnit 4 based tests.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5hqe7udidyc0lwnoptam.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5hqe7udidyc0lwnoptam.png" width="658" height="623"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;JUnit 5 Architecture&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Find bugs early on, improve performance, quality, user experience and make the most of &lt;a href="https://www.lambdatest.com/mobile-app-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile app test&lt;/a&gt; on LambdaTest.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Annotations used in JUnit 5
&lt;/h2&gt;

&lt;p&gt;JUnit annotations are required while performing &lt;a href="https://www.lambdatest.com/blog/automated-testing-with-junit-and-selenium-for-browser-compatibility/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation testing with JUnit&lt;/a&gt;. So, basically, annotations are the meta-tags that provide additional information about the methods and classes defined in our code structure. Below are some of the annotations that are used in JUnit 5.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;&lt;/strong&gt; — This annotation is used for declaring a test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@TestFactory&lt;/strong&gt; — This annotation is used for defining a method which is a test factory for dynamic tests which are generated at the runtime&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@RepeatedTest&lt;/strong&gt; — This annotation is used to specify that the method is a template for the tests that can be repeated a specific number of times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@ParameterizedTest&lt;/strong&gt; — This annotation is used to indicate that the method is a parameterized test. These parameterized tests are similar to normal test methods, but we have to specify a source to provide parameters for each invocation used in the test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;@TestMethodOrder *&lt;/em&gt;— This annotation is used to define the order of the test execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@DisplayName&lt;/strong&gt; — This annotation is used to specify a customized display name for the method or class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@Tag&lt;/strong&gt; — This annotation is used for filtering the tests at the method or class level by defining the tags.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@Disabled&lt;/strong&gt; — This annotation is used to disable a test method or class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@BeforeEach&lt;/strong&gt; — This annotation is used to specify that the specific test method has to be executed before each &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@AfterEach&lt;/strong&gt; — This annotation is used to specify that the specific test method has to be executed after each &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@BeforeAll&lt;/strong&gt; — This annotation is used to specify that the specific test method has to be executed before all &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;@AfterAll&lt;/strong&gt; — This annotation is used to specify that the specific test method has to be executed after all &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory method.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To understand the difference between JUnit 5 and JUnit 4, please refer to our article on &lt;a href="https://www.lambdatest.com/blog/execute-junit4-tests-with-junit5/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;executing JUnit 4 test with JUnit 5&lt;/a&gt;. Now let us see how to create simple test cases in JUnit 5 and run them using Jupiter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycym01fr3vz1zhffzl15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycym01fr3vz1zhffzl15.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest offers free JUnit certification for Java developers that can be helpful to accelerate your career in Java development and testing.&lt;/p&gt;

&lt;p&gt;Here’s a glimpse of the JUnit Certification offered by LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fWsCwrtElAw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Run your &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation&lt;/a&gt; Testing scripts on the LambdatTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments. Try it for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing simple JUnit 5 test cases using Jupiter
&lt;/h2&gt;

&lt;p&gt;Prior to writing the test cases, let us quickly understand the scenarios and steps to automate the tests. We will be using the &lt;a href="https://www.lambdatest.com" rel="noopener noreferrer"&gt;https://www.lambdatest.com&lt;/a&gt; website for writing our test cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1:&lt;/strong&gt; Launch LambdaTest website and verify the tabs on the main page:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://www.lambdatest.com" rel="noopener noreferrer"&gt;https://www.lambdatest.com&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the tabs like Automation, Pricing, Resources, etc., are displayed on the main page or not.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2:&lt;/strong&gt; Login into the LambdaTest website and verify whether the user could successfully navigate to the LT Browser page:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://www.lambdatest.com" rel="noopener noreferrer"&gt;https://www.lambdatest.com&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the valid credentials.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upon successful login, verify if the user is able to navigate to the LT Browser page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Scenario 3:&lt;/strong&gt; Verify if the user is able to navigate to his profile page&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://www.lambdatest.com" rel="noopener noreferrer"&gt;https://www.lambdatest.com&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Login to the website using valid credentials.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify if the user is able to navigate to his profile.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Scenario 4:&lt;/strong&gt; Verify the list of options available under the Resources tab:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://www.lambdatest.com" rel="noopener noreferrer"&gt;https://www.lambdatest.com&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under the Resources tab, verify if the list of options is displayed or not.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To write and run your JUnit 5 tests cases using Jupiter, make sure that you have added the below dependencies in the pom.xml file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pom.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
        &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

        &amp;lt;groupId&amp;gt;org.example&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;Demo&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

        &amp;lt;properties&amp;gt;
            &amp;lt;maven.compiler.source&amp;gt;1.8&amp;lt;/maven.compiler.source&amp;gt;
            &amp;lt;maven.compiler.target&amp;gt;${maven.compiler.source}&amp;lt;/maven.compiler.target&amp;gt;
            &amp;lt;junit.jupiter.version&amp;gt;5.7.1&amp;lt;/junit.jupiter.version&amp;gt;
        &amp;lt;/properties&amp;gt;

        &amp;lt;dependencies&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;junit-jupiter-engine&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${junit.jupiter.version}&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;junit-jupiter-api&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${junit.jupiter.version}&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;

            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.seleniumhq.selenium&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;selenium-java&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;3.141.59&amp;lt;/version&amp;gt;
            &amp;lt;/dependency&amp;gt;
        &amp;lt;/dependencies&amp;gt;
    &amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the automation test script covering all the above-mentioned scenarios.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package demo;

    import org.junit.jupiter.api.*;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.concurrent.TimeUnit;

    @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
    public class demoTests {

        WebDriver driver;
        String urlToTest ="https://www.lambdatest.com/";

        @BeforeAll
        public static void start() {
            System.out.println("=======Starting junit 5 tests========");
        }

        @BeforeEach
        public void setup() {
            System.out.println("Setting up the drivers");
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver_latest94\\chromedriver.exe");
            driver = new ChromeDriver();
        }

     /*To test the tabs available in the main page like Resources,Documentation,login etc */
      @Test
        @DisplayName("HeaderTabs_Test")
        @Tag("Smoke")
        @Order(1)
        public void headers_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

            List&amp;lt;WebElement&amp;gt; elements = driver.findElements(By.xpath("//*[contains(@class,'md:text-right')]/a"));
            List&amp;lt;String&amp;gt; actualList = new ArrayList&amp;lt;&amp;gt;();
            for(WebElement ele :elements){
                actualList.add(ele.getText());
            }

            System.out.println("Actual elements : "+actualList);
            List&amp;lt;String&amp;gt; expectedList = Arrays.asList("Live","Automation","Pricing","Documentation","Login","Start Free Testing");
            System.out.println("Expected elements : "+expectedList);

            boolean boolval = actualList.equals(expectedList);
            System.out.println(boolval);
            Assertions.assertTrue(boolval);
            System.out.println("********Execution of "+methodName+" has ended********");
        }


        @Test
        @DisplayName("LTBrowser_Test")
        @Tag("Smoke")
        @Order(2)
        public void click_LTBrowser_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//a[text()='Login']")).click();
            driver.findElement(By.xpath("//input[@name=\"email\"]")).sendKeys("successismine514@gmail.com");
            driver.findElement(By.xpath("//input[@name=\"password\"]")).sendKeys("Google@123");
            driver.findElement(By.xpath("//button[text()='Login']")).click();
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

            List &amp;lt;WebElement&amp;gt; options = driver.findElements(By.xpath("//div[contains(@class,'aside__menu__item')]//a"));
            for(WebElement ele : options){
                if(ele.getText().equals("LT Browser")) {
                    ele.click();
                    break;
                }

            }
            driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
            String actualText = driver.findElement(By.xpath("//*[@class='lt__demo__box__title']")).getText();
            String expectedText = "LT Browser- Desktop App for Fast and Easy Mobile View Testing";
            Assertions.assertEquals(expectedText, actualText);
            System.out.println("The user has been successfully navigated to LT browser page");
            System.out.println("********Execution of "+methodName+" has ended********");
        }



        @Test()
        @DisplayName("editProfile_Test")
        @Order(3)
        public void editProfile_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//a[text()='Login']")).click();
            driver.findElement(By.xpath("//input[@name=\"email\"]")).sendKeys("successismine514@gmail.com");
            driver.findElement(By.xpath("//input[@name=\"password\"]")).sendKeys("Google@123");
            driver.findElement(By.xpath("//button[text()='Login']")).click();
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

            driver.findElement(By.id("profile__dropdown")).click();

            driver.findElement(By.xpath("//*[@class='profile__dropdown__item']")).click();

            String actualTitle = driver.getTitle();
            Assertions.assertEquals(actualTitle,"Profile - LambdaTest");
            System.out.println("********Execution of "+methodName+" has ended********");
        }

        @Test
        @DisplayName("ResourcesOption_Test")
        @Order(4)
        public void getListOfOptionsUnderResourcesTab() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            WebElement resources = driver.findElement(By.xpath("//*[text()='Resources ']"));
            List&amp;lt;WebElement&amp;gt; options_under_resources = driver.findElements(By.xpath("//*[text()='Resources ']/../ul/a"));
            boolean flag = resources.isDisplayed();
            if(flag) {
                System.out.println("Resources header is visible in the webpage");
                Actions action = new Actions(driver);
                action.moveToElement(resources).build().perform();
                WebDriverWait wait=new WebDriverWait(driver, 20);
                wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources));
                List&amp;lt;String&amp;gt; options = new ArrayList&amp;lt;&amp;gt;();
                for(WebElement element : options_under_resources) {
                    options.add(element.getText());
                }
                System.out.println(options);
                List&amp;lt;String&amp;gt; list = Arrays.asList("Blog", "Certifications", "Learning Hub", "Webinars", "Videos", "Newsletter", "Community", "Case Studies", "Product Updates");
                boolean boolval = list.equals(options);
                System.out.println(boolval);
                Assertions.assertTrue(boolval);
            }
            else {
                Assertions.fail("Resources header is not visible");
            }
            System.out.println("********Execution of "+methodName+" has ended********");
        }


        @AfterEach
        public void tearDown() {
            System.out.println("Quitting the browsers has started");
            driver.quit();
            System.out.println("Quitting the browsers has ended");

        }

        @AfterAll
        public static void end() {
            System.out.println("Tests ended");

        }

    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above script, you could have noticed some JUnit 5 annotations. Let us understand them one by one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;@DisplayName — This annotation is used to specify a customized display name for the method or class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@Tag — This annotation is used for filtering the tests at the method or class level by defining the tags.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@Order — This annotation is used for providing the sequence or order in which the tests have to be executed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To execute the JUnit Tests, right-click on the class and click Run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Console Output:
&lt;/h2&gt;

&lt;p&gt;The test cases would be run in the respective order that has been provided.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8a4kkz0v8iat2xrmz9yp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8a4kkz0v8iat2xrmz9yp.png" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Run your &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Automation Testing&lt;/a&gt; scripts on the LambdatTest cloud grid. Test on 3000+ desktop &amp;amp; mobile environments. Try it for free!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running JUnit 5 tests with specific tags
&lt;/h2&gt;

&lt;p&gt;In our test script, we have used tags for grouping the test cases. For example, during the process of testing, there would be a need to run only smoke or sanity cases. In such cases, we can group the tests using tags and execute them. To run the test cases specific to a tag,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Right-click on your test class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Edit ‘your test class name.’&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Edit Run Configuration dialog box, select Test Kind as Tags and enter the tag value in the Tag expression field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now Run your tests.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft07hdo84lu638vqkyr12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft07hdo84lu638vqkyr12.png" width="800" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Console Output:
&lt;/h2&gt;

&lt;p&gt;In the console, you could see the execution of the tests specific to the tags.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgq4budy5v65ly6gegxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgq4budy5v65ly6gegxj.png" width="651" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also read&lt;/strong&gt; — &lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Mastering Selenium Testing: JUnit Asserts With Examples&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing JUnit 5 tests with composed annotation
&lt;/h2&gt;

&lt;p&gt;Annotations in JUnit Jupiter can be used as meta-annotations. This allows you to create a custom composed annotation that will automatically inherit the semantics of its meta-annotations. For example, you can use &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; and @Tag(“Smoke”) annotations as meta-annotations and create a composed annotation named @SmokeTest which can be used as a replacement for the other two annotations on tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package demo;

    import org.junit.jupiter.api.*;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    import java.lang.annotation.ElementType;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.concurrent.TimeUnit;

    public class RunningMetaAnnotations {

        @Target({ ElementType.TYPE, ElementType.METHOD })
        @Retention(RetentionPolicy.RUNTIME)
        @Tag("Smoke")
        @Test
        public @interface SmokeTest {
        }

        WebDriver driver;
        String urlToTest ="https://www.lambdatest.com/";

        @BeforeAll
        public static void start() {
            System.out.println("=======Starting junit 5 tests========");
        }

        @BeforeEach
        public void setup() {
            System.out.println("Setting up the drivers");
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver_latest94\\chromedriver.exe");
            driver = new ChromeDriver();
        }

        @SmokeTest
        @DisplayName("HeaderTabs_Test")
        public void headers_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

            List&amp;lt;WebElement&amp;gt; elements = driver.findElements(By.xpath("//*[contains(@class,'md:text-right')]/a"));
            List&amp;lt;String&amp;gt; actualList = new ArrayList&amp;lt;&amp;gt;();
            for(WebElement ele :elements){
                actualList.add(ele.getText());
            }

            System.out.println("Actual elements : "+actualList);
            List&amp;lt;String&amp;gt; expectedList = Arrays.asList("Live","Automation","Pricing","Documentation","Login","Start Free Testing");
            System.out.println("Expected elements : "+expectedList);

            boolean boolval = actualList.equals(expectedList);
            System.out.println(boolval);
            Assertions.assertTrue(boolval);
            System.out.println("********Execution of "+methodName+" has ended********");
        }

        @SmokeTest
        @DisplayName("LTBrowser_Test")
        public void click_LTBrowser_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//a[text()='Login']")).click();
            driver.findElement(By.xpath("//input[@name=\"email\"]")).sendKeys("successismine514@gmail.com");
            driver.findElement(By.xpath("//input[@name=\"password\"]")).sendKeys("Google@123");
            driver.findElement(By.xpath("//button[text()='Login']")).click();
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

            List &amp;lt;WebElement&amp;gt; options = driver.findElements(By.xpath("//div[contains(@class,'aside__menu__item')]//a"));
            for(WebElement ele : options){
                if(ele.getText().equals("LT Browser")) {
                    ele.click();
                    break;
                }

            }
            driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
            String actualText = driver.findElement(By.xpath("//*[@class='lt__demo__box__title']")).getText();
            String expectedText = "LT Browser- Desktop App for Fast and Easy Mobile View Testing";
            Assertions.assertEquals(expectedText, actualText);
            System.out.println("The user has been successfully navigated to LT browser page");
            System.out.println("********Execution of "+methodName+" has ended********");
        }


        @SmokeTest
        @DisplayName("editProfile_Test")
        public void editProfile_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//a[text()='Login']")).click();
            driver.findElement(By.xpath("//input[@name=\"email\"]")).sendKeys("successismine514@gmail.com");
            driver.findElement(By.xpath("//input[@name=\"password\"]")).sendKeys("Google@123");
            driver.findElement(By.xpath("//button[text()='Login']")).click();
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

            driver.findElement(By.id("profile__dropdown")).click();

            driver.findElement(By.xpath("//*[@class='profile__dropdown__item']")).click();

            String actualTitle = driver.getTitle();
            Assertions.assertEquals(actualTitle,"Profile - LambdaTest");
            System.out.println("********Execution of "+methodName+" has ended********");
        }
        @AfterEach
        public void tearDown() {
            System.out.println("Quitting the browsers has started");
            driver.quit();
            System.out.println("Quitting the browsers has ended");

        }

        @AfterAll
        public static void end() {
            System.out.println("Tests ended");

        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Console Output:
&lt;/h2&gt;

&lt;p&gt;The tests marked with composed annotation have been executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fri46b1nn7dwjuieop53w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fri46b1nn7dwjuieop53w.png" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: This &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress automation&lt;/a&gt; testing tutorial will help you learn the benefits of Cypress automation, and how to install Cypress and execute Cypress automation testing over scores of browsers and operating systems online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing test cases repeatedly in JUnit5
&lt;/h2&gt;

&lt;p&gt;To run our JUnit tests repeated a certain number of times, JUnit 5 provides an annotation @RepeatedTest. Using the RepeatedTest class, you can write a test method that will repeat execution with different input data over and over again. This class gets used when your tests need to be repeated multiple times with data, such as when running performance profiling or simulating everyday use of your app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package demo;

    import org.junit.jupiter.api.*;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class RepeatedTestsInJUnit {

        WebDriver driver;
        String urlToTest ="https://www.lambdatest.com/";

        @BeforeAll
        public static void start() {
            System.out.println("=======Starting junit 5 tests========");
        }

        @BeforeEach
        public void setup() {
            System.out.println("Setting up the drivers");
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\Mychromedriver\\chromedriver.exe");
            driver = new ChromeDriver();
        }


        @RepeatedTest(value=7,name="{displayName} {currentRepetition}/{totalRepetitions}")
        @DisplayName("Repeat_Test")
        public void launchAndVerifyTitle_Test(RepetitionInfo repetitionInfo) {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            String actualTitle = driver.getTitle();
            System.out.println("The page title is "+actualTitle);
            String expectedTitle ="Most Powerful Cross Browser Testing Tool Online | LambdaTest";
            System.out.println("Verifying the title of the webpage started");
            Assertions.assertEquals(expectedTitle, actualTitle);
            System.out.println("The webpage has been launched and the title of the webpage has been veriified successfully");
            System.out.println("********Execution of "+methodName+" has ended********");
            Assertions.assertEquals(7,repetitionInfo.getTotalRepetitions());
        }
        @AfterEach
        public void tearDown() {
            System.out.println("Quitting the browsers has started");
            driver.quit();
            System.out.println("Quitting the browsers has ended");

        }

        @AfterAll
        public static void end() {
            System.out.println("Tests ended");

        }

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Console Output:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkli3r4k6n2ef14lkij6l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkli3r4k6n2ef14lkij6l.png" width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also read&lt;/strong&gt; — &lt;a href="https://www.lambdatest.com/blog/repeatedtest-annotation-in-junit-5/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How To Use @RepeatedTest Annotation In JUnit 5&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running JUnit 5 tests using Jupiter
&lt;/h2&gt;

&lt;p&gt;To run the same JUnit test with multiple inputs, we can use &lt;a href="https://www.lambdatest.com/blog/junit-parameterized-test-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;@ParameterizedTest annotation in JUnit 5&lt;/a&gt;. While parameterizing the values, the test has to be annotated with @ParameterizedTest instead of &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Scenario: Verify the Login functionality of the website using different sets of credentials to cover valid and negative cases.&lt;/p&gt;

&lt;p&gt;For parameterizing the tests, we have to add the below maven dependency in the pom.xml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;junit-jupiter-params&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pom.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
        &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

        &amp;lt;groupId&amp;gt;org.example&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;SampleJunitTests&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

        &amp;lt;properties&amp;gt;
            &amp;lt;maven.compiler.source&amp;gt;1.8&amp;lt;/maven.compiler.source&amp;gt;
            &amp;lt;maven.compiler.target&amp;gt;${maven.compiler.source}&amp;lt;/maven.compiler.target&amp;gt;
            &amp;lt;junit.jupiter.version&amp;gt;5.7.1&amp;lt;/junit.jupiter.version&amp;gt;
        &amp;lt;/properties&amp;gt;

        &amp;lt;dependencies&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;junit-jupiter-engine&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${junit.jupiter.version}&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;junit-jupiter-api&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${junit.jupiter.version}&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.seleniumhq.selenium&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;selenium-java&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;3.141.59&amp;lt;/version&amp;gt;
            &amp;lt;/dependency&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;junit-jupiter-params&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;

        &amp;lt;/dependencies&amp;gt;

    &amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test script for parameterizing our tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package demo;

    import org.junit.jupiter.api.Assertions;
    import org.junit.jupiter.api.BeforeAll;
    import org.junit.jupiter.api.BeforeEach;
    import org.junit.jupiter.params.ParameterizedTest;
    import org.junit.jupiter.params.provider.Arguments;
    import org.junit.jupiter.params.provider.MethodSource;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;


    import java.util.concurrent.TimeUnit;
    import java.util.stream.Stream;


    import static org.junit.jupiter.params.provider.Arguments.arguments;

    public class test {

        WebDriver driver;
        String urlToTest ="https://www.lambdatest.com/";

        @BeforeAll
        public static void start() {
            System.out.println("=======Starting junit 5 tests========");
        }

        @BeforeEach
        public void setup() {
            System.out.println("Setting up the drivers");
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\Mychromedriver\\chromedriver.exe");
            driver = new ChromeDriver();
        }

        @ParameterizedTest
        @MethodSource("userList")
        public void login_Test(String user,String passwd) {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            WebElement login = driver.findElement(By.xpath("//a[text()='Login']"));
            login.click();
            WebElement username = driver.findElement(By.xpath("//input[@name='email']"));
            WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
            WebDriverWait wait = new WebDriverWait(driver,20);
            wait.until(ExpectedConditions.visibilityOf(username));
            username.clear();
            username.sendKeys(user);
            password.clear();
            password.sendKeys(passwd);
            WebElement loginButton = driver.findElement(By.xpath("//button[text()='Login']"));
            loginButton.click();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            String actual = driver.getTitle();
            String expected = "Welcome - LambdaTest";
            Assertions.assertEquals(expected, actual);
            System.out.println("The user has been successfully logged in");
            System.out.println("********Execution of "+methodName+" has ended********");
        }

        static Stream&amp;lt;Arguments&amp;gt; userList() {
            return Stream.of(
                    arguments("xxxxxx@gmail.com","abc@123" ),
                    arguments("yyyyyyyy@gmail.com", "one@123")
            );
        }
    @AfterEach
    public void tearDown() {
        System.out.println("Quitting the browsers has started");
        driver.quit();
        System.out.println("Quitting the browsers has ended");
    }

    @AfterAll
    public static void end() {
        System.out.println("Tests ended");
    }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: This Cypress automation testing tutorial will help you learn the benefits of &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress test automation&lt;/a&gt;, and how to install Cypress and execute Cypress automation testing over scores of browsers and operating systems online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running JUnit 5 tests in LambdaTest Grid
&lt;/h2&gt;

&lt;p&gt;Using Selenium along with JUnit is a good option due to its capabilities to run tests on multiple browsers and platforms, providing flexibility in choosing any third-party language.&lt;/p&gt;

&lt;p&gt;LambdaTest provides an online cloud platform to perform &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt; with ease at scale. &lt;a href="https://www.lambdatest.com/automation-testing-tool?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Automation testing tools&lt;/a&gt; like LambdaTest allows you to perform &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on an &lt;a href="https://www.lambdatest.com/online-device-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online device farm&lt;/a&gt; of over 3000+ real devices running real operating systems.&lt;/p&gt;

&lt;p&gt;Once you are logged into the website you will be provided with a username and an access key which can be used to run your scripts in the cloud.&lt;/p&gt;

&lt;p&gt;Below is the code snippet for executing the JUnit 5 tests using Jupiter in the LambdaTest platform.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package demo;

    import org.junit.jupiter.api.*;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;

    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.List;
    import java.util.concurrent.TimeUnit;

    @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
    public class RunTestsInCloud {

        String username = "YOUR_USERNAME"; //Enter your username
        String accesskey = "YOUR_ACCESSKEY"; //Enter your accesskey

        static RemoteWebDriver driver = null;
        String gridURL = "@hub.lambdatest.com/wd/hub";
        String urlToTest = "https://www.lambdatest.com/";

        @BeforeAll
        public static void start() {
            System.out.println("=======Starting junit 5 tests in LambdaTest Grid========");
        }

        @BeforeEach
        public void setup() {
            System.out.println("Setting up the drivers and browsers");
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("browserName", "chrome");   //To specify the browser
            capabilities.setCapability("version", "70.0");    //To specify the browser version
            capabilities.setCapability("platform", "win10");      // To specify the OS
            capabilities.setCapability("build", "Running_Junit5Tests_In_Grid");               //To identify the test
            capabilities.setCapability("name", "JUnit5Tests");
            capabilities.setCapability("network", true);      // To enable network logs
            capabilities.setCapability("visual", true);          // To enable step by step screenshot
            capabilities.setCapability("video", true);       // To enable video recording
            capabilities.setCapability("console", true);         // To capture console logs
            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }


        /*To test the tabs available in the main page like Resources,Documentation,login etc */
        @Test
        @DisplayName("HeaderTabs_Test")
        @Tag("Smoke")
        @Order(1)
        public void headers_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

            List&amp;lt;WebElement&amp;gt; elements = driver.findElements(By.xpath("//*[contains(@class,'md:text-right')]/a"));
            List&amp;lt;String&amp;gt; actualList = new ArrayList&amp;lt;&amp;gt;();
            for(WebElement ele :elements){
                actualList.add(ele.getText());
            }

            System.out.println("Actual elements : "+actualList);
            List&amp;lt;String&amp;gt; expectedList = Arrays.asList("Live","Automation","Pricing","Documentation","Login","Start Free Testing");
            System.out.println("Expected elements : "+expectedList);

            boolean boolval = actualList.equals(expectedList);
            System.out.println(boolval);
            Assertions.assertTrue(boolval);
            System.out.println("********Execution of "+methodName+" has ended********");
        }

        @Test
        @DisplayName("LTBrowser_Test")
        @Tag("Smoke")
        @Order(2)
        public void click_LTBrowser_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//a[text()='Login']")).click();
            driver.findElement(By.xpath("//input[@name=\"email\"]")).sendKeys("successismine514@gmail.com");
            driver.findElement(By.xpath("//input[@name=\"password\"]")).sendKeys("Google@123");
            driver.findElement(By.xpath("//button[text()='Login']")).click();
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

            List &amp;lt;WebElement&amp;gt; options = driver.findElements(By.xpath("//div[contains(@class,'aside__menu__item')]//a"));
            for(WebElement ele : options){
                if(ele.getText().equals("LT Browser")) {
                    ele.click();
                    break;
                }

            }
            driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
            String actualText = driver.findElement(By.xpath("//*[@class='lt__demo__box__title']")).getText();
            String expectedText = "LT Browser- Desktop App for Fast and Easy Mobile View Testing";
            Assertions.assertEquals(expectedText, actualText);
            System.out.println("The user has been successfully navigated to LT browser page");
            System.out.println("********Execution of "+methodName+" has ended********");
        }



        @Test()
        @DisplayName("editProfile_Test")
        @Order(3)
        public void editProfile_Test() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//a[text()='Login']")).click();
            driver.findElement(By.xpath("//input[@name=\"email\"]")).sendKeys("successismine514@gmail.com");
            driver.findElement(By.xpath("//input[@name=\"password\"]")).sendKeys("Google@123");
            driver.findElement(By.xpath("//button[text()='Login']")).click();
            driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

            driver.findElement(By.id("profile__dropdown")).click();

            driver.findElement(By.xpath("//*[@class='profile__dropdown__item']")).click();

            String actualTitle = driver.getTitle();
            Assertions.assertEquals(actualTitle,"Profile - LambdaTest");
            System.out.println("********Execution of "+methodName+" has ended********");
        }

        @Test
        @DisplayName("ResourcesOption_Test")
        @Order(4)
        public void getListOfOptionsUnderResourcesTab() {
            String methodName = Thread.currentThread()
                    .getStackTrace()[1]
                    .getMethodName();
            System.out.println("********Execution of "+methodName+" has been started********");
            System.out.println("Launching LambdaTest website started..");
            driver.get(urlToTest);
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
            WebElement resources = driver.findElement(By.xpath("//*[text()='Resources ']"));
            List&amp;lt;WebElement&amp;gt; options_under_resources = driver.findElements(By.xpath("//*[text()='Resources ']/../ul/a"));
            boolean flag = resources.isDisplayed();
            if(flag) {
                System.out.println("Resources header is visible in the webpage");
                Actions action = new Actions(driver);
                action.moveToElement(resources).build().perform();
                WebDriverWait wait=new WebDriverWait(driver, 20);
                wait.until(ExpectedConditions.visibilityOfAllElements(options_under_resources));
                List&amp;lt;String&amp;gt; options = new ArrayList&amp;lt;&amp;gt;();
                for(WebElement element : options_under_resources) {
                    options.add(element.getText());
                }
                System.out.println(options);
                List&amp;lt;String&amp;gt; list = Arrays.asList("Blog", "Certifications", "Learning Hub", "Webinars", "Videos", "Newsletter", "Community", "Case Studies", "Product Updates");
                boolean boolval = list.equals(options);
                System.out.println(boolval);
                Assertions.assertTrue(boolval);
            }
            else {
                Assertions.fail("Resources header is not visible");
            }
            System.out.println("********Execution of "+methodName+" has ended********");
        }

        @AfterEach
        public void tearDown() {
            System.out.println("Quitting the browsers has started");
            driver.quit();
            System.out.println("Quitting the browsers has ended");

        }

        @AfterAll
        public static void end() {
            System.out.println("Tests ended");

        }

    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run this test in the LambdaTest platform:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Right-click on the test class that you have created in the IDE.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click Run. Now the test will be started on the LambdaTest platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once your tests are executed, navigate to your LambdaTest Account in the browser and click Dashboard in the left-hand side panel. This page shows an overview of the tests that are run on the platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, click the Automation label in the left-hand side panel. This is the place where you have to identify your executed tests. It contains multiple tests, and to identify the specific test, you have to search using the build name that you have provided in the script.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the code above, we have named the build as ” Running_Junit5Tests_In_Grid” and now search for that build. This page also shows the status of your build and the time taken for execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feun301task6gz9qdctcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feun301task6gz9qdctcq.png" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the build to view the tests that were run. You can see the test “JUnit5Tests”, which was provided in the script, and this is how we identify our tests in LambdaTest. We will see four tests run in the grid as written in our script. Here you can verify all the test details that have been provided in the script, like the browser, browser version, operating system, and version in which the test was executed. This would be the same as provided in the test script.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As we have enabled video recording in the code, you will see a video attached to the test on this page, which has recorded all the test steps while executing the test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsubtgjtrsdrmv8hev06m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsubtgjtrsdrmv8hev06m.png" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By playing the video, you can view how the tests were executed. In case of failure, this would help analyze the point where the failure has occurred. We can also have a quick view of the tests on the **Meta **tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq93pwcqhnxjfslo9dx1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq93pwcqhnxjfslo9dx1d.png" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To see the steps executed in a test, click a Test and go to the **COMMAND **tab. This displays the list of steps that are executed as part of the test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ddwgoxihvqslpzzng9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ddwgoxihvqslpzzng9v.png" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the test doesn’t behave as per the expectation as a result of which failure occurs in any step, it can be directly marked as a bug by clicking the &lt;strong&gt;Mark Bug&lt;/strong&gt; icon in the test step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Console Output:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3kl80kb6caks4mfdqgn4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3kl80kb6caks4mfdqgn4.png" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest also allows users to get a clear view of the quality and performance of their applications by tracking the health of test cases through &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest Analytics&lt;/a&gt;. Visit Analytics under the Automation page to see your failed tests, download a report, and track test progress.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqjcyhm1jpr3q2webcfk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqjcyhm1jpr3q2webcfk.png" width="600" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can go through the following video on &lt;a href="https://www.youtube.com/playlist?list=PLZMWkkQEwOPn68qzCGJl07ZbnI7Ix5zKU" rel="noopener noreferrer"&gt;JUnit Tutorial for beginners&lt;/a&gt; series, to run JUnit tests in parallel in the Selenium cloud using multiple browsers and platforms. The video demonstrates cross-browser testing with JUnit using the LambdaTest platform. By the end of this tutorial video, you will be in a position to &lt;a href="https://www.lambdatest.com/blog/parallel-testing-with-junit5-and-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;run JUnit tests in parallel&lt;/a&gt; across different browsers and platforms.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/S3tr6TuUL38"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can also Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: This &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright browser testing&lt;/a&gt; tutorial will guide you through the setup of the Playwright framework, which will enable you to write end-to-end tests for your future projects.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally!
&lt;/h2&gt;

&lt;p&gt;We have reached the end of the article on JUnit Jupiter, and it is time to summarize our understanding here. So far, we have seen a quick introduction to the JUnit framework and the latest version of it, JUnit 5. We have seen how to frame our tests using JUnit 5, the various annotations used in JUnit 5, and the most important part, the execution of JUnit 5 tests using Jupiter for &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb27_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;. Now it is time for you to try and explore. I hope you all find this article informative and helpful. I would love to hear your comments on this. Until then, Happy Testing…!&lt;/p&gt;

</description>
      <category>anime</category>
      <category>action</category>
      <category>thriller</category>
      <category>comedy</category>
    </item>
    <item>
      <title>How To Use isDisplayed() In Selenium WebDriver</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Thu, 23 Feb 2023 11:48:50 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-use-isdisplayed-in-selenium-webdriver-4o6b</link>
      <guid>https://forem.com/testmuai/how-to-use-isdisplayed-in-selenium-webdriver-4o6b</guid>
      <description>&lt;p&gt;If you use Selenium WebDriver, you are probably aware that there are a number of common ways to loop through and interact with elements on a web page. Among them isDisplayed(), isEnabled(), and isSelected() methods. When a tester needs to ascertain the visibility scope of a web element, they can use these methods.&lt;/p&gt;

&lt;p&gt;This article will start by explaining how isDisplayed() in Selenium works and why it is used in testing. We will then explore two other looping and conditional commands, isSelected() and isEnabled().&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Selenium?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; has always been the primary choice of automation framework when it comes to automating the interactions on the web page. It is an open-source framework and has various features like multi-browser and platform compatibility, multi-language support, simple setup, and integration with &lt;a href="https://www.lambdatest.com/infographics/top-11-unit-testing-framework?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;popular unit testing frameworks&lt;/a&gt; like JUnit and TestNG.&lt;/p&gt;

&lt;p&gt;When it comes to automation, a tester always looks for a perfect insightful way to capture all the requirements for framing the test cases. But whenever the tests are executed, there would be some cases reported with false failures. We all might have faced such a situation in our work. Sometimes the issue would arise because of the environment, and it would sometimes be the code issue. Overcoming or handling false failures is considered one of the best practices in designing the automation framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also read&lt;/strong&gt; — &lt;a href="https://www.lambdatest.com/blog/locators-in-selenium-webdriver-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Best Practices to Follow in Test Automation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Handling the web elements on the web page in the automation suite might not be as easy as it looks. Locating the web elements has been simplified as we have multiple tools for inspecting them. In some situations, we need to check the presence of the web elements on the web page before proceeding further, as it might throw &lt;a href="https://www.lambdatest.com/blog/49-common-selenium-exceptions-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;exceptions in Selenium&lt;/a&gt; when the elements aren’t found on the page. It’s not that the element we are looking for is not present on the web page&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/VeV_sup5S8E"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt; Cloud For App Automation- Test your Native, Hybrid, and Web Apps on Appium mobile device cloud of 3000+ different real devices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;There might be times when it takes some time for the element to be displayed on the page. Even though adding some amount of wait time would save us from such exceptions, it is always good to verify the presence of elements. But handling those elements in automation might throw some unexpected exceptions. So how do we overcome such situations? I have come up with a few suggestions for overcoming such situations. Let us dive in through this blog to understand a few methods to overcome some false failures in our automation suite.&lt;/p&gt;

&lt;p&gt;To locate an element present on a webpage, we can use eight different types of &lt;a href="https://www.lambdatest.com/blog/locators-in-selenium-webdriver-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;locators in Selenium&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Id&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ClassName&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Xpath&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CSS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LinkText&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PartialLinkText&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TagName&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the help of any of these locators, we can locate the elements on the web page and interact with them.&lt;/p&gt;

&lt;p&gt;But sometimes, even though we have used the correct web element in our automation scripts, our tests may fail to say that the element is not found on the page. Ever wondered why is it so? There are multiple reasons for getting this exception, but among those, we wouldn’t have checked if the element is actually present on the page or not. There may be times the web page might be loaded completely before which our tests might be looking for the element. In such cases, we might face this exception.&lt;/p&gt;

&lt;p&gt;For example, let us use &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest Login Page&lt;/a&gt; to verify the login functionality. Sometimes when the email and password elements aren’t loaded within a specific wait time, the tests will throw exceptions stating that the element is not found on the page. So while automating, it is always a good practice to look for the presence of email and password textboxes before actually interacting with them.&lt;/p&gt;

&lt;p&gt;In the next section of this article on how to use isDisplayed() in &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;, we will see how we ensure the presence of web elements in Selenium.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02y1ubgh0hpkizuk7y9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02y1ubgh0hpkizuk7y9i.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to ensure the presence of Web Elements in Selenium?
&lt;/h2&gt;

&lt;p&gt;There are three different ways to ensure the presence of web elements on a web page:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;isDisplayed()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;isSelected()&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IsEnabled()&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fquzzs06dfdx359sgxxht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fquzzs06dfdx359sgxxht.png" width="800" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article on how to use isDisplayed() in Selenium WebDriver, I have used &lt;a href="https://www.lambdatest.com/learning-hub/selenium-java?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium with Java&lt;/a&gt;. So the syntax and code used here is based on Java language. The syntax mentioned below would vary depending upon the programming language you choose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax for isDisplayed():&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    driver.findElement(By.&amp;lt;LocatorStrategy&amp;gt;(“Locator_Value”)).isDisplayed();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The return type of isDisplayed() method is Boolean. Hence by getting the value of this, we can verify if the web element is present or not on the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax for isSelected():&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    driver.findElement(By.&amp;lt;LocatorStrategy&amp;gt;(“Locator_Value”)). isSelected();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The return type of isSelected() method is Boolean. Hence by getting the value of this, we can verify if the web element is present or not on the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax for isEnabled():&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  driver.findElement(By.&amp;lt;LocatorStrategy&amp;gt;(“Locator_Value”)). isEnabled();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The return type of isEnabled() method is Boolean. Hence by getting the value of this, we can verify if the web element is present or not on the web page.&lt;/p&gt;

&lt;p&gt;As the name suggests, each method is different and is designed in a way to serve its own purpose. Let’s see how to use them in our scripts in detail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Emulator Online&lt;/a&gt; - Test your mobile websites and smartphone apps using our scalable on cloud mobile emulator.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the isDisplayed() method in Selenium?
&lt;/h2&gt;

&lt;p&gt;This method is used to verify the presence of any web elements on the web page. We can use it for verifying the presence of text boxes, buttons, dropdowns, checkboxes, radio buttons, etc.&lt;/p&gt;

&lt;p&gt;Since Selenium Java is used here you can also watch this video to learn how to select multiple checkboxes in Selenium WebDriver Java.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/W07b7lEyoGs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Automation Testing&lt;/a&gt; Platform - Accelerate your release velocity with blazing fast test automation on cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use the isDisplayed() method for verifying the text box?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scenario&lt;/strong&gt;: Verify if the text boxes are present on the login page to enter the credentials&lt;/p&gt;

&lt;p&gt;Step 1: Navigate to &lt;a href="https://accounts.lambdatest.com/login" rel="noopener noreferrer"&gt;https://accounts.lambdatest.com/login&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Step 2: Verify the presence of the Email and Password textbox.&lt;/p&gt;

&lt;p&gt;Step 3: Enter the email and password.&lt;/p&gt;

&lt;p&gt;Step 4: Click LOGIN.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs6m727ydmfki6ebzng3o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs6m727ydmfki6ebzng3o.jpg" width="751" height="713"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Let us inspect the Email element.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1uqwroojcy9d57hf0602.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1uqwroojcy9d57hf0602.png" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Now let us identify the Password element&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fya5jgjjrqxfpqxs514kt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fya5jgjjrqxfpqxs514kt.png" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- The final step is to locate the LOGIN button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsk57e7e0jjfvd841ixlc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsk57e7e0jjfvd841ixlc.jpg" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  package myTest;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Parameters;
    import org.testng.annotations.Test;
    import java.net.MalformedURLException;
    import java.net.URL;

    class test1 {

        public String username = "YOUR_USERNAME";
        public String accesskey = "YOUR_ACCESSKEY";
        public static RemoteWebDriver driver = null;
        public String gridURL = "@hub.lambdatest.com/wd/hub";

        @Parameters(("browser"))
        @BeforeTest
        public void setUp(String browser) throws Exception {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            if(browser.equalsIgnoreCase("chrome")) {
                capabilities.setCapability("browserName", "chrome");
                capabilities.setCapability("version", "96.0");
                capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
                capabilities.setCapability("build", "automationTest");
                capabilities.setCapability("name", "automationTest_Demo");
            }
            else if( browser.equalsIgnoreCase("firefox")){
                capabilities.setCapability("platform", "Windows 11");
                capabilities.setCapability("browserName", "Firefox");
                capabilities.setCapability("version","97.0");
                capabilities.setCapability("build", "automationTest");
                capabilities.setCapability("name", "automationTest_Demo");
            }

            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }

        @Test
        public void elementIsDisplayed() {
            try {
                System.out.println("Launching Lambda Test Login Page");
                driver.get("https://accounts.lambdatest.com/login");

                WebElement email= driver.findElement(By.id("email"));
                boolean isEmailBoxPresent = email.isDisplayed();
                if(isEmailBoxPresent) {
                    email.sendKeys("abc@gmail.com");
                    System.out.println("email text box is present");
                }
                else
                    Assert.fail("No email text box is present in the webpage");

                WebElement password=driver.findElement(By.id("password"));
                boolean isPasswordBoxPresent = password.isDisplayed();
                if(isEmailBoxPresent) {
                    password.sendKeys("abc@13w32");
                    System.out.println("password box is present");
                }
                else
                    Assert.fail("Password text box is not present in the webpage");

                WebElement loginBtn = driver.findElement(By.id("login-button"));
                loginBtn.click();
            } catch (Exception e) {
                System.out.println(e);
            }

        }

        @AfterTest
        public void closeBrowser() {
            driver.quit();
            System.out.println("The driver has been closed.");

        }

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
    &amp;lt;suite name="TestSuite" parallel="tests" thread-count="4"&amp;gt;
        &amp;lt;test name="ChromeBrowserTest"&amp;gt;
            &amp;lt;parameter name="browser" value="Chrome"/&amp;gt;
            &amp;lt;classes&amp;gt;
                &amp;lt;class name="myTest.test1"&amp;gt;
                &amp;lt;/class&amp;gt;
            &amp;lt;/classes&amp;gt;
        &amp;lt;/test&amp;gt;
        &amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pom.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
        &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

        &amp;lt;groupId&amp;gt;org.example&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;LambdaTest&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

        &amp;lt;dependencies&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.seleniumhq.selenium&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;selenium-java&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;4.0.0&amp;lt;/version&amp;gt;
            &amp;lt;/dependency&amp;gt;

            &amp;lt;!-- https://mvnrepository.com/artifact/org.testng/testng --&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.testng&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;testng&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;7.4.0&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.testng&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;testng&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;RELEASE&amp;lt;/version&amp;gt;
                &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
        &amp;lt;/dependencies&amp;gt;

    &amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now let me take you through the code implementation for verifying the presence of an element using the method isDisplayed() in Selenium.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Add the required dependencies like Selenium, TestNG, etc. in pom.xml&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the test class, we have added &lt;a href="https://www.lambdatest.com/blog/complete-guide-on-testng-annotations-for-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG annotations&lt;/a&gt; like @BeforeTest, &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, and @AfterTest&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run our tests in the &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cloud Selenium Grid&lt;/a&gt; like LambdaTest, we need to &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;create an account on LambdaTest&lt;/a&gt;. Once we have our account created, we will be provided with a username and access key to run our tests. We can define the username, access key, and grid URL as the global variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have added some basic setup like defining the desired capabilities for running our tests in different browsers and platforms in cloud Selenium cloud under a method annotated with @BeforeTest. We have also parameterized the test with the parameter browser. Based on the value provided in TestNG.xml for the parameter, the tests will be executed in the respective browsers.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @Parameters(("browser"))
    @BeforeTest
    public void setUp(String browser) throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        if(browser.equalsIgnoreCase("chrome")) {
            capabilities.setCapability("browserName", "chrome");
            capabilities.setCapability("version", "96.0");
            capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
            capabilities.setCapability("build", "automationTest");
            capabilities.setCapability("name", "automationTest_Demo");
        }
        else if( browser.equalsIgnoreCase("firefox")){
            capabilities.setCapability("platform", "Windows 11");
            capabilities.setCapability("browserName", "Firefox");
            capabilities.setCapability("version","97.0");
            capabilities.setCapability("build", "automationTest");
            capabilities.setCapability("name", "automationTest_Demo");
        }

        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5- We have created a method annotated with &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; which has the actual implementation of the test scenario. After launching the login page of the website, we locate the element’s email and password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  WebElement email= driver.findElement(By.id("email"));
    WebElement password=driver.findElement(By.id("password"));

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we have to check if the elements are displayed on the webpage or not to ensure that our tests don’t throw exceptions and cause false failures.&lt;/p&gt;

&lt;p&gt;We have used the isDisplayed() in Selenium to check the presence of a web element on the web page that returns a Boolean value. This method returns true if the element is displayed on the webpage or returns false if the element is not displayed on the webpage. Based on this Boolean value we can ensure the presence of any web element on the web page and then proceed with our tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   boolean isEmailBoxPresent = email.isDisplayed();
    if(isEmailBoxPresent) {
        email.sendKeys("abc@gmail.com");
        System.out.println("email text box is present");
    }
    else
        Assert.fail("No email text box is present in the webpage");

    boolean isPasswordBoxPresent = password.isDisplayed();
    if(isEmailBoxPresent) {
        password.sendKeys("abc@13w32");
        System.out.println("paswword box is present");
    }
    else
        Assert.fail("Password text box is not present in the webpage");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our case, we have used isDisplayed() in Selenium to verify the presence of email and password text boxes on the page. If the element is present, then we shall proceed with entering the values.&lt;/p&gt;

&lt;p&gt;After entering the values of email and password, we have added a step to click the login button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  WebElement loginBtn = driver.findElement(By.id("login-button"));
    loginBtn.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6- Finally, we have added a method annotated with @AfterTest to close the browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   @AfterTest
    public void closeBrowser() {
        driver.quit();
        System.out.println("The driver has been closed.");
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;7- We have to create a TestNG.xml file, which will be used to run our tests. We have to define the test class name along with the package in which it was created. We also have to define the browser parameter and its value which will be leveraged to run our tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;test name="ChromeBrowserTest"&amp;gt;
        &amp;lt;parameter name="browser" value="Chrome"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="myTest.test1"&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To execute our tests, right-click the TestNG.xml file and click run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa08dpd81xl02idk8bx3l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa08dpd81xl02idk8bx3l.png" width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On running the tests, we can see the output displayed below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzo886s71kwpk990qqpee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzo886s71kwpk990qqpee.png" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://accounts.lambdatest.com/dashboard?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt;, we can identify our test by the name provided in the desired capabilities in the code.&lt;/p&gt;

&lt;p&gt;LambdaTest is a &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platform to carry out live and &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt; of websites and web applications on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ browsers and OS combinations.&lt;/p&gt;

&lt;p&gt;LambdaTest’s test automation features help you –&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ship quality builds at a breakneck pace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce lead time by multiple folds with &lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hasten your automation testing cycle by integrating test suites with the best CI/CD tools.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnif1tqmtfx5penplwwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdnif1tqmtfx5penplwwr.png" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see the browser and platform in which the tests were run and also find the status of the test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fabdvle7q4c3pqwc0nw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7fabdvle7q4c3pqwc0nw.png" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On further clicking the tests, we can see some details like the video recording and the logs of our test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8owrchrizkqlejqivrp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8owrchrizkqlejqivrp3.png" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also navigate to the &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest Analytics Dashboard&lt;/a&gt; to view test performance metrics. The Test Summary will show the total number of tests passed or failed, including completed and pending tests. Whereas the Test Overview will provide a snapshot of consistent tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfx9pk0lzxk04r03qhq3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpfx9pk0lzxk04r03qhq3.gif" width="600" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similar to isDisplayed() in Selenium, we have two more methods — isSelected() and isEnabled() to check if an element is selected or if an element is enabled on the web page, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test Automation&lt;/a&gt; Platform — Accelerate your release velocity with blazing fast test automation on cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the isEnabled() method in Selenium?
&lt;/h2&gt;

&lt;p&gt;This method is used to check if an element is enabled on a web page or not. This method returns a Boolean value, and if the value is true the element is enabled in the webpage and it will return false if the element is not enabled in the webpage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax for isEnabled() method :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  driver.findElement(By.&amp;lt;LocatorStrategy&amp;gt;(“Locator_Value”)). isEnabled();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the web page, we might encounter situations where some buttons will be enabled unless some condition has been met.&lt;/p&gt;

&lt;p&gt;For example, let us navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; site, which can be used to download a file. Here, we can see the “Generate File” button disabled unless any value is entered in the Enter Data section. We can implement this in our test and verify if this button is enabled or not on the web page.&lt;br&gt;
&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Launch the &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify if the “Generate File” button is enabled or not.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqqgm41go8ya2rq03734.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqqgm41go8ya2rq03734.jpg" width="800" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The test setup is similar to the one we have implemented in the previous section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package myTest;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Parameters;
    import org.testng.annotations.Test;
    import java.net.MalformedURLException;
    import java.net.URL;

    class test2 {

        public String username = "YOUR_USERNAME";
        public String accesskey = "YOUR_ACCESSKEY";
        public static RemoteWebDriver driver = null;
        public String gridURL = "@hub.lambdatest.com/wd/hub";

        @Parameters(("browser"))
        @BeforeTest
        public void setUp(String browser) throws Exception {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            if(browser.equalsIgnoreCase("chrome")) {
                capabilities.setCapability("browserName", "chrome");
                capabilities.setCapability("version", "96.0");
                capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
                capabilities.setCapability("build", "isEnabledTest");
                capabilities.setCapability("name", "isEnabledTest_Demo");
            }
            else if( browser.equalsIgnoreCase("firefox")){
                capabilities.setCapability("platform", "Windows 11");
                capabilities.setCapability("browserName", "Firefox");
                capabilities.setCapability("version","97.0");
                capabilities.setCapability("build", "isEnabledTest");
                capabilities.setCapability("name", "isEnabledTest_Demo");
            }

            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }

        @Test
        public void elementIsEnabled() {
            try {
                System.out.println("Launching Lambda Test Login Page");
                driver.get("https://www.lambdatest.com/selenium-playground/generate-file-to-download-demo");

                WebElement element= driver.findElement(By.id("create"));
                boolean status = element.isEnabled();

                System.out.println(status);
                if(status){
                    System.out.println("The element is enabled in the web page");
                }
                else
                    Assert.fail("The element is not enabled in the web page");

            } catch (Exception e) {
                System.out.println(e);
            }

        }

        @AfterTest
        public void closeBrowser() {
            driver.quit();
            System.out.println("The driver has been closed.");

        }

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
    &amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
    &amp;lt;suite name="TestSuite" parallel="tests" thread-count="4"&amp;gt;
        &amp;lt;test name="ChromeBrowserTest"&amp;gt;
            &amp;lt;parameter name="browser" value="Firefox"/&amp;gt;
            &amp;lt;classes&amp;gt;
                &amp;lt;class name="myTest.test2"&amp;gt;
                &amp;lt;/class&amp;gt;
            &amp;lt;/classes&amp;gt;
        &amp;lt;/test&amp;gt;

    &amp;lt;/suite&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The setup is similar to one we have done in the previous section for the method isDisplayed() in Selenium.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In our test, we have located the web element for the “Generate File” button.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fova0zx5rf792m4kltb5y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fova0zx5rf792m4kltb5y.png" width="800" height="421"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  WebElement element= driver.findElement(By.id("create"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3- We shall verify if the element is enabled or not on the web page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; boolean status = element.isEnabled();

    System.out.println(status);
    if(status){
        System.out.println("The element is enabled in the web page");
    }
    else
        Assert.fail("The element is not enabled in the web page");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4- The isEnabled() method has returned false as the element is not enabled in the web page before entering any text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbr5pb3vmlnhetqlrshr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbr5pb3vmlnhetqlrshr.png" width="800" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the dashboard, we can see the test being executed in the Firefox browser as mentioned in our TestNG.xml file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46efoyosx2xrlj5m2nik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46efoyosx2xrlj5m2nik.png" width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This Selenium 4 complete tutorial covers everything you need to know about Selenium 4.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/mMStkc3W9jY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Automation Testing Platform&lt;/a&gt; — Accelerate your release velocity with blazing fast test automation on cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the isSelected() method in Selenium?
&lt;/h2&gt;

&lt;p&gt;The isSelected() method is used to verify if the element is selected or not in the webpage. This method returns a Boolean value. If the element is selected then it will return true and if it’s not selected it will return false. This method is used for checking whether the radio buttons and checkboxes are selected or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax for isSelected() method :&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    driver.findElement(By.&amp;lt;LocatorStrategy&amp;gt;(“Locator_Value”)). isSelected();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Scenario:&lt;/strong&gt;&lt;br&gt;
Step 1. Launch the website &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt;.&lt;br&gt;
Step 2. Click the “Click on this check box”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2b9ppcsi1ble6qnbt3mg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2b9ppcsi1ble6qnbt3mg.png" width="512" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 3. Now verify if the checkbox has been selected or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   package myTest;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.testng.Assert;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Parameters;
    import org.testng.annotations.Test;
    import java.net.MalformedURLException;
    import java.net.URL;

    class test3 {

        public String username = "YOUR_USERNAME";
        public String accesskey = "YOUR_ACCESSKEY";
        public static RemoteWebDriver driver = null;
        public String gridURL = "@hub.lambdatest.com/wd/hub";

        @Parameters(("browser"))
        @BeforeTest
        public void setUp(String browser) throws Exception {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            if(browser.equalsIgnoreCase("chrome")) {
                capabilities.setCapability("browserName", "chrome");
                capabilities.setCapability("version", "96.0");
                capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
                capabilities.setCapability("build", "isSelectedTest");
                capabilities.setCapability("name", "isSelectedTest_Demo");
            }
            else if( browser.equalsIgnoreCase("firefox")){
                capabilities.setCapability("platform", "Windows 11");
                capabilities.setCapability("browserName", "Firefox");
                capabilities.setCapability("version","97.0");
                capabilities.setCapability("build", "isSelectedTest");
                capabilities.setCapability("name", "isSelectedTest_Demo");
            }

            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }

        @Test
        public void elementIsSelected() {
            try {
                System.out.println("Launching Lambda Test demo Page");
                driver.get("https://www.lambdatest.com/selenium-playground/checkbox-demo");

                WebElement checkbox= driver.findElement(By.id("isAgeSelected"));
                checkbox.click();
                boolean status = checkbox.isSelected();

                System.out.println(status);
                if(status){
                    System.out.println("The element is selected in the web page");
                }
                else
                    Assert.fail("The element is not selected in the web page");

            } catch (Exception e) {
                System.out.println(e);
            }

        }

        @AfterTest
        public void closeBrowser() {
            driver.quit();
            System.out.println("The driver has been closed.");

        }

    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The test setup is similar to the one that has been done in the previous section.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inspect the element which has to be selected.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopluhh9fzak3xb6oy6ca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopluhh9fzak3xb6oy6ca.png" width="800" height="487"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    WebElement checkbox= driver.findElement(By.id(“isAgeSelected”));
    checkbox.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3- After clicking the checkbox, let us check if the element is selected or not&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   boolean status = checkbox.isSelected();

        System.out.println(status);
        if(status){
            System.out.println("The element is selected in the web page");
        }
        else
            Assert.fail("The element is not selected in the web page");

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The isSelected() method has returned true as the element has been selected on the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszzgh6beea18pjx5neo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszzgh6beea18pjx5neo7.png" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the LambdaTest dashboard, we can find our tests&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d6p2ac392vzof3meem7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d6p2ac392vzof3meem7.png" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s modify our test and see what happens if we don’t select the checkbox.!!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   @Test
    public void elementIsSelected() {
        try {
            System.out.println("Launching Lambda Test demo Page");
            driver.get("https://www.lambdatest.com/selenium-playground/checkbox-demo");

            WebElement checkbox= driver.findElement(By.id("isAgeSelected"));
            boolean status = checkbox.isSelected();
            System.out.println(status);
            if(status){
                System.out.println("The element is selected in the web page");
            }
            else
                Assert.fail("The element is not selected in the web page");

        } catch (Exception e) {
            System.out.println(e);
        }

    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we have identified the locator but we aren’t clicking the checkbox. We shall be verifying if the checkbox has been selected or not now.&lt;/p&gt;

&lt;p&gt;Now our isSelected() method would return false as the checkbox is not selected. The console output would look like the below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3x2si8i4hj0gig98lq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3x2si8i4hj0gig98lq2.png" width="800" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdb3g5gkgq5110e3lw8js.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdb3g5gkgq5110e3lw8js.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This certification is ideal for testing professionals who want to acquire advanced, hands-on knowledge in &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Selenium Advanced certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DK21aHjuUE4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online Automation Testing Platform — Accelerate your release velocity with blazing fast &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb23_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation cloud&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap up…!
&lt;/h2&gt;

&lt;p&gt;Now it’s time to wrap up our understanding. So far, we have the implementation of three different methods — isDisplayed(), isEnabled() and isSelected() — serving its own purpose. The isDisplayed() in Selenium is used to ensure the visibility of the web element present on the web page. The isEnabled() method is used to ensure if the element with which we are trying to interact with is enabled or not on the web page.&lt;/p&gt;

&lt;p&gt;In case the element is not enabled, then we can’t proceed further on our tests which might return incorrect exceptions. The isSelected() method is to verify if the web element is already selected or not on the web page. This can be applied to the radio buttons and checkbox elements. The return type of all three methods is Boolean, based on which we can conclude the status of the web element.&lt;/p&gt;

&lt;p&gt;I hope this article on how to use isDisplayed() in Selenium WebDriver is really informative and helps you efficiently implement your tests. I would like to hear your feedback on this article. Try your hands on this and build up your automation tests logically. Keep exploring…!&lt;/p&gt;

&lt;p&gt;Happy Testing…!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>lowcode</category>
    </item>
    <item>
      <title>How To Generate Extent Reports In Selenium</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Thu, 09 Feb 2023 22:03:02 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-generate-extent-reports-in-selenium-4ab2</link>
      <guid>https://forem.com/testmuai/how-to-generate-extent-reports-in-selenium-4ab2</guid>
      <description>&lt;p&gt;Selenium is a great tool when it comes to reporting, as it provides inbuilt reports using various frameworks like TestNG and JUnit. Though a few built-in reports are available, they do not provide information on the steps executed as part of the test suite. Therefore, custom reporting needs to be implemented to make it convenient for all major project stakeholders.&lt;/p&gt;

&lt;p&gt;With the advent of custom report functionality that can be used to create reports for additional test-case information, it is even more important for the testers to configure those reports to be helpful for the entire project team.&lt;/p&gt;

&lt;p&gt;For someone who is new to the concept of Extent Reports, the idea of generating them may seem strange at first. This step-by-step guide will make it a little easier to understand how to generate Extent Reports in &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; with example codes.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  What are test reports in automation?
&lt;/h2&gt;

&lt;p&gt;Creating a report for a task makes the task 100% complete. The report not only provides a summary but also helps the person to visualize and summarize the results of the task. A report plays a vital role in &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; as well. A test automation report helps the testers and the other stakeholders understand the stability of the tests executed before the product goes live. This helps the stakeholders to understand the stability of the application and also provides confidence for going live.&lt;/p&gt;

&lt;p&gt;An automation test report should be designed in such a way that it depicts the results of the tests to the end-user. A good test report should hold various test statistics like the total number of automation test cases, the total number of test cases passed, the total number of failed test cases, the percentage of passed and failed cases, classification of the tests based on certain criteria, etc.&lt;/p&gt;

&lt;p&gt;In recent years, various reporting tools like &lt;a href="https://www.lambdatest.com/blog/how-to-generate-testng-reports-in-jenkins/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG Reports&lt;/a&gt;, JUnit Reports, Allure Reports, etc., are available for generating the test automation report. Out of those, Extent Reports is one of the &lt;a href="https://www.lambdatest.com/blog/best-reporting-tools-for-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;best reporting tools for Selenium&lt;/a&gt; that is being widely used in various organizations. It has gained immense popularity because of its unique features like report customization, integration with different test frameworks, amazing data visualization, etc. In this blog on Extent Reports in Selenium, we shall be looking at the most popularly used test report — the Extent Reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Extent Reports
&lt;/h2&gt;

&lt;p&gt;Extent Report is an open-source library used for generating test reports in &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt;. It has been more widely used for report generation than the inbuilt reports in various test frameworks because of its enhanced features and customization. It is a simple yet powerful reporting library that can be integrated with the automation framework for generating the automation test report.&lt;/p&gt;

&lt;p&gt;Extent Reports can also be integrated with other &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;popular test automation frameworks&lt;/a&gt; like JUnit and TestNG. It provides a detailed outlook on the automated test cases in a graphical way. It is very easy to integrate Extent Reports with the automation framework.&lt;/p&gt;

&lt;p&gt;Watch this video to know more about test result analysis and reporting in Selenium 4. Also, learn about different selenium reporting tools based on ease of setup, pricing, supported report formats, and more.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hx-RmetSsII"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/blog/cypress-test-automation-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Cypress Automation&lt;/a&gt; Testing Tutorial: E2E Testing with Cypress&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of Extent Reports
&lt;/h2&gt;

&lt;p&gt;Let us pen down the advantages of using Extent Reports in Selenium for automation testing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is an open-source library.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It provides a pictorial representation of the test results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be customized as required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It allows the users to attach screenshots and logs in the test report for a detailed summary of the tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be easily integrated with other frameworks like JUnit, TestNG, NUnit, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can be easily configured with Jenkins, Bamboo, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright Automation&lt;/a&gt; Tutorial: Getting Started With Playwright Framework&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites to generate Extent Reports
&lt;/h2&gt;

&lt;p&gt;In this blog on how to generate Extent Reports in Selenium, we shall set up and generate our first Extent Report in Selenium for our automation tests implemented with Selenium Java. For more information about Selenium Java, please read our &lt;a href="https://www.lambdatest.com/learning-hub/selenium-java?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium Java Tutorial&lt;/a&gt;. To set up and generate Extent Reports in Selenium upon test execution, let us see the prerequisites to be done.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Java:&lt;/strong&gt; Download and install Java in the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Selenium:&lt;/strong&gt; For framing our automation test cases, we need to install Selenium by adding a maven dependency in the pom.xml file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8aic1aiuef6n5iulwiq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8aic1aiuef6n5iulwiq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- Extent Reports:&lt;/strong&gt; To integrate our automation framework, we need the Extent Report dependency either as a maven dependency or a jar file. In the case of a maven project, add maven dependency in the pom.xml file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5a85czbvvr5ckyheunog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5a85czbvvr5ckyheunog.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also download the jar file and add the jar to the build path. You can refer to the mvn repository for adding the Extent Report dependency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4- TestNG:&lt;/strong&gt; To design and execute the tests, we shall use TestNG by adding the TestNG dependency.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmn1cc760yqrhvmwjx9z5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmn1cc760yqrhvmwjx9z5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have set up for automating a web application and generating the Extent Reports in Selenium.&lt;/p&gt;

&lt;p&gt;In the next section of this article on Extent Reports in Selenium, let us understand the terminologies in Extent Report in detail before adding our tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fztjf37ue7py5e42togd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fztjf37ue7py5e42togd8.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: How To Debug Websites Using &lt;a href="https://www.lambdatest.com/blog/debug-websites-using-safari-developer-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Developer Tools for safari&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to generate and customize the Extent Reports?
&lt;/h2&gt;

&lt;p&gt;There are three classes that are used for generating and customizing the Extent Reports in Selenium. They are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ExtentHtmlReporter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ExtentReports&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ExtentTest&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The ExtentHtmlReporter is used for creating an HTML file, and it accepts a file path as a parameter. The file path represents the path in which our extent report would be generated.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ExtentHtmlReporter htmlReporter =  new 

ExtentHtmlReporter(System.getProperty("user.dir")+"/Reports/extentR
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above line, we have used ExtentHtmlReporter and specified the file path where the Extent Report in Selenium has to be generated.&lt;br&gt;
In Java, the &lt;em&gt;getProperty(String key)&lt;/em&gt; method returns the system property specified by the key, which is passed as the argument. Here we have specified “user.dir” as the key, and System.getProperty(“user.dir”) returns our current working directory. So instead of specifying the full path, we can use this to fetch the value of our directory and add the path where we want our Extent Report in Selenium to be saved.&lt;br&gt;
ExtentHtmlReporter is also used to customize the extent reports. It allows many configurations to be made through the config() method. Some of the configurations that can be made are described below.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To set the title of the extent report, we can use setDocumentTitle(“YOUR_TITLE”).&lt;/p&gt;

&lt;p&gt;htmlReporter.config().setDocumentTitle("Automation Report");&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2- To set the report name, we can use setReportName(“YOUR_REPORT_NAME”).&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;htmlReporter.config().setReportName("report");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;3- We can also specify the time format in our extent report by using the setTimeStampFormat() method.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;htmlReporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now, once the Extent Report in Selenium gets generated, we can visualize all the above changes in the report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqs1b4dhvddir5jrj3uh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqs1b4dhvddir5jrj3uh.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to these changes, if you are a great fan of dark themes, then Extent Reports in Selenium can also be customized with dark themes using the setTheme() method.&lt;/p&gt;

&lt;p&gt;We have two themes — STANDARD and DARK for customizing the look and feel of our extent reports.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7urpxbrxxrex0hue03i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7urpxbrxxrex0hue03i.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For Light Theme, we can set the Theme as STANDARD.&lt;/p&gt;

&lt;p&gt;htmlReporter.config().setTheme(Theme.STANDARD);&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9bsklvox2pnpazgsu27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9bsklvox2pnpazgsu27.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For the Dark theme, we can set the theme as DARK.&lt;/p&gt;

&lt;p&gt;htmlReporter.config().setTheme(Theme.DARK);&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a nutshell,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The ExtentHtmlReporter class is used for creating the HTML reports.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ExtentReports class is used for creating the tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ExtentTest class is used for generating the logs in the Extent Report.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So now, we have gone through various configurations that can be made to customize the look of the Extent Reports in Selenium. We can initialize the ExtentHtmlReporter and add the required configurations in the @BeforeTest &lt;a href="https://www.lambdatest.com/blog/complete-guide-on-testng-annotations-for-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG annotation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe3wkh9pch0exyviu8vt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foe3wkh9pch0exyviu8vt.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let us see how to write simple test cases and generate our first Extent Report in Selenium. We shall create test cases that end in three different statuses like Pass, Fail and Skip.&lt;/p&gt;

&lt;p&gt;To create a test, we can use createTest(test_name,test_description) using ExtentReports class.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We have created a simple test test_1 which ends up in PASS by asserting the condition as true.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have created test_2, which would fail as we have passed False in the assetTrue condition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have created test_3, which would be skipped.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhjzcv27gty5g5dqkrpfm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhjzcv27gty5g5dqkrpfm.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get the status of our tests and publish it in our report, we can use the log() method from ExtentTest class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ut1egp29ao44apzu9ns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ut1egp29ao44apzu9ns.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the end, we can use the flush()method, which is used for removing any previous data and creating a new Extent Report in Selenium.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7a27zjwztouag5zrhf9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7a27zjwztouag5zrhf9v.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code snippet for creating simple tests and generating our first extent report:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package testCases;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.configuration.ChartLocation;
import com.aventstack.extentreports.reporter.configuration.Theme;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class DemoTest {

    ExtentHtmlReporter htmlReporter;

    ExtentReports extent;
    //helps to generate the logs in the test report.
    ExtentTest test;

    @BeforeTest
    public void startReport() {
        // initialize the HtmlReporter
        htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") +"/test-output/testReport.html");

        //initialize ExtentReports and attach the HtmlReporter
        extent = new ExtentReports();
        extent.attachReporter(htmlReporter);


        //configuration items to change the look and feel
        //add content, manage tests etc
        htmlReporter.config().setChartVisibilityOnOpen(true);
        htmlReporter.config().setDocumentTitle("Simple Automation Report");
        htmlReporter.config().setReportName("Test Report");
        htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
        htmlReporter.config().setTheme(Theme.STANDARD);
        htmlReporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'");
    }

    @Test
    public void test_1() {
        test = extent.createTest("Test Case 1", "The test case 1 has passed");
        Assert.assertTrue(true);
    }


    @Test
    public void test_2() {
        test = extent.createTest("Test Case 2", "The test case 2 has failed");
        Assert.assertTrue(false);
    }

    @Test
    public void test_3() {
        test = extent.createTest("Test Case 3", "The test case 3 has been skipped");
        throw new SkipException("The test has been skipped");
    }

    @AfterMethod
    public void getResult(ITestResult result) {
        if(result.getStatus() == ITestResult.FAILURE) {
            test.log(Status.FAIL,result.getThrowable());
        }
        else if(result.getStatus() == ITestResult.SUCCESS) {
            test.log(Status.PASS, result.getTestName());
        }
        else {
            test.log(Status.SKIP, result.getTestName());
        }
    }

    @AfterTest
    public void tearDown() {
        //to write or update test information to reporter
        extent.flush();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Test Execution:&lt;/strong&gt;&lt;br&gt;
Upon running the tests, our output console would look similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkmj55yvof3yucsr5xqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkmj55yvof3yucsr5xqh.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the Extent Report in Selenium would be generated and saved in the path provided initially.&lt;/p&gt;

&lt;p&gt;Right-click on the Extent Report 🡪 Open in Browser 🡪 Chrome (Browser of your choice).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzdel87v07h617yszyyqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzdel87v07h617yszyyqo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have successfully generated our first Extent Report in Selenium..!!!&lt;/p&gt;

&lt;p&gt;Here you can see the tests that have been marked with different statuses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkl5dvpz7582fjha7knp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkl5dvpz7582fjha7knp.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re a Java developer, the following &lt;a href="https://www.lambdatest.com/certifications/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=certification" rel="noopener noreferrer"&gt;certification from LambdaTest&lt;/a&gt; can help you improve your skills.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmit51tzqv95lf4fv890.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjmit51tzqv95lf4fv890.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This Selenium Java 101 certification is for anyone who wants to upskill their knowledge of the Java programming language and learn more about the Selenium automation testing.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/vUxfvuAI7kE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: How To Debug Websites Using &lt;a href="https://www.lambdatest.com/blog/debug-websites-using-safari-developer-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Dev Tools in safari&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to generate Extent Reports in Selenium using a cloud grid?
&lt;/h2&gt;

&lt;p&gt;So far, we have written simple test cases to understand the basics of Extent Reports in Selenium. Now let us automate some test cases using Selenium and generate our real automation report. We shall use our &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cloud Selenium Grid&lt;/a&gt; like LambdaTest to execute our tests.&lt;/p&gt;

&lt;p&gt;LambdaTest is a cloud-based &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; platform that supports Selenium Grid, which can be leveraged for running our tests in the grid. Test automation platforms like LambdaTest offer an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ online browsers to perform &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt; effortlessly.&lt;/p&gt;

&lt;p&gt;Here’s a glimpse of LambdaTest cloud Selenium Grid:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/WZlsHlReRww"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can also Subscribe to the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around &lt;a href="https://www.lambdatest.com/automated-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/cypress-ui-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress UI automation&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Also, check this out: &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Browser Test&lt;/a&gt; - Browser &amp;amp; app testing cloud to perform both exploratory and automated testing across 3000+ different browsers, real devices and operating systems.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let us create two classes for our tests, execute them in Cloud Selenium Grid and then finally generate Extent Reports in Selenium for automation.&lt;/p&gt;

&lt;p&gt;Generate your Extent Reports using Cloud Selenium Grid. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest Now!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenarios:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We shall be using the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest playground&lt;/a&gt; for all our tests, which opens the gate to explore various pages to learn automation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test case 1: To verify the title of the webpage&lt;/strong&gt;&lt;br&gt;
Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt;.&lt;br&gt;
Step 2: Get the title of the web page and verify it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test case 2: To enter single input and verify the message displayed&lt;/strong&gt;&lt;br&gt;
Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt;.&lt;br&gt;
Step 2: Click &lt;a href="https://www.lambdatest.com/selenium-playground/simple-form-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Simple Form Demo&lt;/a&gt; under the Input Forms Section.&lt;br&gt;
Step 3: Enter the message in the Enter Message text box.&lt;br&gt;
Step 4: Click the Get Checked Value button.&lt;br&gt;
Step 5: Verify the message displayed in the Your Message section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9h5w9udglgyq63qiu1e8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9h5w9udglgyq63qiu1e8.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test case 3: To enter multiple inputs and verify the value displayed&lt;/strong&gt;&lt;br&gt;
Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt;.&lt;br&gt;
Step 2: Click &lt;a href="https://www.lambdatest.com/selenium-playground/simple-form-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Simple Form Demo&lt;/a&gt; under the Input Forms Section.&lt;br&gt;
Step 3: In the two input Fields section, enter the value of a and b.&lt;br&gt;
Step 4: Click the Get Values button.&lt;br&gt;
Step 5: Verify the value displayed in the Total a+b section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fannkmlpkthta4jlt5gad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fannkmlpkthta4jlt5gad.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test case 4: Verify the alert message on the web page&lt;/strong&gt;&lt;br&gt;
Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt;.&lt;br&gt;
Step 2: Click &lt;a href="https://www.lambdatest.com/selenium-playground/bootstrap-alert-messages-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Bootstrap Alerts&lt;/a&gt; under the Alerts &amp;amp; Modals section.&lt;br&gt;
Step 3: Click Normal Success Message and verify the message displayed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6n6f0x5f2vjf474wu045.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6n6f0x5f2vjf474wu045.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We understood the scenarios to be automated. Let us split them into two different classes — InputFormTest having the first three scenarios and AlertTests having the last test case.&lt;/p&gt;

&lt;p&gt;Before we implement the test cases, let us frame a BaseTest class, which will have the common methods used for initializing and generating Extent Reports in Selenium.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BaseTest class&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package testCases;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.configuration.Theme;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

import java.io.File;
import java.io.IOException;

public class BaseTest {
    public static ExtentHtmlReporter htmlReporter;
    public static ExtentReports extent;
    public static ExtentTest test;
    public static WebDriver driver;

public void initializeReport(){
    htmlReporter =  new ExtentHtmlReporter(System.getProperty("user.dir")+"/Reports/extentReport.html");
    htmlReporter.config().setDocumentTitle("Automation Report");
    htmlReporter.config().setReportName("report");
    htmlReporter.config().setTheme(Theme.STANDARD);
    extent =new ExtentReports();

    extent.attachReporter(htmlReporter);   
}
    public static String CaptureScreenshot(WebDriver driver) throws IOException {
String FileSeparator = System.getProperty("file.separator");
String Extent_report_path = "."+FileSeparator+"Reports";
String ScreenshotPath = Extent_report_path+FileSeparator+"screenshots";

File src = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String screenshotName = "screenshot"+Math.random()+".png";
String screenshotpath = ScreenshotPath+FileSeparator+screenshotName;

FileUtils.copyFile(src,new File(screenshotpath));
return "."+FileSeparator+"screenshots"+FileSeparator+screenshotName;


    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initialize the global variables&lt;/strong&gt;
In the BaseClass, let us initialize the global variables.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkj53gwfjdlelte65xw2s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkj53gwfjdlelte65xw2s.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2- Initialize the extent report&lt;/strong&gt;&lt;br&gt;
We have created a method initializeReport(), which has the steps to initialize and configure Extent Reports in Selenium.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidpxzzltcf2m6uupumsz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidpxzzltcf2m6uupumsz.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- Include common methods&lt;/strong&gt;&lt;br&gt;
In the BaseTest class we can add commonly used methods like capturing screenshots which can be used across various tests.&lt;/p&gt;

&lt;p&gt;Let us frame the automation test cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Class 1 — InputFormTest&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package testCases;

import com.aventstack.extentreports.Status;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class InputFormTest extends BaseTest {
    public String username = "YOUR_USERNAME";
    public String accesskey = "YOUR_ACCESSKEY";
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";

    @BeforeTest
    public void startReport(){
        initializeReport();
    }

    @BeforeMethod
    public void setUp(){
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", "chrome");
        capabilities.setCapability("version", "96.0");
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
        capabilities.setCapability("build", "ExtentReportGeneration");
        capabilities.setCapability("name", "ExtentReportGenerationTest");
        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());

    }
    }

    @Test
    public void verifyTitle(){
        String methodName = new Exception().getStackTrace()[0].getMethodName();
        test = extent.createTest(methodName,"verify_Page_Title");
        test.log(Status.INFO,"starting");
        test.assignCategory("P0");

        driver.get("https://www.lambdatest.com/selenium-playground/");
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        String title ="Selenium Grid Online | Run Selenium Test On Cloud";
        Assert.assertEquals(title,driver.getTitle());
    }

    @Test
    public void SingleInputTest() {
        try {
            String nameofCurrMethod = new Throwable()
                    .getStackTrace()[0]
                    .getMethodName();

            test = extent.createTest(nameofCurrMethod, "TestCase_singleInputTest");
            test.log(Status.INFO,"Starting the tests : "+test.getStatus());
            test.assignCategory("P1");

            driver.get("https://www.lambdatest.com/selenium-playground/");

            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

            //Clicks on the simple form demo option in the selenium playground
            WebElement simpleFormDemo = driver.findElement(By.xpath("//a[text()='Simple Form Demo']"));
            simpleFormDemo.click();

            //Enters the message in the enter message input box
            WebElement messageInputBox = driver.findElement(By.xpath("//input[@id='user-message']"));
            messageInputBox.sendKeys("Hello World");

            //Clicks on Show Message button
            WebElement showMessageButton = driver.findElement(By.xpath("//button[text()='Get Checked value']"));
            showMessageButton.click();

            //Retrieves the entered user message
            WebElement userMessage = driver.findElement(By.xpath("//label[text()='Your Message: ']//..//p"));
            String actualUserText = userMessage.getText();

            Assert.assertEquals(actualUserText,"Hello World", "Expected and actual texts do not match.");

        } catch (Exception e) {

        }

    }

    @Test
    public void MultipleInputTest() {
        try {
            String methodName = new Exception().getStackTrace()[0].getMethodName();
            test = extent.createTest(methodName, "TestCase_MultipleInputTest");
            test.log(Status.INFO,"Starting the tests :");
            test.assignCategory("P0");

            driver.get("https://www.lambdatest.com/selenium-playground/");
            driver.manage().window().maximize();
            driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

            WebElement simpleFormDemo = driver.findElement(By.xpath("//a[text()='Simple Form Demo']"));
            simpleFormDemo.click();

            WebElement firstInputBox = driver.findElement(By.xpath("//input[@id='sum1']"));
            firstInputBox.sendKeys("5");

            WebElement secondInputBox = driver.findElement(By.xpath("//input[@id='sum2']"));
            secondInputBox.sendKeys("10");

            WebElement getTotalButton = driver.findElement(By.xpath("//button[text()='Get values']"));
            getTotalButton.click();

            WebElement userMessage = driver.findElement(By.xpath("//p[@id='addmessage']"));
            String actualUserText = userMessage.getText();

            Assert.assertEquals(actualUserText,"15", "Expected and actual values do not match.");

        } catch (Exception e) {
            System.out.println(e);
        }

    }

    @AfterMethod
    public void end(){
        driver.quit();

    }
    @AfterTest
    public void endReport(){
        extent.flush();

    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Extend BaseTest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initialize the global variables like username and access key for running the tests in cloud Selenium Grid.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqeu02lx44c32nf3a7c0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqeu02lx44c32nf3a7c0.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- @BeforeTest&lt;/strong&gt;&lt;br&gt;
Use the initializeReport() method from BaseTest class for initializing the Extent Report set up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5euqpa379jefsuksnkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5euqpa379jefsuksnkk.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4- @BeforeMethod&lt;/strong&gt;&lt;br&gt;
Define the desired capabilities like browser, browser version, operating system and its version, build and test name for running our tests in cloud Selenium Grid like LambdaTest. In addition to this, we need to specify the grid URL for the tests to be executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8lxfwy1nrj0g1vs5mpyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8lxfwy1nrj0g1vs5mpyh.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5- &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Test annotations must be defined at the start of every test method. If the &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotation is not found on a given test method, then the method will not be executed as a part of the test code.&lt;/p&gt;

&lt;p&gt;Let us implement our test cases.&lt;br&gt;
&lt;strong&gt;Test case 1: To verify the title of the webpage&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Test
public void verifyTitle(){
    String methodName = new Exception().getStackTrace()[0].getMethodName();
    test = extent.createTest(methodName,"verify_Page_Title");
    test.log(Status.INFO,"starting");
    test.assignCategory("P0");

    driver.get("https://www.lambdatest.com/selenium-playground/");
    driver.manage().window().maximize();
    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

    String title ="Selenium Grid Online | Run Selenium Test On Cloud";
    Assert.assertEquals(title,driver.getTitle());
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To get the title of the web page, we can use driver.getTitle(). Then we can use &lt;a href="https://www.lambdatest.com/blog/asserts-in-testng/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG assertions&lt;/a&gt; to compare the actual and expected title on the web page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft5mwvewz1cgfcbd2kxc6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft5mwvewz1cgfcbd2kxc6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The ExtentTest class provides a method to segregate our tests into various categories.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test.assignCategory(category_name);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Let us assign this test case as P0 category.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqx3eiw6763z9ltwz982.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqx3eiw6763z9ltwz982.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test 2: SingleInputTest – This is to verify the form submission and verification of the message in the form&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Upon launching the browser and navigating to the website, we have to click the Simple Input Form. For this, we have first to inspect the Simple Form Demo link and then perform a click.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fto6gr00j5xwbgz11qol9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fto6gr00j5xwbgz11qol9.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be directed to the form page, where we have to provide some value in the input form. We shall inspect the text box web element and enter the value by using the sendkeys(your_message) method. You can go through this article on &lt;a href="https://www.lambdatest.com/blog/how-to-use-selenium-sendkeys/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;sendKeys in Selenium&lt;/a&gt; to know more about sendKeys.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5b12nntxwm7lbmtr05wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5b12nntxwm7lbmtr05wg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After entering the value in the form, we have to click the ‘Get Checked value’ button to display our message, which was entered in the form.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1o1p8ha9u0k9cz63anl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw1o1p8ha9u0k9cz63anl.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we have to fetch the message displayed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxf4ml4r0b7uqkxnbn27o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxf4ml4r0b7uqkxnbn27o.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using assertions let us verify if the actual and expected messages are the same.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fze3sokuh3qjm5p80lgbd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fze3sokuh3qjm5p80lgbd.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Test
public void SingleInputTest() {
    try {
        String nameofCurrMethod = new Throwable().getStackTrace()[0].getMethodName();

        test = extent.createTest(nameofCurrMethod, "TestCase_singleInputTest");
        test.log(Status.INFO,"Starting the tests : "+test.getStatus());
        test.assignCategory("P1");

        driver.get("https://www.lambdatest.com/selenium-playground/");

        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        //Clicks on the simple form demo option in the selenium playground
        W,ebElement simpleFormDemo = driver.findElement(By.xpath("//a[text()='Simple Form Demo']"));
        simpleFormDemo.click();

        //Enters the message in the enter message input box
        WebElement messageInputBox = driver.findElement(By.xpath("//input[@id='user-message']"));
        messageInputBox.sendKeys("Hello World");

        //Clicks on Show Message button
        WebElement showMessageButton = driver.findElement(By.xpath("//button[text()='Get Checked value']"));
        showMessageButton.click();

        //Retrieves the entered user message
        WebElement userMessage = driver.findElement(By.xpath("//label[text()='Your Message: ']//..//p"));
        String actualUserText = userMessage.getText();

        Assert.assertEquals(actualUserText,"Hello World", "Expected and actual texts do not match.");

    } catch (Exception e) {
        System.out.println(e);
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Test 3: MultipleInputTest — This test is to verify if the user is able to enter two input fields in the form.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First we need to click the Simple Form Demo option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7mej7timlmab8l42zlg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7mej7timlmab8l42zlg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This navigates us to the form page and here we have to enter two values in the form for which first we have to identify the web elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc48znifg3m3kkcd0gsmr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc48znifg3m3kkcd0gsmr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon submitting the form, the sum of the values would be displayed and we have to verify the displayed value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1waavjkos4t04j8118hh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1waavjkos4t04j8118hh.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadcsesalxbmkv848yyir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadcsesalxbmkv848yyir.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6- @AfterMethod&lt;/strong&gt;&lt;br&gt;
Here we will add a step to quit the browser&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu59d95uzmupn9nztmr78.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu59d95uzmupn9nztmr78.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7- @AfterTest&lt;/strong&gt;&lt;br&gt;
Here we shall flush the report&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewd6v2vp8pxfqfj28qxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewd6v2vp8pxfqfj28qxf.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we will see AlertTests, where we have added one test which verifies the alert message displayed on the page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Class 2 — AlertTests&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package testCases;

import com.aventstack.extentreports.Status;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class AlertTests extends BaseTest {
    public String username = "YOUR_USERNAME";
    public String accesskey = "YOUR_ACCESSKEY";
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";
    @BeforeTest
    public void startReport() {
        initializeReport();
    }

    @BeforeMethod
    public void setUp() {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", "chrome");
        capabilities.setCapability("version", "96.0");
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
        capabilities.setCapability("build", "ExtentReportGeneration");
        capabilities.setCapability("name", "ExtentReportGenerationTest");
        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

    @Test
    public void clickSimpleAlertAndGetMessage() {
        String methodName = new Exception().getStackTrace()[0].getMethodName();
        String className = new Exception().getStackTrace()[0].getClassName();

        test = extent.createTest(methodName, "Click alert and verify the text");
        test.log(Status.INFO, "starting");
        test.assignCategory("P0");

        driver.get("https://www.lambdatest.com/selenium-playground/");
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement alertMenu = driver.findElement(By.linkText("Bootstrap Alerts"));
        alertMenu.click();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement alert = driver.findElement(By.xpath("//button[text()='Normal Success Message']"));
        alert.click();
        WebElement message = driver.findElement(By.xpath("//div[contains(text(),'normal success message')]"));
        String actualMessage = message.getText();
        String expectedMessage = "I'm a normal success message. To close use the appropriate button.";
        Assert.assertTrue(actualMessage.contains(expectedMessage));

    }


    @AfterMethod
    public void end(){
        driver.quit();

    }
    @AfterTest
    public void endReport(){
        extent.flush();

    }
}ode Walkthrough
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Extend BaseTest.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initialize the global variables like username and access key for running the tests in cloud Selenium Grid.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqp3415nf3cy6dcofbr2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqp3415nf3cy6dcofbr2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- @BeforeTest&lt;/strong&gt;&lt;br&gt;
Use the initializeReport() method from BaseTest class for initializing the Extent Report set up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feac8zwk14t28dy9s5kt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feac8zwk14t28dy9s5kt4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4- @BeforeMethod&lt;/strong&gt;&lt;br&gt;
Define the desired capabilities like browser, browser version, operating system, and its version, build and test name for running our tests in cloud Selenium Grid like LambdaTest. In addition to this, we need to specify the grid URL for the tests to be executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdsmcr2xxevf3slux8bk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdsmcr2xxevf3slux8bk.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5- &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Test annotations must be defined at the start of every test method. If the &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotation is not found on a given test method, then the method will not be executed as a part of the test code.&lt;/p&gt;

&lt;p&gt;Let us implement our test case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsg8yctyu5ocqu6g6clk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsg8yctyu5ocqu6g6clk1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the website has been launched, the Bootstrap Alert webElement has to be identified and clicked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe1dcs6vevy6b2ygtg48a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe1dcs6vevy6b2ygtg48a.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This directs us to the alerts page where we should verify the alert message popped up upon clicking the Normal Success Message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5y18ew1bqvi7lssro90.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5y18ew1bqvi7lssro90.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listener class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TestNG provides the @Listeners annotation, which listens to every event that occurs in a Selenium code. &lt;a href="https://www.lambdatest.com/blog/testng-listeners-in-selenium-webdriver-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG Listeners&lt;/a&gt; are activated either before the test or after the test case. It is an interface that modifies the TestNG behavior. If any event matches an event for which we want the listener to listen then it executes the code, which ultimately results in modifying the default behavior of TestNG.&lt;/p&gt;

&lt;p&gt;If you want to know more about Event Listeners In Selenium WebDriver watch this video to learn how the Listeners “listen” to the event defined in the Selenium script and behave accordingly.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/lwkcuHqHgws"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Test On &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Online Emulator Android&lt;/a&gt; -Test your web and mobile apps on Android Emulators online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are various types of TestNG listeners out of which we shall be using ITestListener in our tests. The ITestListener is an interface which has unimplemented methods by default and we can add lines of code within each method. So whenever a specific event occurs, the code written within that method will be executed. &lt;strong&gt;onTestFailure&lt;/strong&gt; is a method in which this listener will be invoked whenever the test fails.&lt;/p&gt;

&lt;p&gt;Within this method we shall add our code to capture screenshots whenever the test case fails on execution.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Listener;

import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.markuputils.ExtentColor;
import com.aventstack.extentreports.markuputils.MarkupHelper;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import sun.misc.BASE64Decoder;
import testCases.BaseTest;


import java.io.IOException;

import static testCases.BaseTest.CaptureScreenshot;

public class MyListener implements ITestListener {
    public void onTestStart(ITestResult iTestResult) {

    }

    public void onTestSuccess(ITestResult iTestResult) {
        BaseTest.test.log(Status.PASS,MarkupHelper.createLabel(iTestResult.getName().toUpperCase()+" PASS",ExtentColor.GREEN));

    }

    public void onTestFailure(ITestResult iTestResult) {
        BaseTest.test.log(Status.FAIL,iTestResult.getThrowable().getMessage());
        BaseTest.test.log(Status.FAIL,MarkupHelper.createLabel(iTestResult.getName().toUpperCase()+" FAIL",ExtentColor.RED));

        try {
            BaseTest.test.addScreenCaptureFromPath(CaptureScreenshot(BaseTest.driver));
            BaseTest.test.addScreencastFromPath(CaptureScreenshot(BaseTest.driver));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void onTestSkipped(ITestResult iTestResult) {
        BaseTest.test.log(Status.SKIP,MarkupHelper.createLabel(iTestResult.getName().toUpperCase()+" SKIPPED",ExtentColor.PURPLE));

    }

    public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {

    }

    public void onStart(ITestContext iTestContext) {

    }

    public void onFinish(ITestContext iTestContext) {

    }


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a class and implement the ITestListener.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flq8z08yswa4q2zhpcspo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flq8z08yswa4q2zhpcspo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Generate all the implemented methods in it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3vcbfdmyw28hk2vossd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3vcbfdmyw28hk2vossd.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- OnTestSuccess()&lt;/strong&gt;&lt;br&gt;
Once the test execution is complete and the test has been passed, this method will be invoked. We shall add the log included in the Extent Report to mark the test case as passed within this method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthbag2jn1y2yffeai9qr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fthbag2jn1y2yffeai9qr.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MarkHelper is a class that is used for customizing the Extent Reports in Selenium by creating labels for the tests and adding colors to the test status by using ExtentColor enum.&lt;/p&gt;

&lt;p&gt;Here, the tests which are passed will be updated with a label — testname with “PASS”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3idbxl0qxq2h84724v4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3idbxl0qxq2h84724v4g.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, the status of the status will be marked with green color as we have provided ExtentColor.GREEN.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjyfc9kavvf0pkgdaon5h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjyfc9kavvf0pkgdaon5h.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4- OnTestFailure()&lt;/strong&gt;&lt;br&gt;
Once the test execution is complete and the test has failed, this method will be invoked. We shall add the log to be included in the Extent Report to mark the test case as failed within this method. Also, we add code to capture screenshots whenever the test fails.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum1wsc5923enmtv60cxx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum1wsc5923enmtv60cxx.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So when a test fails, logs will be captured with the exceptions and attached to the Extent Report in Selenium.&lt;/p&gt;

&lt;p&gt;The addScreenCaptureFromPath() is a method in ExtentTest class that attaches the captured screenshot in the Extent Report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3doskchf741nz7jozar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3doskchf741nz7jozar.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It takes the image path where the screenshot has been captured as the parameter and attaches the screenshot to the Extent Report in Selenium.&lt;/p&gt;

&lt;p&gt;We can invoke the CaptureScreenshot() method which we have implemented in the BaseTest class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojrx7djv3z7d56g90wja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fojrx7djv3z7d56g90wja.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using getScreenshotAs() method we shall capture the screenshot and save it in the path. This path will be returned to addScreenCaptureFromPath(), which will attach the screenshot in the Extent Report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8alb9dg1614q3xite61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8alb9dg1614q3xite61.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon test execution for the failed tests, you would see the screenshot attached to the respective tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F95vmuzw563bkemy7s8bt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F95vmuzw563bkemy7s8bt.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking on it will show an enlarged view of the screenshot. This will help in analyzing the test failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the TestNG.xml file, we shall add our classes and also the listener class.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite name="Automation tests"&amp;gt;
    &amp;lt;listeners&amp;gt;
        &amp;lt;listener class-name="Listener.MyListener"&amp;gt;&amp;lt;/listener&amp;gt;
    &amp;lt;/listeners&amp;gt;
    &amp;lt;test name="MyTests"&amp;gt;

        &amp;lt;classes&amp;gt;
            &amp;lt;class name="testCases.InputFormTest"/&amp;gt;
            &amp;lt;class name="testCases.AlertTests"&amp;gt;&amp;lt;/class&amp;gt;

        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;


&amp;lt;/suite&amp;gt; &amp;lt;!-- Suite --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Output Console:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjyi3nrndc7u67javbb9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjyi3nrndc7u67javbb9.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud Grid Console&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://accounts.lambdatest.com/login?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=login" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt;, you can see our tests that are executed. You can see four tests that were executed and on clicking each test you can further navigate and verify the test details like the browser and its version, the platform upon which the tests were executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgo2u0qywf65l5lvmtckn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgo2u0qywf65l5lvmtckn.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwccrcs490nahzbdsime.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwccrcs490nahzbdsime.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This section shows the browser and platform configurations in which the tests were executed. As mentioned in the DesiredCapabilities, the tests were run in the Chrome browser of version 96.0 and the Windows operating system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6buqw2mnsgmq56mcili.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6buqw2mnsgmq56mcili.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is also a video recording attached to the tests, which shows the end-to-end flow of our tests. This will help us to analyze when there are test failures. There is also an option to download the captured video.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3l5d7nd3gcli3pdce3u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3l5d7nd3gcli3pdce3u.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extent Reports&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that our tests have been executed in the cloud-based Selenium Grid. Now let’s see if our extent report has been generated.&lt;/p&gt;

&lt;p&gt;Yes, it is…! You can see the report being generated in the mentioned path.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-click the report and open it in your choice of browser.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ovq40uxr033yx8fvm68.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ovq40uxr033yx8fvm68.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Upon opening the Extent Report, you can see the summary of the tests executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1sn9o91ei8zapqro02j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1sn9o91ei8zapqro02j.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- On clicking the category tab, you can see how the tests are categorized into different groups as mentioned in our tests.&lt;/p&gt;

&lt;p&gt;We have assigned 3 tests for the P0 category and 1 test for P1 category. In the category tab, you can visualize the same. In a similar way, we can categorize our tests into Regression, Smoke, Sanity, etc. Thus, categorization will help us to get the test execution summary in a structured way. We can take a quick look at the execution of the tests based on the category by filtering out the specific category in the Extent Report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flwt5onxpcyhehq8poqqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flwt5onxpcyhehq8poqqi.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the view of the dashboard in the Extent Report. This page provides a complete view of the total number of the tests executed, passed tests, failed tests, the total time taken for executing the tests, and also the classification of the tests based on the category.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyyn2b7hr3xunuqhzhr6b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyyn2b7hr3xunuqhzhr6b.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/90F7dePW1vo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/mobile-friendly-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Mobile Friendly Test&lt;/a&gt; with LT Browser!! Building world-class mobile websites with our mobile friendly tester.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to execute parallel tests and generate Extent Reports in Selenium?
&lt;/h2&gt;

&lt;p&gt;As the name suggests, &lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing&lt;/a&gt; is the process of running the test methods/test classes in parallel rather than in sequential order. &lt;a href="https://www.lambdatest.com/blog/parallel-test-execution-in-testng/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Parallel execution in TestNG&lt;/a&gt; is widely preferred in automation as it reduces the time taken for test execution. We can apply parallel execution on method level, class level, test level, and instance level.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Methods&lt;/strong&gt;: This will run the parallel tests on all &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; methods in TestNG.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tests&lt;/strong&gt;: All the test cases present inside the tag will run with this value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Classes&lt;/strong&gt;: All the test cases present inside the classes that exist in the XML will run in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Instances&lt;/strong&gt;: This value will run all the test cases parallel inside the same instance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let us execute our tests in parallel in a cloud-based Selenium Grid like LambdaTest and then generate Extent Reports in Selenium.&lt;/p&gt;

&lt;p&gt;We shall use the two classes — InputFormTest and AlertTests to carry out our parallel execution and then generate the final Extent Report in Selenium.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: 30 Top &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Automated Testing Tools&lt;/a&gt; In 2022&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallel execution in Class level
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Class 1: InputFormTest&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@BeforeTest
public void startReport(){
   initializeReport();
}
@BeforeMethod
public void setUp(){
   DesiredCapabilities capabilities = new DesiredCapabilities();
   capabilities.setCapability("browserName", "chrome");
   capabilities.setCapability("version", "96.0");
   capabilities.setCapability("platform", "win10");
   capabilities.setCapability("build", "ExtentReport");
   capabilities.setCapability("name", "InputFormTestClass");
   try { driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
   } catch (MalformedURLException e) { System.out.println("Invalid grid URL");
   } catch (Exception e) { System.out.println(e.getMessage()); }}
@Test
public void verifyTitle(){
   //same implementation as before
}
@Test
public void SingleInputTest() {
   //same implementation as before
}
@Test
public void MultipleInputTest() {
   //same implementation as before
}
@AfterMethod
public void end(){ driver.quit();};

@AfterTest
public void endReport(){extent.flush(); }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Class 2: AlertTests&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package testCases;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.*;

import java.net.MalformedURLException;
import java.net.URL;

public class AlertTests extends BaseTest {
   public String username = "YOUR_USERNAME";
   public String accesskey = "YOUR_ACCESSKEY";
   public static RemoteWebDriver driver = null;
   public String gridURL = "@hub.lambdatest.com/wd/hub";
   @BeforeTest
   public void startReport() {
       initializeReport();
   }

   @BeforeMethod
   public void setUp() {
       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("browserName", "chrome");
       capabilities.setCapability("version", "96.0");
       capabilities.setCapability("platform", "win10");
       capabilities.setCapability("build", "ExtentReportGeneration");
       capabilities.setCapability("name", "AlertTest");
       try { driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) { System.out.println("Invalid grid URL");
       } catch (Exception e) { System.out.println(e.getMessage());
       } }
   @Test
   public void clickSimpleAlertAndGetMessage() {
      // same implementation as before
   }

   @AfterMethod
   public void end(){ driver.quit(); }

   @AfterTest
   public void endReport(){ extent.flush(); }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
To run classes in parallel, we have mentioned parallel attribute with classes value and thread-count with a specific value. Here I have mentioned thread-count as 3 which means the classes mentioned in TestNG.xml will be executed in parallel in 3 threads.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite name="Automation tests"&amp;gt;
    &amp;lt;listeners&amp;gt;
        &amp;lt;listener class-name="Listener.MyListener"&amp;gt;&amp;lt;/listener&amp;gt;
    &amp;lt;/listeners&amp;gt;
    &amp;lt;test name = "Parallel Tests" parallel = "classes" thread-count="3"&amp;gt;

        &amp;lt;classes&amp;gt;
            &amp;lt;class name="testCases.InputFormTest"/&amp;gt;
            &amp;lt;class name="testCases.AlertTests"&amp;gt;&amp;lt;/class&amp;gt;

        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;


&amp;lt;/suite&amp;gt; &amp;lt;!-- Suite --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Output Console&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here you can see the classes being executed in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rd558scjtvazj63om88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rd558scjtvazj63om88.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, the extent report has been generated for the tests executed in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpf56qe7jbtdiff5nl1cc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpf56qe7jbtdiff5nl1cc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the cloud Selenium Grid, we can visualize the tests executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnio8gw8h5y3r3zp6315c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnio8gw8h5y3r3zp6315c.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: 30 Top &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Tools for Automation Testing&lt;/a&gt; In 2022&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallel execution in method level
&lt;/h2&gt;

&lt;p&gt;We shall use the InputFormTest class which has three test methods. Let us run them in parallel.&lt;/p&gt;

&lt;p&gt;The implementation of the tests remains the same as used before.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package testCases;

import com.aventstack.extentreports.Status;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class InputFormTest extends BaseTest {

   public String username = "YOUR_USERNAME";
   public String accesskey = "YOUR_ACCESSKEY";
   public static RemoteWebDriver driver = null;
   public String gridURL = "@hub.lambdatest.com/wd/hub";

   @BeforeTest
   public void startReport(){
       initializeReport();
   }
   @BeforeMethod
   public void setUp(){
       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("browserName", "chrome");
       capabilities.setCapability("version", "96.0");
       capabilities.setCapability("platform", "win10");
       capabilities.setCapability("build", "ExtentReport");
       capabilities.setCapability("name", "InputFormTestClass");
       try { driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) { System.out.println("Invalid grid URL");
       } catch (Exception e) { System.out.println(e.getMessage()); }}
   @Test
   public void verifyTitle(){
       //same implementation as before
   }
   @Test
   public void SingleInputTest() {
       //same implementation as before
   }
   @Test
   public void MultipleInputTest() {
       //same implementation as before
   }
   @AfterMethod
   public void end(){ driver.quit();};

   @AfterTest
   public void endReport(){extent.flush(); }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
To execute the methods in parallel , we use a parallel attribute with methods value and shall define the thread-count as 3. This will execute the methods in the class in parallel in 3 different threads.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite name="Automation tests"&amp;gt;
    &amp;lt;listeners&amp;gt;
        &amp;lt;listener class-name="Listener.MyListener"&amp;gt;&amp;lt;/listener&amp;gt;
    &amp;lt;/listeners&amp;gt;
    &amp;lt;test name = "Parallel Tests" parallel = "methods" thread-count="3"&amp;gt;

        &amp;lt;classes&amp;gt;
            &amp;lt;class name="testCases.InputFormTest"/&amp;gt;

        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;


&amp;lt;/suite&amp;gt; &amp;lt;!-- Suite --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Test Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the tests are executed, we shall see the methods running in parallel in three threads.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fobtc85lhfn1i47nrgiva.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fobtc85lhfn1i47nrgiva.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extent Report&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the execution is complete, the Extent Report will be generated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8npjb674gptfyw724uc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk8npjb674gptfyw724uc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud Selenium Grid Dashboard&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s4xqa0ccrk2wf2ejzo8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0s4xqa0ccrk2wf2ejzo8.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Test in parallel and cut down test execution time by over 10x. &lt;a href="https://accounts.lambdatest.com/register?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;Try LambdaTest now&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Automation Testing Platform&lt;/a&gt; - Accelerate your release velocity with blazing fast test automation on cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to generate Extent Reports in Selenium using Jenkins?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/what-is-jenkins/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Jenkins&lt;/a&gt; is an open-source DevOps tool that has been popularly used for &lt;a href="https://www.lambdatest.com/blog/what-is-continuous-integration-and-continuous-delivery/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;continuous integration and continuous delivery&lt;/a&gt; processes. It is a Java-based application and platform-independent. It is a build tool used for running builds from the source code repository, running unit tests, and sending the build reports to the respective member or team.&lt;/p&gt;

&lt;p&gt;To get a detailed understanding of Jenkins setup and creating various projects, please go through our blog on &lt;a href="https://www.lambdatest.com/blog/how-to-setup-continuous-integration-with-git-jenkins/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;continuous integration with Jenkins.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Execute &amp;amp; analyse &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; test scripts online. Deploy quality builds faster with 40+ browser versions on cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to generate Extent Reports in Selenium using Jenkins
&lt;/h2&gt;

&lt;p&gt;To generate Extent Reports in Selenium using Jenkins, please follow the below-mentioned steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Login into Jenkins and click Manage Jenkins.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyvlm3nlh8geaz40n2vme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyvlm3nlh8geaz40n2vme.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2- Install the HTML Publisher plugin.&lt;/p&gt;

&lt;p&gt;3- Once installed, you will see the HTML Publisher plugin in the Installed tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feh8hncsxv3qs8ox105g2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feh8hncsxv3qs8ox105g2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4- After installing the plugin, make sure that you restart the Jenkins.&lt;/p&gt;

&lt;p&gt;5- Now click New Item and create a Project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8jnbrikx1xhbdlhped0m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8jnbrikx1xhbdlhped0m.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6- Integrate your GitHub account in the source code management section. This helps us to pull the code from the GitHub account and run the tests in Jenkins.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq555lz0vgv01rpr79jj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq555lz0vgv01rpr79jj.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7- In the Post-Build Actions section, select Publish HTML Reports option under Add Post-Build action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famwj6k3gsrxr71xstzin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famwj6k3gsrxr71xstzin.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8- In this section, provide the folder name where your report would be generated, the name of the Extent Report, and the title of the Extent Report.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm66ab29dg2xdrjqmr9p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm66ab29dg2xdrjqmr9p.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;9- Save the changes.&lt;/p&gt;

&lt;p&gt;10- Click Build Now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqi3w4dr3z2c15xh3oyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqi3w4dr3z2c15xh3oyq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;11- You shall see a job being triggered within the project.&lt;/p&gt;

&lt;p&gt;12- Once the build has been completed, you shall see ExtentReport in the project, as highlighted in the below screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6h049rtqzp55z1be9ew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6h049rtqzp55z1be9ew.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;13- Click on the ExtentReport.&lt;/p&gt;

&lt;p&gt;14- Now the generated Extent Report will be displayed. You can access the Extent Report to analyze the test execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsp88eabe2orczhxwtho5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsp88eabe2orczhxwtho5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Playwright Automation&lt;/a&gt; Tutorial: Getting Started With Playwright Framework&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up..!
&lt;/h2&gt;

&lt;p&gt;In this article on generating Extent Reports in Selenium, we have explored a new topic on integrating a reporting library with our automation framework. Extent Reports have been widely used by the automation testers for generating the test report and sharing it with the stakeholders in the organization.&lt;/p&gt;

&lt;p&gt;As test reports play an important role in automation, it is always better to have a good report that captures the entire test execution summary with graphical representation. Extent Reports not only provide a detailed summary of the executed tests but also provide pie charts depicting the test summary in visual form.&lt;/p&gt;

&lt;p&gt;Moreover, it is very easy to replace any existing reporting tool with Extent Reports in an automation framework. The Extent Report is very simple yet provides extraordinary test reports. I hope this article has been informative and will help you in integrating the reporting tool into your automation framework without any hurdles. Try your hands on these Extent Reports in Selenium, and let me know your feedback on this article. Keep exploring..!&lt;/p&gt;

&lt;p&gt;Happy Testing…!&lt;/p&gt;

</description>
      <category>requestforpost</category>
      <category>gratitude</category>
      <category>howto</category>
      <category>writing</category>
    </item>
    <item>
      <title>How To Scroll a Page Using Selenium WebDriver?</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Wed, 08 Feb 2023 12:40:58 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-scroll-a-page-using-selenium-webdriver-6pf</link>
      <guid>https://forem.com/testmuai/how-to-scroll-a-page-using-selenium-webdriver-6pf</guid>
      <description>&lt;p&gt;Selenium is one of the most widely used test automation frameworks for web automation testing. As far as the framework is concerned, &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; is the most vital component for carrying out automated browser testing. Before deep-diving into how to perform scroll operations (e.g. scroll down, scroll up, horizontal scroll, etc.) using Selenium, let us take a quick look at the hierarchy of classes and interfaces in Selenium WebDriver.&lt;/p&gt;

&lt;p&gt;The Search context is the super interface in Selenium. The Remote WebDriver class implements the methods in WebDriver — search context interfaces, TakeScreenshot, and JavaScriptExecutor interfaces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A-OyXvt6bqBlO2HOh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A-OyXvt6bqBlO2HOh.png" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/how-to-use-javascriptexecutor-in-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;JavaScriptExecutor in Selenium&lt;/a&gt; is used to execute the code written in Javascript within the &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium automation framework&lt;/a&gt;. This interface has two methods namely ExecuteScript and ExecuteAsyncScript which are used to execute the JavaScript code.&lt;/p&gt;

&lt;p&gt;In this blog, we look at you how to perform scrolling actions on any webpage using the JavaScriptExecutor interface. &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; scroll down, scroll to element, horizontal scroll, etc. are some of the common scroll operations that we would be demonstrating using Java.&lt;/p&gt;

&lt;p&gt;Starting your journey with Selenium WebDriver? Check out this step-by-step guide to perform Automation testing using &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To realize Selenium scroll down, Selenium scroll to element, and other relevant operations; we first need to import org.openqa.selenium.JavascriptExecutor package in our code. Shown below is the syntax of JavaScriptExecutor for &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript(Script,Arguments);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that the basic premise is set, let’s deep-dive into how to scroll a web page using Selenium WebDriver for Selenium automation testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll down to the bottom of the page in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;To scroll down to the end of the page using Selenium WebDriver, we first get the height of the page. Once the page height is available with us, we perform a Selenium scroll down till the end of the page. This operation is commonly used in &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; automation testing where page scroll is done to perform relevant operations on the WebElements in the DOM.&lt;/p&gt;

&lt;p&gt;The following code helps you scroll down to the bottom of the page using the JavaScriptExecutor interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    js.executeScript(“window.scrollTo(0, document.body.scrollHeight)”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; Scroll down to the bottom of the webpage using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class ScrollDown {

       public static void main(String[] args) {

           //specify the location of the driver
           System.setProperty("webdriver.chrome.driver","Path_to_chrome_driver\\chromedriver.exe");

           //Initialising the driver
           WebDriver driver = new ChromeDriver();

           //launch the website
           driver.get("https://opensource-demo.orangehrmlive.com/");

           //maximize the window to full screen
           driver.manage().window().maximize();

           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           //identify the locator of the username field
           WebElement username = driver.findElement(By.name("txtUsername"));

           //identify the locator of the password field
           WebElement password = driver.findElement(By.name("txtPassword"));

           username.clear();

           //pass the value of the username
           username.sendKeys("Admin");

           password.clear();

           //pass the value of the password
           password.sendKeys("admin123");

           //identify the locator of the login button
           WebElement loginButton = driver.findElement(By.id("btnLogin"));

           loginButton.click();

           JavascriptExecutor js = (JavascriptExecutor) driver;

           //get the height of the webpage and scroll to the end
           js.executeScript("window.scrollTo(0, document.body.scrollHeight)");

           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shown below is the execution output which indicates that the Selenium scroll down operation was performed successfully using the JavaScriptExecutor interface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ANsustNg8-ygz3R3u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ANsustNg8-ygz3R3u.png" width="778" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll by the visibility of WebElement on the page in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;Any webpage would comprise multiple WebElements where some of the elements would be loaded on an on-demand basis. Before you can perform scroll operations in Selenium, it is essential that the corresponding WebElement is present (or visible) in the DOM.&lt;/p&gt;

&lt;p&gt;This is where the scrollIntoView() interface in JavaScript comes into the picture. This method helps scroll an element into the viewing portion of the window.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // Locate the desired WebElement
    WebElement element = driver.findElement(By.linkText("All Browsers and Devices"));

    js.executeScript("arguments[0].scrollIntoView();", element);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; Scroll by the visibility of an element on the webpage using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class scrollDownByElementVisibility
    {
       public static void main(String[] args) {

           //specify the location of the driver
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");

           //Initialising the driver
           WebDriver driver = new ChromeDriver();

           //launch the website
           driver.get("https://www.lambdatest.com/");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor) driver;

           //specify the WebElement till which the page has to be scrolled
           WebElement element = driver.findElement(By.linkText("All Browsers and Devices"));

           js.executeScript("arguments[0].scrollIntoView();", element);

           driver.close();
       }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above implementation, we navigated to the LambdaTest webpage and performed Selenium scroll down to the point where the WebElement “All Browsers and Devices” is visible.&lt;/p&gt;

&lt;p&gt;Shown below is the execution snapshot which indicates that scroll down in Selenium to the desired WebElement (which is visible) was performed successfully:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A9Qs_82FKRXoU_OGP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2A9Qs_82FKRXoU_OGP.png" width="512" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/cypress-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress cloud&lt;/a&gt; Automation Testing Online&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll down in a page by specified pixels in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;You can also scroll to a particular point by specifying the exact location or coordinates on the page. This can be done using the scrollBy method in JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; js.executeScript(“window.scrollBy(0,3000)”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; Scroll down by the specified pixels on the page using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class scrollDownByPixel
    {
       public static void main(String[] args) {

           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://www.lambdatest.com/");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor) driver;

           //specify the number of pixels the page has to be scrolled
           js.executeScript("window.scrollBy(0,3000)");

           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/types-of-waits-in-selenium/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Implicit wait in Selenium&lt;/a&gt; (for 10 seconds) is used before the scrollBy() method is triggered to scroll to the desired coordinates.&lt;/p&gt;

&lt;p&gt;Read — &lt;a href="https://www.lambdatest.com/blog/how-to-measure-page-load-times-with-selenium/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How To Measure Page Load Time With Selenium&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Shown below is the execution snapshot which indicates that the Selenium scroll down operation was successful:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2ATWtR_2WSRsdLKT6O.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2ATWtR_2WSRsdLKT6O.png" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ATf4TEqtjXFUZOLnQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2ATf4TEqtjXFUZOLnQ.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll the page to the left in a horizontal direction using Selenium Java
&lt;/h2&gt;

&lt;p&gt;When performing &lt;a href="https://www.lambdatest.com/blog/get-started-with-automated-browser-testing/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt; of websites (or web apps), there are times where the page under test has to be scrolled in a horizontal as well as vertical direction. When scrolling in the horizontal direction, you have the option to scroll either to the left or right of the page.&lt;/p&gt;

&lt;p&gt;To scroll to the left of a webpage in a horizontal direction, use the below implementation in the automation test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;js.executeScript(“window.scrollBy(-3000,0)”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration&lt;/strong&gt;: Scroll the webpage to the left in the horizontal direction using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import java.util.concurrent.TimeUnit;

    public class HorizontalLeft
    {
       public static void main(String[] args) {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://www.album.alexflueras.ro/index.php");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor) driver;

           js.executeScript("window.scrollBy(6000,0)");

           try
           {
               Thread.sleep(4000);
           }
           catch (InterruptedException e)
           {
               e.printStackTrace();
           }
           js.executeScript("window.scrollBy(-3000,0)");
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To visualize the movement of the scroll bar in the horizontal left direction, we first scroll to the right and then to the left. By executing the above script, you could see the horizontal scroll bar being scrolled in the left direction of the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AFqGNGkThsVEmBoXK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AFqGNGkThsVEmBoXK.png" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll the page to the right in the horizontal direction using Selenium Java
&lt;/h2&gt;

&lt;p&gt;To scroll the webpage in the horizontal right direction, use the below code in the Selenium Automation Test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; js.executeScript(“window.scrollBy(2000,0)”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; How to scroll to the right in the horizontal direction of the webpage using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class HorizontalRight
    {
       public static void main(String[] args)
       {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://www.album.alexflueras.ro/index.php");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor) driver;
           js.executeScript("window.scrollBy(2000,0)");
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the execution snapshot:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AJmYoChtCiEQqo3Gy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AJmYoChtCiEQqo3Gy.png" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;RUN YOUR JAVA SCRIPT ON SELENIUM GRID 3000+ BROWSERS AND OS: &lt;a href="https://accounts.lambdatest.com/register/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=register" rel="noopener noreferrer"&gt;FREE SIGNUP&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll a webpage in horizontal and vertical directions in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;When scrolling a page, there is flexibility to scroll in horizontal as well as vertical directions. To achieve Selenium scroll in both directions, implement the following code in the automation script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  js.executeScript(“window.scrollBy(6000,50)”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; How to scroll in the horizontal and vertical directions of a page using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class VerticalAndHorizontalScroll
    {
       public static void main(String[] args)
       {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://www.album.alexflueras.ro/index.php");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor) driver;
           js.executeScript("window.scrollBy(6000,50)");
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the execution snapshot:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2Ae4JGpoyQGWOpYugh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2Ae4JGpoyQGWOpYugh.png" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Run Automated &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright Test&lt;/a&gt; Online - Run your Playwright test scripts instantly on 50+ browser and OS combinations using the LambdaTest cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll the scroll bar on a page using Selenium Java
&lt;/h2&gt;

&lt;p&gt;If there is a scroll bar present on a webpage, the user can change value on the scroll bar and move it to the desired value. To realize this in a Selenium automation script, we have to identify the scroll bar WebElement and perform the scrolling action on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demonstration&lt;/strong&gt; — Scroll the scroll bar on the page using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class scrollBar
    {
       public static void main(String[] args)
       {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://the-internet.herokuapp.com/horizontal_slider");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           WebElement element = driver.findElement(By.xpath("//input[@type,'range']"));
           element.sendKeys(Keys.END);
           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shown below is the execution snapshot&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2Aa7AjK2KD8RtFr0l3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2Aa7AjK2KD8RtFr0l3.png" width="800" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Playwright Tutorial: Getting Started With &lt;a href="https://www.lambdatest.com/blog/playwright-framework/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright browser testing&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to scroll a webpage having infinite scrolling in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;You would have come across many websites that have long or infinite scrolling. Pages with infinite scrolling might witness increased engagement since they do not have to go through the tedious task of clicking the ‘Previous’ and ‘Next’ buttons.&lt;/p&gt;

&lt;p&gt;Read — &lt;a href="https://www.lambdatest.com/blog/how-modern-e-commerce-websites-are-built/?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;How Moden E-Commerce Websites Are Built&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can visit &lt;a href="https://the-internet.herokuapp.com/infinite_scroll" rel="noopener noreferrer"&gt;https://the-internet.herokuapp.com/infinite_scroll&lt;/a&gt; to take a brief look at infinite scrolling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; How to scroll web page having infinite length using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class DynamicScroll {
       public static void main(String[] args) {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://the-internet.herokuapp.com/infinite_scroll");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor)driver;

           long intialLength = (long) js.executeScript("return document.body.scrollHeight");

           while(true){
               js.executeScript("window.scrollTo(0,document.body.scrollHeight)");
               try {
                   Thread.sleep(4000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }

               long currentLength = (long) js.executeScript("return document.body.scrollHeight");
               if(intialLength == currentLength) {
                   break;
               }
               intialLength = currentLength;

           }
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shown below is the execution snapshot:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AMW9AgprgJZz1s74o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AMW9AgprgJZz1s74o.png" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Online &lt;a href="https://www.lambdatest.com/safari-browser-for-windows?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Safari Browser For Windows&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Scroll to the top of the page in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;Apart from Selenium scroll down in a page and Selenium scroll to element, scrolling to the top of the page is one of the widely used operations on pages using JavaScriptExecutor interface. There are different ways through which you can scroll to the top of the page.&lt;/p&gt;

&lt;p&gt;To realize this operation, we first perform scroll down in Selenium Java and than perform scroll up the page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; How to scroll up in a page using Selenium WebDriver&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class ScrollToTop {
       public static void main(String[] args) {

           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://opensource-demo.orangehrmlive.com/");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           WebElement username = driver.findElement(By.name("txtUsername"));
           WebElement password = driver.findElement(By.name("txtPassword"));

           username.clear();
           username.sendKeys("Admin");

           password.clear();
           password.sendKeys("admin123");

           WebElement loginButton = driver.findElement(By.id("btnLogin"));

           loginButton.click();


           JavascriptExecutor js = (JavascriptExecutor) driver;
           js.executeScript("window.scrollTo(0, document.body.scrollHeight)");

           try {
               Thread.sleep(3000);
           } catch (InterruptedException e) {
               e.printStackTrace();
           }

           js.executeScript("window.scrollTo(document.body.scrollHeight,0)");

           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Method 2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class ScrollToTop
    {
       public static void main(String[] args)
       {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://opensource-demo.orangehrmlive.com/");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           WebElement username = driver.findElement(By.name("txtUsername"));
           WebElement password = driver.findElement(By.name("txtPassword"));

           username.clear();
           username.sendKeys("Admin");

           password.clear();
           password.sendKeys("admin123");

           WebElement loginButton = driver.findElement(By.id("btnLogin"));

           loginButton.click();

           JavascriptExecutor js = (JavascriptExecutor) driver;
           js.executeScript("window.scrollTo(0, document.body.scrollHeight)");

           try {
               Thread.sleep(5000);
           } catch (InterruptedException e) {
               e.printStackTrace();
           }

           js.executeScript("window.scrollTo(0,0)");

           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Method 3&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class ScrollToTop
    {
       public static void main(String[] args) {

           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://opensource-demo.orangehrmlive.com/");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           WebElement username = driver.findElement(By.name("txtUsername"));
           WebElement password = driver.findElement(By.name("txtPassword"));

           username.clear();
           username.sendKeys("Admin");

           password.clear();
           password.sendKeys("admin123");

           WebElement loginButton = driver.findElement(By.id("btnLogin"));

           loginButton.click();

           JavascriptExecutor js = (JavascriptExecutor) driver;
           js.executeScript("window.scrollTo(0, document.body.scrollHeight)");

           try {
               Thread.sleep(3000);
           } catch (InterruptedException e) {
               e.printStackTrace();
           }
           js.executeScript("window.scrollTo(0,-document.body.scrollHeight)");

           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the execution snapshot that shows how Selenium scroll up in performed on a page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AZLAv4kHtsH2Rusmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2AZLAv4kHtsH2Rusmh.png" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aerzcg8lD0I0G_X18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F0%2Aerzcg8lD0I0G_X18.png" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: Mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Emulator Online&lt;/a&gt; - Test your mobile websites and smartphone apps using our scalable on cloud mobile emulator.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to do scroll horizontally to a specific element on a page in Selenium using Java
&lt;/h2&gt;

&lt;p&gt;The scrollIntoView() method in JavaScript is used in conjunction with the WebElement to which horizontal scroll has to be perfomed. Their combination is passed to the executeScript method to realize scroll to element in Selenium.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  js.executeScript(“arguments[0].scrollIntoView();”, Element);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Demonstration:&lt;/strong&gt; How to scroll to a specific element on a page using using Selenium WebDriver&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    package Demo;

    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;

    import java.util.concurrent.TimeUnit;

    public class HorizontalScroll
    {
       public static void main(String[] args) {
           System.setProperty("webdriver.chrome.driver", "Path_To_ChromeDriver\\chromedriver.exe");
           WebDriver driver = new ChromeDriver();

           driver.get("https://www.album.alexflueras.ro/index.php");
           driver.manage().window().maximize();
           driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

           JavascriptExecutor js = (JavascriptExecutor) driver;
           WebElement Element = driver.findElement(By.xpath("//*[@id=\"a18\"]/img"));

           js.executeScript("arguments[0].scrollIntoView();", Element);

           driver.close();
       }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shown below is the execution snapshot:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2A_mKRwzlPM7MdCFQM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2048%2F0%2A_mKRwzlPM7MdCFQM.png" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Check this out: &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=group&amp;amp;utm_campaign=feb08_sd&amp;amp;utm_term=sd&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; Tutorial: A Complete Guide on Selenium Automation Testing&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we have seen many ways of scrolling in a web page using Selenium Java. Automating the page scroll operation using JavaScriptExecutor interface is one of the widely used operations when it comes to Selenium automation testing. Do let us know how you use Selenium scroll down, Selenium scroll to element, infinite scroll using Selenium WebDriver, etc. for automated browser testing.&lt;/p&gt;

&lt;p&gt;Do feel free to share this article with your friends and colleagues.&lt;/p&gt;

&lt;p&gt;Happy Testing…!&lt;/p&gt;

</description>
      <category>testing</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How To Automate Login Page Using Selenium WebDriver?</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Thu, 10 Mar 2022 12:58:59 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-automate-login-page-using-selenium-webdriver-1924</link>
      <guid>https://forem.com/testmuai/how-to-automate-login-page-using-selenium-webdriver-1924</guid>
      <description>&lt;p&gt;Selenium has always been the most preferred &lt;a href="https://www.lambdatest.com/blog/best-test-automation-frameworks-2021/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation framework&lt;/a&gt; for testing web applications. This open-source framework supports popular programming languages (e.g. Java, JavaScript, Python, C#, etc.), browsers, and operating systems. It can also be integrated with other test automation frameworks like JUnit, TestNG, PyTest, PyUnit, amongst others. As per the &lt;a href="https://www.tricentis.com/state-of-open-source-2020/" rel="noopener noreferrer"&gt;State of open source testing survey&lt;/a&gt;, Selenium is still the king for web automation testing, with 81% of organizations preferring it over other frameworks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp58h5r3q48avx1r3rc6l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp58h5r3q48avx1r3rc6l.png" alt=" " width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When it comes to designing a responsive website, the most important feature is the login page. Login functionality plays a critical role from the security perspective of a user or customer. If the login feature acts up, the other website functionalities might not hold good.&lt;/p&gt;

&lt;p&gt;In this blog on how to automate login page using Selenium WebDriver, we will take a look at different login mechanisms. Along with it, we will also deep dive into how to automate login page using Selenium WebDriver on a &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Grid cloud&lt;/a&gt; like LambdaTest for realizing Selenium automation testing.&lt;/p&gt;

&lt;p&gt;So, let’s get started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Wanna take a sneak peek into The Future of testing? Attend the free &lt;a href="https://www.lambdatest.com/testuconf-2022?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul19_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Testμ 2022&lt;/a&gt; Conf by LambdaTest&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Top Authentication Mechanisms
&lt;/h2&gt;

&lt;p&gt;There are different mechanisms used for login purposes. Some of them are mentioned below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Password-based authentication&lt;/li&gt;
&lt;li&gt;Multi-factor authentication&lt;/li&gt;
&lt;li&gt;Token-based authentication&lt;/li&gt;
&lt;li&gt;Certificate-based authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Based on its type, the implementation of the Login feature would differ. For example, the user would be asked to authenticate his/her identity in different ways to maintain a high-security level on some websites.&lt;/p&gt;

&lt;p&gt;Of all these types, we have the latest authentication type called OAuth2.0 that is designed to allow a web page or application to access resources hosted by another web application on behalf of a user.&lt;/p&gt;

&lt;p&gt;There may be multiple scenarios to be handled while testing web applications. However, out of those tests, the most important scenario that should be handled is the login scenario, without which nothing can be tested in the web application. Therefore, the login page has to be tested effectively to test the website (or application) from usability and security perspectives.&lt;/p&gt;

&lt;p&gt;To test the login feature of any web application with password authentication, we need to fulfil the below requirements before writing the test case.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Valid URL to test the web application&lt;/li&gt;
&lt;li&gt;Valid URL to test the web application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, we will have different steps for handling different kinds of authentication.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For password-based authentication, a combination of username and password has to be passed in the test script&lt;/li&gt;
&lt;li&gt;For multi-factor authentication, different steps for handling the authentication. Once the user has entered his/her credentials in some web pages, he would be prompted to respond to the push notification sent to the mobile. In such cases, we have to automate the steps for handling the notification.&lt;/li&gt;
&lt;li&gt;In OAuth authentication, we need to provide various parameters like client ID, secret client ID, etc. Here, tests have to be designed based on the authentication mechanism used in the web application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are a few scenarios that have to be covered as a part of testing login page using Selenium WebDriver:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Testing with different data combinations like upper case, special character, maximum and minimum length and verifying the error message in case of incorrect usage&lt;/li&gt;
&lt;li&gt;Masking the password in the password field and verifying the password by clicking the Show Password option&lt;/li&gt;
&lt;li&gt;Verifying if the password is stored in an encrypted form&lt;/li&gt;
&lt;li&gt;Verifying if the user can copy and paste the password&lt;/li&gt;
&lt;li&gt;Verifying two-way authentication (or 2FA) through email and mobile in highly secured websites&lt;/li&gt;
&lt;li&gt;Verifying if a logged-in user lands on the login page when the same URL is copied &amp;amp; pasted in a new browser window&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We have seen some high-level scenarios to be tested on the login page. In the next section of this article on how to automate login page using Selenium WebDriver, let us see how to implement and test the login functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Login automation using Selenium WebDriver
&lt;/h2&gt;

&lt;p&gt;Consider the below scenario to test the login feature of the LambdaTest web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Launch the LambdaTest website. (&lt;a href="https://www.lambdatest.com" rel="noopener noreferrer"&gt;https://www.lambdatest.com&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Click Login.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Enter a valid email and password.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; Click the Log in button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Verify the title of the page to ensure that the user has successfully logged into the website.&lt;/p&gt;

&lt;p&gt;Now let’s see how to write our login test in Selenium WebDriver.&lt;/p&gt;

&lt;p&gt;To begin with, we first need to specify the driver’s path and then instantiate the appropriate browser for that driver. Then, depending on our browser choice, we can instantiate the drivers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chrome&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty(“webdriver.chrome.driver”,path_to_browser_driver);
WebDriver driver = new ChromeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Firefox&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty(“webdriver.gecko.driver”,path_to_browser_driver);
WebDriver driver = new FirefoxDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Edge&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty(“webdriver.edge.driver”,path_to_browser_driver);
WebDriver driver =  new EdgeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Internet Explorer&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty(“webdriver.ie.driver”,path_to_browser_driver);
WebDriver driver = new InternetExplorerDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To implement our test scenario, we have to identify four web elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Login button in the main web page to navigate to the login page&lt;/li&gt;
&lt;li&gt;Email&lt;/li&gt;
&lt;li&gt;Password&lt;/li&gt;
&lt;li&gt;Log in&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how our web page looks upon launching the site.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcsay7118ejg3wl55wwxl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcsay7118ejg3wl55wwxl.jpg" alt=" " width="800" height="348"&gt;&lt;/a&gt;&lt;br&gt;
So our first step would be identifying the Login element on the main page. To do that, right-click on the element and click Inspect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87wy9iqw9u6e4im2v4tn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87wy9iqw9u6e4im2v4tn.png" alt=" " width="800" height="348"&gt;&lt;/a&gt;&lt;br&gt;
Upon clicking Inspect, you could see the attributes displayed for the web element in the Elements tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fttuhf6si7ovra8y9224x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fttuhf6si7ovra8y9224x.png" alt=" " width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have eight different locators in Selenium WebDriver that are supported to locate the elements. They are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ID&lt;/li&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;className&lt;/li&gt;
&lt;li&gt;tagName&lt;/li&gt;
&lt;li&gt;linkText&lt;/li&gt;
&lt;li&gt;partialLinkText&lt;/li&gt;
&lt;li&gt;CssSelector&lt;/li&gt;
&lt;li&gt;XPath&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use any one of the &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium locators&lt;/a&gt; to identify the element in our script.&lt;/p&gt;

&lt;p&gt;To identify the login option in the webpage, let us use the &lt;a href="https://www.lambdatest.com/blog/using-link-text-and-partial-link-text-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LinkText locator&lt;/a&gt; in our code and then perform a click action on that element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement login = driver.findElement(By.LinkText(“Login”);
login.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upon navigating to the login page, the user must enter the valid credentials in the Email and Password textbox.&lt;/p&gt;

&lt;p&gt;There are also other options to log in to this web page, i.e., by clicking the Log in with Google and Log in with GitHub. Here, we will consider Log in via Google.&lt;/p&gt;

&lt;p&gt;Upon clicking this you will be asked to log in through your Gmail account that is used in the device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4r82iwnlm6kb3wq7xpv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4r82iwnlm6kb3wq7xpv.png" alt=" " width="518" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you don’t have any accounts, you will have to provide your email and password, and then the notification will be sent to your mobile as it is the first time you have signed in through this device.&lt;/p&gt;

&lt;p&gt;Now let’s proceed with the usual login with email and password.&lt;/p&gt;

&lt;p&gt;To identify the Email and Password web elements, right-click and inspect them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqhmjrzu2n4451r9ifssz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqhmjrzu2n4451r9ifssz.png" alt=" " width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can use id, name, className, or even XPath to identify this web element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ID:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.findElement(By.id(“email”));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Name:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.findElement(By.name(“email”));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;className:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.findElement(By.className(“(//input[@class=’form-control’])[1])”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;XPath:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.findElement(By.xpath(@id=”email”));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the web elements are identified, we can use the &lt;a href="https://www.lambdatest.com/blog/how-to-use-selenium-sendkeys/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium sendKeys() method&lt;/a&gt; to enter the values. But before entering the values, it is always recommended to clear the text fields, which is considered one of the best practices for Selenium test automation. To do that, we can use the clear() method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement email = driver.findElement(By.name(“email”));
email.clear();
email.sendKeys(“your_email”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let us inspect the Password text box.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvewuakxt5cl1zu4nvvec.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvewuakxt5cl1zu4nvvec.png" alt=" " width="800" height="366"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement password = driver.findElement(By.id(“password”));
password.clear();
password.sendKeys(“your_password”));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After entering the credentials, we have to click the Login button.&lt;/p&gt;

&lt;p&gt;To do that, we have to click the Log in button and Inspect it to identify the Log in web element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35jholdmos489myo60wp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F35jholdmos489myo60wp.png" alt=" " width="800" height="136"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement loginButton = driver.findElement(By.id(“login-button”));
loginButton.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have identified all the web elements and methods required to automate login page using Selenium WebDriver in the web application.&lt;/p&gt;

&lt;p&gt;The final step is to get the web page’s title to ensure that the login has been successful and the user has been logged into the web page to perform further actions.&lt;/p&gt;

&lt;p&gt;To get the title of the current web page, we can use the getTitle() method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String actualTitle = driver.getTitle();
System.out.println(“The title of the web page is “ +actualTitle);

String expectedTitle = “Welcome – LambdaTest”;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use the assertions class to compare the results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertEquals(actualTitle, expectedTitle,"The actual and expected title don’t match");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So whenever the titles don’t match, we can handle them by throwing an error message, “The actual and expected title don’t match”.&lt;/p&gt;

&lt;p&gt;And at last, when the test execution is completed, we have to close the browsers used for executing the tests.&lt;/p&gt;

&lt;p&gt;You can close the browser by using two different Selenium WebDriver commands, these are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;close(): Closes the current browser window.&lt;/li&gt;
&lt;li&gt;quit(): Quit all the instantiated browser instances.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.close();  //it closes the single browser window accessed by the WebDriver instance
driver.quit();    //it closes all the open browser windows instances
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/free-online-tools/sha512-hash-calculator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul19_sb&amp;amp;utm_term=sb&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;SHA512 Hash calculator&lt;/a&gt; helps you determine the integrity of your data and challenge hash authentication.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Snippet to automate login page using Selenium WebDriver
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;

import java.util.concurrent.TimeUnit;

public class LoginTest {
    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver",path_of_browser_driver);
        WebDriver driver = new ChromeDriver();

        String url = "https://www.lambdatest.com/";

        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);


        WebElement login = driver.findElement(By.linkText("Login"));
        System.out.println("Clicking on the login element in the main page");
        login.click();

        driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);

        WebElement email = driver.findElement(By.id("email"));
        WebElement password = driver.findElement(By.id("password"));
        WebElement loginButton = driver.findElement(By.id("login-button"));

        email.clear();
        System.out.println("Entering the email");
        email.sendKeys("your_email");

        password.clear();
        System.out.println("entering the password");
        password.sendKeys("your_password");

        System.out.println("Clicking login button");
        loginButton.click();

        String title = "Welcome - LambdaTest";

        String actualTitle = driver.getTitle();

        System.out.println("Verifying the page title has started");
        Assert.assertEquals(actualTitle,title,"Page title doesnt match");

        System.out.println("The page title has been successfully verified");

        System.out.println("User logged in successfully");

        driver.quit();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the tests locally, right-click your class and click Run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpixfgdbtqunaj6nbr2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpixfgdbtqunaj6nbr2a.png" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhpxsyw7d2b7w5ts2xc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhpxsyw7d2b7w5ts2xc3.png" alt=" " width="800" height="305"&gt;&lt;/a&gt;&lt;br&gt;
This certification is for anyone who wants to stay ahead among professionals who are growing their career in test automation using Selenium.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Selenium 101 certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/qx9FPFfJm7E"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You can follow the &lt;a href="https://www.youtube.com/channel/UCCymWVaTozpEng_ep0mdUyw?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials around Selenium testing, Cypress testing, CI/CD, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to automate login page using Selenium Grid cloud?
&lt;/h2&gt;

&lt;p&gt;With a cloud-based &lt;a href="https://www.lambdatest.com/blog/selenium-grid-setup-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Grid&lt;/a&gt; like LambdaTest, you can now run your Selenium automated test cases on a scalable Selenium infrastructure running real browsers and operating systems. Selenium testing tools like LambdaTest allows you to perform cross browser testing on more than 3000+ online browsers and OS combinations.&lt;/p&gt;

&lt;p&gt;To run our tests on Selenium Server, we must first ensure that the prerequisites are met.&lt;/p&gt;

&lt;p&gt;The basic setup for running our tests are mentioned below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1. Create a LambdaTest account&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To begin with, you need to create a &lt;a href="https://accounts.lambdatest.com/dashboard?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Account&lt;/a&gt;. Upon successful account creation, you can sign in to your account and navigate to the LambdaTest Dashboard. Next, go to the LambdaTest Profile section under the Settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F010c6bbk9o4xeg3ipfxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F010c6bbk9o4xeg3ipfxj.png" alt=" " width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can find your username and access token, which can be used in your tests to run them in the LambdaTest grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flrm97b2wyfrwb98z0e6o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flrm97b2wyfrwb98z0e6o.png" alt=" " width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These credentials can be defined in your tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public String username = "YOUR_USERNAME";
public String accesskey = "YOUR_ACCESSKEY";
public static RemoteWebDriver driver = null;
public String gridURL = "@hub.lambdatest.com/wd/hub";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2. Setting up Desired Capabilities&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To run our tests in different browsers and operating systems, we must define the Desired Capabilities&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", browserName);
capabilities.setCapability("version", browser_version);
capabilities.setCapability("platform", platform_name);
capabilities.setCapability("build", buildName);
capabilities.setCapability("name", testName);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In our tests, I have mentioned the desired capabilities for running our tests in a chrome browser with version 93 in Windows 10 operating system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("version", "93.0");
capabilities.setCapability("platform", "win10");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, you can also define the desired capabilities for other browsers and operating systems. If you are not sure of writing your own desired capabilities, still LambdaTest extends its hand to assist you with it!&lt;/p&gt;

&lt;p&gt;You can generate the desired capabilities of different browser and OS combinations using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Desired Capabilities Generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphfd0657fou4ibc93fja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphfd0657fou4ibc93fja.png" alt=" " width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Are you looking to &lt;a href="https://www.lambdatest.com/free-online-tools/shuffle-letters?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul19_sb&amp;amp;utm_term=sb&amp;amp;utm_content=free_tools" rel="noopener noreferrer"&gt;Shuffle letters&lt;/a&gt; online? This tool generates completely random words from a given input by shuffling their letters. Try shuffling now!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippet to automate login page using Selenium Grid cloud
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class LoginTest {
    public String username = "YOUR_USERNAME";
    public String accesskey = "YOUR_ACCESSKEY";
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";

@BeforeClass
public void setUp() throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", "chrome");
        capabilities.setCapability("version", "93.0");
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
        capabilities.setCapability("build", "LoginTest");
        capabilities.setCapability("name", "LoginTestInChrome");
        try {
        driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
        System.out.println("Invalid grid URL");
        } catch (Exception e) {
        System.out.println(e.getMessage());
        }
        }

@Test()
public void test_1() {

        String url = "https://www.lambdatest.com/";

        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);


        WebElement login = driver.findElement(By.linkText("Login"));
        System.out.println("Clicking on the login element in the main page");
        login.click();

        driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);

        WebElement email = driver.findElement(By.id("email"));
        WebElement password = driver.findElement(By.id("password"));
        WebElement loginButton = driver.findElement(By.id("login-button"));

        email.clear();
        System.out.println("Entering the email");
        email.sendKeys("your_email");

        password.clear();
        System.out.println("entering the password");
        password.sendKeys("your_password");

        System.out.println("Clicking login button");
        loginButton.click();

        String title = "Welcome - LambdaTest";

        String actualTitle = driver.getTitle();

        System.out.println("Verifying the page title has started");
        Assert.assertEquals(actualTitle,title,"Page title doesnt match");

        System.out.println("The page title has been successfully verified");

        System.out.println("User logged in successfully");      
    }

    @AfterClass
    public void closeBrowser() {
        driver.close();

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite  name="LoginSuite"&amp;gt;

    &amp;lt;test name="LoginTest" &amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="com.MyTests.LoginTest"&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the LambdaTest dashboard, you can see the test which has run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsivgf500rp5cesuub923.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsivgf500rp5cesuub923.png" alt=" " width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On further navigating inside, you can see the browser and operating system details on which the test had been run, and also, a video recording of the test execution has been attached for debugging purposes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznbnjc9qtl3hf3wof4ox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznbnjc9qtl3hf3wof4ox.png" alt=" " width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to automate login page using Selenium WebDriver in Parallel?
&lt;/h3&gt;

&lt;p&gt;LambdaTest supports more than 3000+ browsers and OS combinations that give the ability to perform Selenium automation testing in parallel on any of these combinations. The combinations can be defined in Desired Capabilities, and the rest all remain the same.&lt;/p&gt;

&lt;p&gt;The Login feature has to be the same across the browsers and operating systems. Running our tests across different platforms will ensure that the functionality is the same across the platforms. The functionality and the user should have the same experience of using the feature on different platforms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5j4rf5l5tfmcow3mxays.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5j4rf5l5tfmcow3mxays.png" alt=" " width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the list of operating systems and &lt;a href="https://www.lambdatest.com/list-of-browsers?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;list of browsers&lt;/a&gt; for running your tests in the grid. In addition to that, we can also run our tests in parallel on different platforms, which will be very effective in reducing Selenium test execution time.&lt;/p&gt;

&lt;p&gt;Let us try running the login tests in two different browsers – Chrome and Firefox.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippet to automate login page using Selenium WebDriver in parallel
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class LoginTest {
    public String username = "YOUR_USERNAME";
    public String accesskey = "YOUR_ACCESSKEY";
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";

@BeforeClass
@Parameters("browser")
public void setUp(String browser) throws Exception {

        DesiredCapabilities capabilities = new DesiredCapabilities();

        if (browser.equalsIgnoreCase("Chrome")) {
                capabilities.setCapability("browserName", "chrome");
                capabilities.setCapability("version", "93.0");
                capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
                capabilities.setCapability("build", "LoginTest");
                capabilities.setCapability("name", "LoginTestInChrome");
        }
        else if (browser.equalsIgnoreCase("Firefox")) {
                capabilities.setCapability("browserName", "Firefox");  //To specify the browser
                capabilities.setCapability("version", "76.0");    //To specify the browser version
                capabilities.setCapability("platform", "win10");      // To specify the OS
                capabilities.setCapability("build", "LoginTest");  //To identify the test
                capabilities.setCapability("name", "LoginTestInFirefox");
        }
        try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
                } catch (Exception e) {
                        System.out.println(e.getMessage());
                }

}

@Test()
public void test_1() {

        String url = "https://www.lambdatest.com/";

        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);


        WebElement login = driver.findElement(By.linkText("Login"));
        System.out.println("Clicking on the login element in the main page");
        login.click();

        driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);

        WebElement email = driver.findElement(By.id("email"));
        WebElement password = driver.findElement(By.id("password"));
        WebElement loginButton = driver.findElement(By.id("login-button"));

        email.clear();
        System.out.println("Entering the email");
        email.sendKeys("your_email”);

        password.clear();
        System.out.println("entering the password");
        password.sendKeys("your_password");

        System.out.println("Clicking login button");
        loginButton.click();

        String title = "Welcome - LambdaTest";

        String actualTitle = driver.getTitle();

        System.out.println("Verifying the page title has started");
        Assert.assertEquals(actualTitle,title,"Page title doesnt match");

        System.out.println("The page title has been successfully verified");

        System.out.println("User logged in successfully");


    }

    @AfterClass
    public void closeBrowser() {
        driver.close();

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite name="TestSuite" parallel="tests"&amp;gt;
    &amp;lt;test name="ChromeBrowserTest"&amp;gt;
        &amp;lt;parameter name="browser" value="Chrome"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="com.infa.dqcloud.testcases.profiling.LoginTest"&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;
    &amp;lt;test name="FirefoxBrowserTest"&amp;gt;
        &amp;lt;parameter name="browser" value="Firefox"/&amp;gt;
        &amp;lt;classes&amp;gt;
           &amp;lt;class name="com.infa.dqcloud.testcases.profiling.LoginTest"&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;

&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the TestNG.xml file, we defined the browser name to execute our tests in different browsers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the output console, you can see that the tests are executed in two different browsers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd8jq27m1k3a9bk922jqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd8jq27m1k3a9bk922jqh.png" alt=" " width="419" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the LambdaTest dashboard, we can see the tests and the browser configuration in which they ran.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqds9km2jno015m8zv9s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvqds9km2jno015m8zv9s.png" alt=" " width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest also enables the users with the freedom to get a clear view of their application’s performance and quality. You can now track the health of your automated test cases by going to &lt;a href="https://analytics.lambdatest.com/test-overview?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Analytics&lt;/a&gt; under the Automation tab. This page allows you to see which tests have failed and lets you download a report for your records.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxypow1jrmlkd9tvwuwjs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxypow1jrmlkd9tvwuwjs.gif" alt=" " width="600" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally..!
&lt;/h2&gt;

&lt;p&gt;The login feature has always been considered the most important feature of any web application. Handling this feature is simple and pretty straightforward. While testing the login functionality, negative case testing contributes equally to the positive case scenario. In this article on how to automate login page using Selenium WebDriver, we have taken the LambaTest web page to test the Login functionality, and we have seen the way to automate the login functionality using Selenium WebDriver. We have also used cloud testing solutions to run the login test in different browsers to check the &lt;a href="https://www.lambdatest.com/feature?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cross browser compatibility&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this article on performing login automation using Selenium is really helpful in implementing a login automation scenario using the Selenium WebDriver. Feel free to provide your feedback in the comment section. Try your hands on this and keep exploring. Happy testing…!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Handle Cookies in Selenium WebDriver</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Fri, 11 Feb 2022 10:45:37 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-handle-cookies-in-selenium-webdriver-3h22</link>
      <guid>https://forem.com/testmuai/how-to-handle-cookies-in-selenium-webdriver-3h22</guid>
      <description>&lt;p&gt;Most of us use online platforms for doing things like online shopping, bill payments, ticket booking, and more. These online platforms (or websites) use cookies to identify whenever there is a new visit. On a lighter note, these are not cookies that you would normally see on your dessert menu 🙂 These are computer cookies (or HTTP cookies or web cookies).&lt;/p&gt;

&lt;p&gt;In simple terms, a cookie is a packet of data received by your machine and sent back to the server without being altered or changed. For example, when you visit any website, cookies are sent to your machine by the website. Since these cookies contain information, it helps the website keep track of your visits or activity (without indulging in your privacy zone).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29d7n6tabwawiz6r6bz6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29d7n6tabwawiz6r6bz6.gif" alt=" " width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Website owners (e.g., online shopping portals) use cookies to keep a tab on your shopping cart while browsing the site. Without the presence of cookies, your shopping cart might become empty (or the item count would reset to zero) each time you open up a new link on the site.&lt;/p&gt;

&lt;p&gt;Selenium cookies can be extensively used for test automation projects for performing cookie-related operations during the process of &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb11_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt;. To realize this requirement, Selenium WebDriver API provides built-in methods for interacting with the cookies.&lt;/p&gt;

&lt;p&gt;By the end of this blog, you would be better positioned to work with Selenium cookies API. We also cover common operations like how to get cookies in Selenium WebDriver, clearing session cookies using Selenium, and more.&lt;/p&gt;

&lt;p&gt;So, let’s get started biting the cookies 🙂&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Cookies
&lt;/h2&gt;

&lt;p&gt;Cookies are usually used to recognize the identity of a user on a website. In simple terms, a cookie is a portion of data that has been sent from a web application and stored in a browser. Whenever a user browses a website, the information about the user and their favorites is stored as a cookie in the form of key-value pairs.&lt;/p&gt;

&lt;p&gt;When the user visits the website again, the information which was stored would be used for identification.&lt;/p&gt;

&lt;p&gt;Below is an example of the LambdaTest website that uses cookies for recognizing the user. In the below screenshot, you can see a small popup that shows the usage of cookies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F944vwog2sc85h2qnjs69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F944vwog2sc85h2qnjs69.png" alt=" " width="800" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name – This field contains the cookie’s name.&lt;/li&gt;
&lt;li&gt;Value – This field contains the cookie’s value.&lt;/li&gt;
&lt;li&gt;Domain – This field contains the hosts that are allowed to receive the cookie.&lt;/li&gt;
&lt;li&gt;Path – This field contains the URL required in the requested URL to send the Cookie header.&lt;/li&gt;
&lt;li&gt;Expires / Max-Age – This field contains the expiration date or the maximum age of the cookie.&lt;/li&gt;
&lt;li&gt;Size – This field contains the size of the cookie.&lt;/li&gt;
&lt;li&gt;HttpOnly – This field indicates whether the cookie has to be used only over HTTP or not.&lt;/li&gt;
&lt;li&gt;Secure – This field indicates that the cookie can only be sent to the server over a secure HTTPS connection (set as true).&lt;/li&gt;
&lt;li&gt;SameSite – This field contains the values (strict or lax) if the cookie is using the experimental SameSite attribute.&lt;/li&gt;
&lt;li&gt;Priority – This field Contains low, medium (default), or high values if the depreciated cookie Priority attribute is enabled.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9imapbn1zy5s12i42wv.png" alt=" " width="800" height="364"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the major functions of website cookies:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tracking the browsing activity of the user&lt;/li&gt;
&lt;li&gt;Remembering the login details of the user&lt;/li&gt;
&lt;li&gt;Tracking the visitor count in a website further helps the website owners identify their unique visitors every day.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;If you are looking for a &lt;a href="https://www.lambdatest.com/free-online-tools/random-character-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul14_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;random character generator&lt;/a&gt;. Here the is best &lt;a href="https://www.lambdatest.com/free-online-tools/random-character-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul14_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;random character generator&lt;/a&gt; you can find.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why handle cookies in Selenium Automation WebDriver
&lt;/h2&gt;

&lt;p&gt;This section unearths the major reasons for using Selenium cookies API in a test automation script. The important aspect of storing cookies and handling them in our automation script is to reduce the time taken for implementation and execution.&lt;/p&gt;

&lt;p&gt;Take the case where we have multiple test cases, and each of them has a prerequisite to log into the website. In such scenarios, we can store the cookies, which can then be used for login purposes. This, in turn, helps in reducing the execution time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction to Selenium Cookies API
&lt;/h3&gt;

&lt;p&gt;Selenium WebDriver provides multiple commands for handling the cookies in a website. These Selenium cookies APIs provide you the required mechanism for interacting and querying the cookies. In Selenium Java, these methods are a part of the org.openqa.selenium.Cookie package.&lt;/p&gt;

&lt;p&gt;Here are the various methods to handle cookies in Selenium that can be accessed using driver.manage() method:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;getCookies()&lt;/td&gt;
&lt;td&gt;It returns the list of all the cookies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getCookieNamed(“Name of Cookie”)&lt;/td&gt;
&lt;td&gt;It returns the cookie that matches the name specified as the argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;addCookie(“Cookie”)&lt;/td&gt;
&lt;td&gt;It creates and adds a new cookie&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;deleteCookie(“Cookie”)&lt;/td&gt;
&lt;td&gt;It deletes a particular cookie&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;deleteCookieName(“Name of Cookie”)&lt;/td&gt;
&lt;td&gt;It deletes the cookie that matches the name specified as the argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;deleteAllCookies&lt;/td&gt;
&lt;td&gt;It deletes all the cookies&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Selenium Cookies API in Action
&lt;/h3&gt;

&lt;p&gt;Now that we have covered the basic aspects of handling cookies in Selenium WebDriver let’s get our hands dirty with some implementation. For demonstrating handling cookies in Selenium, we first use the corresponding Selenium APIs on a local Selenium Grid. If you want to quickly brush up on your Selenium skills, check out our detailed &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb11_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; tutorial.&lt;/p&gt;

&lt;p&gt;Let us use the &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb11_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest home page&lt;/a&gt; in our script to understand the commands used for handling cookies using Selenium WebDriver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. How to Get Cookies in Selenium WebDriver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As mentioned earlier, if you want to get all the stored cookies, you can use the below Selenium WebDriver command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.manage().getCookies()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will retrieve details of all the stored cookies. Below is a simple script to get cookies in Selenium WebDriver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandleCookies {

    public static void main(String args[]) {
 System.setProperty("webdriver.chrome.driver", "ChromeDriver Path");
        WebDriver driver = new ChromeDriver();
        String url ="https://www.lambdatest.com/";
        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        Set&amp;lt;Cookie&amp;gt; cookiesList =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesList) {
            System.out.println(getcookies);
        }
        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cookie information can be stored in a file that can be used for logging into the website without the credentials.&lt;/p&gt;

&lt;p&gt;To get information about a specific cookie, use the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.manage().getCookieNamed(arg0);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is a simple script for getting information about a specific cookie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandleCookies {

    public static void main(String args[]) {
        System.setProperty("webdriver.chrome.driver", "ChromeDriver Path");
        WebDriver driver = new ChromeDriver();
        String url ="https://www.lambdatest.com/";
        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        Cookie cookieValue = driver.manage().getCookieNamed("JSESSIONID");
        System.out.println(cookieValue.getValue());

        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The implementation is self-explanatory; hence, we are not doing a code walkthrough of the same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. How to Add a new Cookie in Selenium WebDriver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To add a new cookie, you can use the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.manage().addCookie(cookieName); //specify the name of the cookie to be added
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before adding a cookie, we have to create it and add the values. Post that, we should pass the name of the newly created cookie.&lt;/p&gt;

&lt;p&gt;Here is a simple script that demonstrates Selenium cookies API for adding a new cookie.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandleCookies {

    public static void main(String args[]) {
        System.setProperty("webdriver.chrome.driver", "ChromeDriver Path");
        WebDriver driver = new ChromeDriver();
        String url ="https://www.lambdatest.com/";
        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        //For creating a new cookie we should pass the name of the cookie and its value
        Cookie cname = new Cookie("myCookie", "12345678999");
        driver.manage().addCookie(cname);

//retrieve the cookies to view the newly added cookie
        Set&amp;lt;Cookie&amp;gt; cookiesList =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesList) {
            System.out.println(getcookies );
        }
        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run the test script, you would be able to see the newly added cookie in the output console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7i2nt1r87k3ut1o1rsu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7i2nt1r87k3ut1o1rsu.png" alt=" " width="800" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. How to Delete a Cookie in Selenium WebDriver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the help of the Selenium WebDriver commands, you can delete a specific cookie or delete all the cookies.&lt;/p&gt;

&lt;p&gt;This command is used for deleting a specific cookie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.manage().deleteCookie(arg0); // Deletes the specific cookie
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command is used for deleting a specific cookie that is matched using its name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.manage().deleteCookieNamed(arg0); // Deletes the specific cookie by its name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command is used for deleting all the cookies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.manage().deleteAllCookies(); // Deletes all the cookies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the same script that demonstrates how to delete a specific cookie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandleCookies {

    public static void main(String args[]) {
        System.setProperty("webdriver.chrome.driver", "ChromeDriver Path");
        WebDriver driver = new ChromeDriver();
        String url ="https://www.lambdatest.com/";
        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        //For creating a new cookie we should pass the name of the cookie and its value
        Cookie cname = new Cookie("myCookie", "12345678999");
        driver.manage().addCookie(cname);

        Set&amp;lt;Cookie&amp;gt; cookiesList =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesList) {
            System.out.println(getcookies );
        }

        //delete the newly created cookie
        driver.manage().deleteCookie(cname);
        Set&amp;lt;Cookie&amp;gt; cookiesListNew =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesListNew) {
            System.out.println(getcookies );
        }
        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The below script demonstrates how to use Selenium cookies API for deleting all the cookies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandleCookies {

    public static void main(String args[]) {
        System.setProperty("webdriver.chrome.driver", "ChromeDriver Path");
        WebDriver driver = new ChromeDriver();
        String url ="https://www.lambdatest.com/";
        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);


        driver.manage().deleteAllCookies();
        Set&amp;lt;Cookie&amp;gt; cookiesListNew =  driver.manage().getCookies();
        cookiesListNew.size();
        System.out.println("The size is "+cookiesListNew);

        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/free-online-tools/random-color-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul14_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Random Color Generator&lt;/a&gt; is an online tool that generates a list of random colors or a single random color in different color code formats: HEX, RGB(A), and HSL.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use Selenium Cookies API on Cloud Selenium Grid
&lt;/h2&gt;

&lt;p&gt;Rather than running Selenium tests on a local Selenium Grid, it is recommended to execute the same on a cloud-based Selenium Grid like LambdaTest. There are numerous benefits of website testing on cloud since it helps achieve much-needed scalability, reliability, and performance.&lt;/p&gt;

&lt;p&gt;LambdaTest provides an online cloud platform to run all your Selenium tests with ease. In addition, it is easy to port the code that uses the local Selenium Grid to LambdaTest’s cloud-based Selenium Grid. Thus, you can make the most out of parallel testing in Selenium by moving the Selenium test automation to a cloud-based Grid.&lt;/p&gt;

&lt;p&gt;Once you have created an account on LambdaTest, note the username &amp;amp; access key available in the profile section of LambdaTest. The combination of username &amp;amp; access key is used for accessing the Remote Selenium Grid of LambdaTest. The capabilities are generated using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb11_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest capabilities generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Shown below is the demonstration of Selenium cookies API with the execution being performed on the LambdaTest Selenium Grid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package Pages;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class HandleCookies
{
    String username = "Your_username"; //Enter your username 
    String accesskey = "Your_accessKey"; //Enter your accesskey

    static RemoteWebDriver driver = null;
    String gridURL = "@hub.lambdatest.com/wd/hub";
    String URL = "https://www.lambdatest.com/";


    @BeforeTest
    @Parameters("browser")
    public void setUp(String browser)throws MalformedURLException  
    {           
        if(browser.equalsIgnoreCase("chrome"))
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("browserName", "chrome");    //To specify the browser
            capabilities.setCapability("version", "70.0");      //To specify the browser version
            capabilities.setCapability("platform", "win10");        // To specify the OS
            capabilities.setCapability("build", "HandlingCookie");               //To identify the test 
            capabilities.setCapability("name", "CookieTest");
            capabilities.setCapability("network", true);        // To enable network logs
            capabilities.setCapability("visual", true);             // To enable step by step screenshot
            capabilities.setCapability("video", true);          // To enable video recording
            capabilities.setCapability("console", true);            // To capture console logs
            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }
        else if(browser.equalsIgnoreCase("Firefox"))
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("browserName", "Firefox");   //To specify the browser
            capabilities.setCapability("version", "76.0");      //To specify the browser version
            capabilities.setCapability("platform", "win10");        // To specify the OS
            capabilities.setCapability("build", " HandlingCookie"); //To identify the test
            capabilities.setCapability("name", " CookieTest");
            capabilities.setCapability("network", true);        // To enable network logs
            capabilities.setCapability("visual", true);             // To enable step by step screenshot
            capabilities.setCapability("video", true);                        // To enable video recording
            capabilities.setCapability("console", true);            // To capture console logs
            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }
    }

    @Test
    public void getCookieInformation()
    {
        System.out.println("=====Getting cookie information Test started======");
        driver.get(URL);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        Set&amp;lt;Cookie&amp;gt; cookiesList =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesList)
        {
            System.out.println(getcookies);
        }
        System.out.println("=====Getting cookie information Test has ended======");         

    }

    @Test
    public void addCookie() {
        boolean status = false;

        System.out.println("=====Adding a cookie Test started======");
        driver.get(URL);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        Cookie cname = new Cookie("myCookie", "12345678999");
        driver.manage().addCookie(cname);

        //retrieve the cookies to view the newly added cookie
        Set&amp;lt;Cookie&amp;gt; cookiesList =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesList) {
            System.out.println(getcookies);
            if(getcookies.getName().equals("myCookie")) {
                status = true;
                System.out.println("The cookie has been added");
            }
            else
                Assert.assertFalse(false, "The cookie hasnt been added");
        }
        System.out.println("=====Adding a new cookie Test has ended======");            
    }

    @Test
    public void deleteSpecificCookie()
    {
        System.out.println("=====Deleting a specific cookie Test started======");
        driver.get(URL);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        Cookie cname = new Cookie("myCookie1", "abcdefj");
        driver.manage().addCookie(cname);

        driver.manage().deleteCookie(cname);
        Set&amp;lt;Cookie&amp;gt; cookiesListNew =  driver.manage().getCookies();
        for(Cookie getcookies :cookiesListNew)
        {
            System.out.println(getcookies );
        }
        System.out.println("=====Deleting a specific cookie Test has ended======");         
    }

    @Test
    public void deleteAllCookies()
    {
        System.out.println("=====Deleting all cookies Test started======");
        driver.get(URL);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        driver.manage().deleteAllCookies();
        Set&amp;lt;Cookie&amp;gt; cookiesListNew =  driver.manage().getCookies();
        cookiesListNew.size();
        System.out.println("The size is "+cookiesListNew);
        System.out.println("=====Deleting all cookies Test has ended======");           

    }
    @AfterTest
    public void tearDown()
    {
        driver.quit();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As seen above, there are no logic changes, and most of the implementation remains unchanged. However, instead of the local Selenium WebDriver, the Remote WebDriver is used for accessing the cloud-based Selenium Grid.&lt;/p&gt;

&lt;p&gt;Since we have four tests in the test suite, we leverage parallel testing in TestNG Selenium to realize parallelism at the Thread level. Shown below is the testng.xml file that runs tests under the &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotation in parallel. In addition, you can check out more TestNG Learning Hub on LambdaTest to gain insights into the TestNG framework.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite name="TestSuite" parallel="tests"&amp;gt;
&amp;lt;test name="ChromeBrowserTest"&amp;gt;
&amp;lt;parameter name="browser" value="chrome"/&amp;gt;
&amp;lt;classes&amp;gt;
&amp;lt;class name="Pages.HandleCookies"&amp;gt;
&amp;lt;/class&amp;gt;
&amp;lt;/classes&amp;gt;
&amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the test execution status of our tests in Eclipse:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7hehs8tyuicu506ewx19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7hehs8tyuicu506ewx19.png" alt=" " width="800" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run this test in the LambdaTest platform, right-click on the testng.xml that you have created in the IDE. Click Run As –&amp;gt; TestNG Suite. With this, the test would be triggered on the LambdaTest platform.&lt;/p&gt;

&lt;p&gt;Shown below is the console output, which indicates that the test execution was successful:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffmtip4128myc9bcaxfp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffmtip4128myc9bcaxfp7.png" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hop on to the &lt;a href="https://automation.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb11_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Automation Dashboard on LambdaTest&lt;/a&gt; for checking the status of the test execution:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bthdj6ac0gq49b34rk3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bthdj6ac0gq49b34rk3.png" alt=" " width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6vf6ctb3ujdgpnieoj8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6vf6ctb3ujdgpnieoj8.png" alt=" " width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this we have demonstrated the major Selenium cookies APIs that can be used for performing operations on the cookies.&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Selenium Java 101 certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/vUxfvuAI7kE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/free-online-tools/random-date-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul14_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Random Date Generator&lt;/a&gt; allows users to randomly select a day, month, and year from any point in time. In addition, users can enter ranges of years they want and pick numbers up to 100.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  It’s a Wrap
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18buipisnxjx1xw3i4r4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18buipisnxjx1xw3i4r4.gif" alt=" " width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To summarize, we deep-dived into the various aspects of cookies primarily used for website owners to track the user's visits or activity. Selenium provides methods (or APIs) using which you can perform various actions on the cookies. We demonstrated how to get cookies in Selenium, how to delete all the cookies in Selenium, how to delete a certain cookie, and more.&lt;br&gt;
Rather than performing Selenium automation testing on a local Selenium Grid, it is recommended to expedite the test execution using a cloud-based Selenium grid like LambdaTest. It lets you run Selenium tests at scale on 3,000+ browsers and operating systems and also lets you &lt;a href="https://www.lambdatest.com/app-test-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar17_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;app test automation&lt;/a&gt; for your mobile apps.&lt;/p&gt;

&lt;p&gt;I hope you find this article very useful and informative. I would love to hear how you use Selenium cookies API for large-scale websites (or web apps). Please feel free to share this blog with your friends and colleagues.&lt;/p&gt;

&lt;p&gt;Happy Testing…!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Use Breakpoints For Debugging In Selenium WebDriver</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Thu, 10 Feb 2022 10:53:21 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-use-breakpoints-for-debugging-in-selenium-webdriver-28ln</link>
      <guid>https://forem.com/testmuai/how-to-use-breakpoints-for-debugging-in-selenium-webdriver-28ln</guid>
      <description>&lt;p&gt;Automation testing is not always a smooth ride. There are cases where the tests would not work as expected, in which cases debugging the test code (or implementation) is the only way out! Debugging issues in tests become even more difficult if the test suite comprises a large number of test methods.&lt;/p&gt;

&lt;p&gt;Like me, many QA engineers would co-relate to this situation when performing &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt;. There could be cases where we need to understand the memory allocation of the objects which cannot be physically seen from the outside. Though the call stack might help in such scenarios, digging deeper into the internals of the test code and/or the automation framework would be super beneficial.&lt;/p&gt;

&lt;p&gt;In all the above scenarios, the process of debugging the code comes into the picture. As an automation engineer, our end goal is to ensure that &lt;a href="https://www.lambdatest.com/blog/selenium-webdriver-tutorial-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver scripts&lt;/a&gt; are executed in the best possible time! However, debugging in Selenium WebDriver is a useful method that should be leveraged effectively whenever there are not-to evident issues in the test code. We can debug Selenium WebDriver in Eclipse IDE when we are executing the test scripts.&lt;/p&gt;

&lt;p&gt;Breaking the normal code flow by inserting breakpoints at strategic points can be used for debugging issues in the test code. In this blog, we deep dive into the essentials of debugging in Selenium WebDriver from a test automation point of view. We would also look at how to debug Selenium WebDriver in Eclipse and IntelliJ, the two popular IDEs for Selenium Java development.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Debugging?
&lt;/h2&gt;

&lt;p&gt;For starters, debugging is a scrutinized process that involves a deep understanding and minute examination of the source code. For example, the code might have failed, or there is a need to take a deep dive into the framework code to understand execution steps in a much better way. I would term this as a major perk of working with an open-source framework like Selenium. The process of debugging involves four main stages, namely identify, isolate, fix and review.&lt;/p&gt;

&lt;p&gt;In the first stage of debugging, we have to identify and understand the issue or failure in the code. This would help us to perform root cause analysis which is one of the key skills of a tester or developer. If one has identified the issue and understood its root cause, it would be easier to develop an approach to resolve the issue.&lt;br&gt;
In the second stage, we have to isolate the portion of the code on which debugging has to be performed. However, it is not necessary to debug every line of code unless required. Therefore, we have to separate the faulty code into smaller chunks and perform debugging.&lt;/p&gt;

&lt;p&gt;Then by understanding the cause of the failure, a fix can be provided to the faulty code, which can be finally reviewed and merged. Of course, it has to be fixed and reviewed so that it doesn't break the other parts of the code.&lt;/p&gt;

&lt;p&gt;Now let's see how to debug Selenium WebDriver in Eclipse with our testing framework, which consists of tests written using Selenium WebDriver and Java.&lt;/p&gt;
&lt;h2&gt;
  
  
  What are Breakpoints in Selenium WebDriver
&lt;/h2&gt;

&lt;p&gt;Akin to software breakpoints, the breakpoints in Selenium WebDriver let us temporarily pause (or stop) the execution of the code. Once the execution is stopped, you can verify the essential elements of the source code.&lt;/p&gt;

&lt;p&gt;When debugging in Selenium WebDriver, breakpoints should be inserted at appropriate places so that the required variable values (and other details) can be checked in detail. Whether you are using the Eclipse IDE or IntelliJ IDE, breakpoints are shown alongside the UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/customevent?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun28_sb&amp;amp;utm_term=sb&amp;amp;utm_content=web_technologies" rel="noopener noreferrer"&gt;CustomEvent&lt;/a&gt; interface represents any DOM event that can carry custom application-defined data.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How To Debug Selenium WebDriver In Eclipse
&lt;/h2&gt;

&lt;p&gt;There are multiple ways to debug the code: having a code walkthrough, getting support from peers, refactoring and restructuring, etc. Debugging is often considered the easiest and most efficient way to debug the issue in the code. Several &lt;a href="https://www.lambdatest.com/blog/best-ide-for-web-development/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;IDEs for web development&lt;/a&gt; provide the option of running the code and inserting breakpoints to debug the source code.&lt;/p&gt;

&lt;p&gt;Since the steps involved in debugging mode look similar in most of the IDEs, you can use the IDE as per your requirements. Before running the tests in Eclipse IDE, set breakpoints at appropriate locations in the source code.&lt;/p&gt;

&lt;p&gt;Breakpoint is usually a point where the code has to be stopped for further examination or understanding while debugging.&lt;/p&gt;

&lt;p&gt;It is usually inserted in front of a single line or multiple lines in the code. By setting or inserting a breakpoint, the code will be executed up to the breakpoint, and the execution will halt once the breakpoint is encountered.&lt;/p&gt;

&lt;p&gt;The breakpoint can be inserted into a single line or multiple lines of code, a method, and even a class.&lt;/p&gt;

&lt;p&gt;Let us see how to insert a breakpoint in Eclipse IDE for debugging in Selenium WebDriver.&lt;/p&gt;
&lt;h2&gt;
  
  
  Inserting Breakpoints
&lt;/h2&gt;

&lt;p&gt;To add a breakpoint in your code, you can follow either of the below ways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Double click in the left side margin&lt;/li&gt;
&lt;li&gt;Perform a right-click in the left side margin and click the Toggle Breakpoint option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9lw75vyiwwdxxff0yq90.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9lw75vyiwwdxxff0yq90.png" alt=" " width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Move to the line where you need to add the breakpoint and then press CTRL+SHIFT+B.&lt;/li&gt;
&lt;li&gt;Move to the line where you need to insert the breakpoint, click the Run menu, and click the Toggle Breakpoint option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzn6ti9xrkjl2bfxiiwv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzn6ti9xrkjl2bfxiiwv.png" alt=" " width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This way, you can add multiple breakpoints in your code. Once the breakpoint is added, you will see a blue circle on the left margin where you tried to insert the breakpoint.&lt;/p&gt;

&lt;p&gt;Now that the breakpoint is added to the source code, it’s time to debug the issue.&lt;/p&gt;

&lt;p&gt;Before running the code, we have to switch to Debug perspective. To do this, navigate to the Windows menu → Perspective → Open Perspective. Here, choose the Debug option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wpaskzz81rcdct3uogk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wpaskzz81rcdct3uogk.png" alt=" " width="511" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run the code, you have to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Select the Java class which has to be run in debug mode. Next, right-click on the class, move to Debug As an option, and click Java Application.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwqzhs3ko4hifs4u4rxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwqzhs3ko4hifs4u4rxp.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Within the class workspace, you can right-click, select Debug As → Java Application.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff502vy7xlllpawjmth03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff502vy7xlllpawjmth03.png" alt=" " width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the Run menu. Navigate to Debug As option and then click Java Application.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8lajc5usdnxagbugxjgj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8lajc5usdnxagbugxjgj.png" alt=" " width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You could also use the shortcut icon to run the code.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkssfj6ea5i6gm6giwng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkssfj6ea5i6gm6giwng.png" alt=" " width="512" height="64"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Click the debug shortcut icon and then move to Debug As → Java Application.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx4l5ghwqu9bc0yk46oq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx4l5ghwqu9bc0yk46oq.png" alt=" " width="512" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also use Keyboard shortcut keys to run the code in debug mode. Press ALT+SHIFT+D. You will see a small popup on the screen like below
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frn2dnxeu3dpak98wkdph.png" alt=" " width="800" height="471"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Press ‘J’ to select Debug Java Application and enter the debug mode.&lt;/p&gt;

&lt;p&gt;If you haven’t switched to the debug perspective view before running the code, you will get a switch notification prompting you to switch to the Debug perspective before running the code. Click Switch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flauh8stc4xv8get49t3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flauh8stc4xv8get49t3n.png" alt=" " width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the code starts running in debug mode.&lt;/p&gt;

&lt;p&gt;The code will be executed, and it stops when it reaches the line where the breakpoint has been added. For example, in my code, I have added breakpoints in lines 39,40,41,42, and 45. So, while running the code, the execution stops at line 39 as it is the first breakpoint in the code and then moves ahead one by one.&lt;/p&gt;

&lt;p&gt;When the breakpoint has been reached, it will be highlighted, as shown in the below screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4vv24z1nopj3g6ak69a2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4vv24z1nopj3g6ak69a2.png" alt=" " width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the execution starts, you could see a window that shows the variables, breakpoints, and expressions tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6uxqwkqyyf9prfepj3a6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6uxqwkqyyf9prfepj3a6.png" alt=" " width="607" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Breakpoints tab shows the lines in which the breakpoint has been added. For example, this shows that the breakpoint has been added in lines 39,40,41,42, and 45 in the Java class brokenLinksCount.&lt;/p&gt;

&lt;p&gt;The Variables tab shows the values being assigned to the variables in the line where the breakpoint has been added.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazat00otjx92phm6sx1m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fazat00otjx92phm6sx1m.png" alt=" " width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To control the execution, we have various shortcut keys in the editor. You could see them under the Run menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwawxb91cxvpqy140kpdh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwawxb91cxvpqy140kpdh.png" alt=" " width="384" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also view them in the submenu bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9u8qgxf7imjwv4r2rwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9u8qgxf7imjwv4r2rwj.png" alt=" " width="548" height="34"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us understand their usage in more detail:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step Into (F5)&lt;/strong&gt; The line where the breakpoint has been added will be executed, followed by the next lines. For example, if the breakpoint has been added to a method, then the control reaches inside the method and debugs the code written within that method.
Sometimes the control might reach deep into the libraries and JDK classes which could be skipped by checking the Use Step Filters option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wn4u6d2lf3fzxl7mjj5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wn4u6d2lf3fzxl7mjj5.png" alt=" " width="800" height="629"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step Over (F6)&lt;/strong&gt; When the control reaches the method where the breakpoint has been added, it steps to the next line after the method without getting into the method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step Return (F7)&lt;/strong&gt; The control returns to the caller of the method once the breakpoint inserted in the method is executed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resume (F8)&lt;/strong&gt; The code is executed until the control reaches the next breakpoint&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terminate (CTRL+F2)&lt;/strong&gt; This is used to terminate the debugging or execution of the code forcibly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skip All Breakpoint (CTRL+ALT+B)&lt;/strong&gt; This is used to skip all the breakpoints inserted in the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to remove the inserted breakpoints?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Either of the following ways can remove the breakpoints added in the code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A simple way to remove the added breakpoint is by double-clicking on the same point where it was added.&lt;/li&gt;
&lt;li&gt;Right-click on the breakpoint and click Disable Breakpoint option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsf0t9uv3hn4horpaviqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsf0t9uv3hn4horpaviqg.png" alt=" " width="351" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A breakpoint can also be removed by pressing SHIFT+double click on the breakpoint&lt;/li&gt;
&lt;li&gt;The other option is by navigating to the Run menu → Remove All Breakpoints to remove all the breakpoints inserted in the code.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fveurojq6bp3ys38gtj7u.png" alt=" " width="381" height="194"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So far, we have seen the process of debugging in Selenium WebDriver by adding breakpoints in Eclipse. The idea of debugging seems to be almost the same across different IDEs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/do-not-track?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun28_sb&amp;amp;utm_term=sb&amp;amp;utm_content=web_technologies" rel="noopener noreferrer"&gt;Do Not Track API&lt;/a&gt; enables websites to query the user's Do Not Track setting via Navigator.doNotTrack . The returned value is a promise that resolves to a boolean, "true" if Do Not Track is enabled, and false otherwise.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How To Debug Selenium WebDriver In IntelliJ
&lt;/h2&gt;

&lt;p&gt;To add breakpoints in IntelliJ, you can choose either of the following ways, namely;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Double-click the left margin of the line in which the breakpoint has to be added.&lt;/li&gt;
&lt;li&gt;Move to the line in which the breakpoint has to be added. Then, navigate to Run menu → Toggle Breakpoint → click Line Breakpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8rb9lo8uisawct37ff0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8rb9lo8uisawct37ff0.png" alt=" " width="512" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the breakpoint has been added, you can see a red circle on the left margin.&lt;br&gt;
Similarly, you can also add a method breakpoint to debug the methods in the framework.&lt;/p&gt;
&lt;h2&gt;
  
  
  Running The Code In Debug mode
&lt;/h2&gt;

&lt;p&gt;Now we can begin to debug the code in our framework.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right-click on the class and click Debug.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60cno4agscc3g7oxe7an.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60cno4agscc3g7oxe7an.png" alt=" " width="397" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also run in the debug mode by clicking the Debug option under the Run menu.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fpywxxz5unsklezerkq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fpywxxz5unsklezerkq.png" alt=" " width="367" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also click the Debug icon on the top right side of the editor.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnou3xw3dwefcs4s7htfj.png" alt=" " width="512" height="162"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After clicking the debug option, you will see various options to control the execution under the Run menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F27nrvft36kh0ywo4e30p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F27nrvft36kh0ywo4e30p.png" alt=" " width="506" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once it reaches the breakpoints and executes the code, you can see tick marks on the breakpoints.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xi4smmvyd76byq4ihgr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7xi4smmvyd76byq4ihgr.png" alt=" " width="512" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To terminate the debug mode, click the red square icon or the Stop option under the Run menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3cnh00q00ca2j0sm3ujz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3cnh00q00ca2j0sm3ujz.png" alt=" " width="478" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you would have got a clear picture of the similarity of the debugging process in different editors.&lt;/p&gt;

&lt;p&gt;Let us understand an example for debugging in Selenium WebDriver.&lt;/p&gt;

&lt;p&gt;Below is the code which was used for demonstrating debugging in Selenium WebDriver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class brokenLinksCount
{
   public static void main(String[] args) throws MalformedURLException, IOException
   {
       String username = "user-name";
       String access_key = "access-key";
       WebDriver driver = null;

       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("build", "[Java] Finding broken links on a webpage using Selenium");
       capabilities.setCapability("name", "[Java] Finding broken links on a webpage using Selenium");
       capabilities.setCapability("platform", "Windows 10");
       capabilities.setCapability("browserName", "Chrome");
       capabilities.setCapability("version","latest");
       capabilities.setCapability("tunnel",false);
       capabilities.setCapability("network",true);
       capabilities.setCapability("console",true);
       capabilities.setCapability("visual",true);
       driver = new RemoteWebDriver(new URL("http://" + username + ":" + access_key + "@hub.lambdatest.com/wd/hub"),
               capabilities);
       System.out.println("Started session");

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

       List&amp;lt;WebElement&amp;gt; list = driver.findElements(By.tagName("a"));
       list.addAll(driver.findElements(By.tagName("img")));
       System.out.println(list.size());

       List&amp;lt;WebElement&amp;gt; activeList = new ArrayList&amp;lt;WebElement&amp;gt;();

       for(int i = 0 ;i&amp;lt;list.size();i++)
       {

           if((list.get(i).getAttribute("href") != null) &amp;amp;&amp;amp; (! (list.get(i).getAttribute("href").contains("javascript"))) )
           {
                   activeList.add(list.get(i));
           }
       }
       System.out.println(activeList.size());

       for(int j = 0;j&amp;lt;activeList.size();j++)
       {
           HttpURLConnection connection = (HttpURLConnection)new URL (activeList.get(j).getAttribute("href")).openConnection();
           connection.connect();
           URL url = connection.getURL();
           System.out.println(url.toString());

           int response_code = connection.getResponseCode();
           System.out.println(activeList.get(j).getText());
           connection.disconnect();
       }      
       driver.close();
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above implementation is used to &lt;a href="https://www.lambdatest.com/blog/broken-links-testing-using-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb10_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;find broken links using Selenium WebDriver.&lt;/a&gt; As demonstrated earlier, we added breakpoints at appropriate places in the test code. Also, the tests are run on a cloud-based Selenium Grid provided by LambdaTest. Porting existing implementation from a local Selenium Grid to a cloud Grid requires minimal effort and also lets you reap benefits offered by parallel testing in Selenium.&lt;/p&gt;

&lt;p&gt;Adding breakpoints at different points in the code will help us understand how each link in the website works and analyze the HTTP response code of each and every link, thereby understanding which link is broken. In addition, we can add breakpoints in for loops for debugging purposes if any link is broken and get to know the failure by getting the response code of the link.&lt;/p&gt;

&lt;p&gt;Using breakpoints in the debugging mode helps analyze issues and fix the failure in the automation framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? with &lt;a href="https://www.lambdatest.com/web-technologies/document-evaluate-xpath?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun28_sb&amp;amp;utm_term=sb&amp;amp;utm_content=web_technologies" rel="noopener noreferrer"&gt;document.evaluate &amp;amp; XPath&lt;/a&gt; you can traverse various nodes in an XML/HTML document using XPath expressions. This allows you to look for specific attributes or content based upon a pattern.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up!
&lt;/h2&gt;

&lt;p&gt;Debugging in Selenium WebDriver is the art of understanding the code flow in a framework, analyzing the issue, and fixing the faulty parts in the test code.&lt;/p&gt;

&lt;p&gt;In this blog, we deep-dived into the importance of debugging in Selenium WebDriver for Selenium automation testing. We also looked at debugging in Selenium WebDriver using Eclipse and IntelliJ IDEs. I hope you have gained good knowledge in the process of debugging in Selenium WebDriver. Now it’s time to add breakpoints in your code and run them in debug mode to understand this process clearly.&lt;/p&gt;

&lt;p&gt;Happy debugging!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Write Test Scripts in Selenium</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Wed, 09 Feb 2022 12:52:23 +0000</pubDate>
      <link>https://forem.com/testmuai/how-to-write-test-scripts-in-selenium-5gck</link>
      <guid>https://forem.com/testmuai/how-to-write-test-scripts-in-selenium-5gck</guid>
      <description>&lt;p&gt;When it comes to &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt;, the first thing that strikes most of our minds is Selenium. Selenium is one of the best automation frameworks and is being widely used by automation testers for writing the tests and designing the automation framework. It is compatible with multiple programming languages like Java, Python, JavaScript, PHP, Ruby, and C#. It also supports running the tests across various browsers like Chrome, Firefox, Microsoft Edge, Internet Explorer, and much more; making it an ideal choice for test automation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrezafng94pcykeyhgp0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhrezafng94pcykeyhgp0.gif" alt=" " width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are new to automation and wondering what is Selenium, you can go through the Selenium WebDriver tutorial, which can help you kickstart the &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium automation&lt;/a&gt; journey.&lt;/p&gt;

&lt;p&gt;In this article, I will take you through the basic configuration of setting up Selenium in your system, and then explain how to write test scripts in Selenium. But, before that, let us briefly introduce Selenium, its components, and its features.&lt;/p&gt;

&lt;p&gt;Let’s begin…!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Selenium?
&lt;/h2&gt;

&lt;p&gt;Selenium is an open-source automation testing framework that has been widely used for automating web applications. It helps carry out tests in multiple browsers, languages and operating systems. In addition, it is compatible with various programming languages like Java, Python, Ruby and C#. Furthermore, it supports various browsers like Chrome, Firefox, Safari, Edge and Opera. It can also be integrated with other automation testing frameworks like JUnit and TestNG.&lt;/p&gt;

&lt;p&gt;When writing this article, Selenium has 22.3k Stars and 6.7k Forks on the &lt;a href="https://github.com/SeleniumHQ/selenium" rel="noopener noreferrer"&gt;Selenium GitHub Page&lt;/a&gt;, which shows its popularity among the developer community.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bgwctb4dg2g4dxowthk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4bgwctb4dg2g4dxowthk.png" alt=" " width="800" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the last few years, there have been a lot of changes in the world of software testing due to the enormous advancements made in modern web automation frameworks. However, more and more enterprises still prefer Selenium for browser testing over other modern frameworks like Cypress because of its rich, mature ecosystem of tools. Therefore, Cypress vs Selenium comparison will help you make the right choice for your project and organization.&lt;/p&gt;

&lt;p&gt;As per the &lt;a href="https://www.tricentis.com/state-of-open-source-2020/" rel="noopener noreferrer"&gt;State of Open Source Survey&lt;/a&gt;, Selenium is still the go-to framework for automated web browser testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyoucq6n77yeo5115f64t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyoucq6n77yeo5115f64t.png" alt=" " width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the components of Selenium?
&lt;/h3&gt;

&lt;p&gt;Selenium is composed of the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selenium IDE&lt;/li&gt;
&lt;li&gt;Selenium WebDriver&lt;/li&gt;
&lt;li&gt;Selenium Grid&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft78g6kgatbjbke6wxl3k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft78g6kgatbjbke6wxl3k.png" alt=" " width="512" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Selenium IDE
&lt;/h4&gt;

&lt;p&gt;Selenium IDE is a browser plugin that lets you write, execute, and debug your Selenium scripts without switching between tools. You can run the IDE from Firefox or Chrome.&lt;br&gt;
Selenium IDE in Selenium 4 is much more than a normal script recorder, as the recorded steps can be exported in any Selenium-supported programming language. This allows an automated test script to be automatically generated from these actions. It can also be used as a playback tool to repeatedly execute those recorded test scenarios.&lt;/p&gt;
&lt;h4&gt;
  
  
  Selenium WebDriver
&lt;/h4&gt;

&lt;p&gt;Selenium WebDriver is a browser-specific driver that provides an interface to write and execute the browser automation scripts for testing web applications. It binds with any popular programming language via browser-specific drivers, providing the ideal environment for automated testing. Selenium can also be integrated with language-supported frameworks, irrespective of whether they are TDD or BDD frameworks.&lt;br&gt;
Automated tests using Selenium WebDriver can also expedite the testing and release processes by integrating with top CI/CD tools like Jenkins, TeamCity, GitLab CI, and more.&lt;/p&gt;
&lt;h4&gt;
  
  
  Selenium Grid
&lt;/h4&gt;

&lt;p&gt;In case you want to leverage the benefits of parallel test execution in Selenium, you should opt for the Selenium Grid. It lets you run Selenium tests at scale on multiple browsers and platforms in parallel. Selenium Grid works by distributing the tests across multiple machines, enabling the testers to execute their tests in an asynchronous manner.&lt;br&gt;
Selenium Grid in Selenium 4 is entirely re-architectured, thereby enabling you to start the Grid in different modes - Standalone mode, Hub &amp;amp; Node mode, and fully-distributed mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/input-placeholder?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun22_sb&amp;amp;utm_term=sb&amp;amp;utm_content=web_technologies" rel="noopener noreferrer"&gt;input placeholder attribute&lt;/a&gt; is used to suggest the expected input information, use a pre-filled placeholder text. The placeholder text will be replaced with actual input when the user interacts with the field.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is new in Selenium 4?
&lt;/h2&gt;

&lt;p&gt;Selenium 4 is the latest version of Selenium. It has come up with advanced features like improvised Selenium IDE and Selenium Grid, &lt;a href="https://www.lambdatest.com/blog/selenium-4-relative-locator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;relative web locators&lt;/a&gt;, and W3C compliance of WebDriver APIs. As of writing this blog, the latest version of Selenium 4 was Selenium 4.10.&lt;/p&gt;

&lt;p&gt;The JSON Wire Protocol which was responsible for the communication between the browser and the test scripts is no longer a part of Selenium 4. W3C in Selenium 4 is responsible for direct communication between the test scripts and browser driver (or browser).&lt;/p&gt;

&lt;p&gt;WebDriver W3C Protocol is the major architectural change in Selenium 4 and WebDriver W3C standardization will result in more stable and less flaky Selenium tests. If you are using Selenium 4, refer to the blog that deep dives into the Selenium 4 WebDriver architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2v3et1y0dxij3bbxgfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2v3et1y0dxij3bbxgfw.png" alt=" " width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Relative locators in Selenium 4 are used to locate the web elements relative to other WebElements on the document (or page). So, for example, we can use relative locators like near(), above(), below(), toRightOf(), and toLeftOf() of a particular element. In addition, significant changes have also been brought in Actions class and FluentWait class in Selenium 4.&lt;/p&gt;

&lt;p&gt;Next, let us get into the prerequisites before we deep-dive into how to write test scripts in Selenium.&lt;/p&gt;

&lt;p&gt;This Selenium WebDriver video tutorial for beginners and professionals will help you learn what’s new in Selenium 4 (Features and Improvements).&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Mmp_FiNIYtQ"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites for running the first Selenium test script
&lt;/h2&gt;

&lt;p&gt;In this section of the blog on how to write test scripts in Selenium, we will see how to configure a few other dependencies before configuring Selenium. To get started with Selenium automation testing, please configure the following components:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Java&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Depending on the operating system (Mac, Windows, or Linux), download JDK with JRE (32 or 64 bit) and then install it.&lt;/li&gt;
&lt;li&gt;Set an environment variable JAVA_HOME with the value to JDK installation location in the system.&lt;/li&gt;
&lt;li&gt;In the Path variable, update the path to the bin folder of the JDK installation folder.&lt;/li&gt;
&lt;li&gt;Ensure successful installation of Java by using the java –version command in the command prompt.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;IDE (Integrated Development Environment)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Depending upon your operating system and preference, you can download and set up an IDE in your system for creating the Selenium tests and running them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drivers and Grid&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For running our tests in different browsers, we have to use drivers. Therefore, choosing the correct driver and version plays a crucial role in successfully executing the tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faf2pvncrjlwuh58x8q9l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faf2pvncrjlwuh58x8q9l.png" alt=" " width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For running tests in the grid, we have to set up Hub and Nodes, and it has to be downloaded from the Selenium official website.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5a24w4d9gnbwgj06an5v.png" alt=" " width="800" height="284"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Configuring and writing test scripts in Selenium
&lt;/h2&gt;

&lt;p&gt;In the previous section of this blog on how to write test scripts in Selenium, we covered the prerequisites for setting and running our tests. Now let us see how to configure and write the first test script in Selenium.&lt;/p&gt;

&lt;p&gt;To configure Selenium in our IDE, we can use Java or Maven. Let us see the steps to configure our project in both ways.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Creating Java Project&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Eclipse.&lt;/li&gt;
&lt;li&gt;Create a new project File🡪 New🡪Project.&lt;/li&gt;
&lt;li&gt;Provide the project name and click Finish.&lt;/li&gt;
&lt;li&gt;Create a new class in the project.&lt;/li&gt;
&lt;li&gt;To write the first test script in Selenium, download the external jars required.&lt;/li&gt;
&lt;li&gt;To add the external jars, right-click on the project 🡪 Build Path 🡪 Configure Build Path and click OK.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Creating Maven Project&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download maven.&lt;/li&gt;
&lt;li&gt;Add MAVEN_HOME system variable and update it with the maven installed folder path.&lt;/li&gt;
&lt;li&gt;Verify successful installation of Maven by using the mvn -version in the command prompt.&lt;/li&gt;
&lt;li&gt;In the pom.xml file, we have to add all the dependencies required to create and run our first Selenium test.&lt;/li&gt;
&lt;li&gt;We need to add the below Selenium dependency to create our tests.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    org.Seleniumhq.Selenium
    Selenium-java
    3.141.59
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;We have the setup and created a project to kickstart our first Selenium test script.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch the LambdaTest webpage &lt;a href="https://accounts.lambdatest.com/login" rel="noopener noreferrer"&gt;https://accounts.lambdatest.com/login&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Enter valid username and password.&lt;/li&gt;
&lt;li&gt;Click the Login button.&lt;/li&gt;
&lt;li&gt;Upon login, verify the page’s title to ensure that the user is successfully logged in and then directed to the home page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To begin with, we need to first specify the driver’s path and then instantiate the appropriate browser for that driver. Then, depending on our choice of browser we can instantiate the drivers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chrome&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty(“webdriver.chrome.driver”,path_to_browser_driver);
WebDriver driver = new ChromeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Firefox&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty(“webdriver.gecko.driver”,path_to_browser_driver);
WebDriver driver = new FirefoxDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Edge&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSystem.setProperty("WebDriver.edge.driver",path_to_browser_driver);
WebDriver driver = new EdgeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Internet Explorer&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.setProperty("WebDriver.ie.driver", path_to_browser_driver);
WebDriver driver=new InternetExplorerDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let us kickstart our scripting. To implement our login scenario, we need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identify the web elements for entering the email, password and click the Login button.&lt;/li&gt;
&lt;li&gt;Right-click on the specific element and click Inspect, which will help us identify that particular element’s locator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are eight basic Selenium locators that are supported to locate the elements. They are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ID&lt;/li&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;className&lt;/li&gt;
&lt;li&gt;tagName&lt;/li&gt;
&lt;li&gt;linkText&lt;/li&gt;
&lt;li&gt;partialLinkText&lt;/li&gt;
&lt;li&gt;CssSelector&lt;/li&gt;
&lt;li&gt;XPath&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our scenario, we need to identify three web elements: email, password, and a login button. Next, right-click on the email web element text box and click Inspect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67hld268082f71nk7cwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67hld268082f71nk7cwb.png" alt=" " width="800" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Elements tab, we can see the different types of attributes that can be used for identifying the web element. Let us take a simple attribute id and use it in our test.&lt;/p&gt;

&lt;p&gt;To enter the value for the email in the text box, we can use sendKeys and pass the value to be entered&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement email = driver.findElement(By.id("email"));
email.clear();
email.sendKeys("abc12@gmail.com");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, moving to the password text box, right-click and click Inspect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhg9u51toiaz92l08xovk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhg9u51toiaz92l08xovk.png" alt=" " width="800" height="31"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use id to locate the web element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement password = driver.findElement(By.id("password"));
password.clear();
password.sendKeys("abc@123");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the login button, right-click the button and click Inspect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ko4xjd39aqcfjkhix6b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ko4xjd39aqcfjkhix6b.png" alt=" " width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the button must be clicked, we have to click() to act on the login button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement loginButton = driver.findElement(By.id("login-button"));
loginButton.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As this is our first script, we have used id as the locator to identify the web page’s web elements.&lt;/p&gt;

&lt;p&gt;Once the user has been successfully logged in, we need to verify the web page’s title to ensure successful login.&lt;/p&gt;

&lt;p&gt;To get the title of the webpage, we have to use the getTitle() method in Selenium.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String actualTitle = driver.getTitle();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To compare the actual and expected title, we can use assertions in TestNG.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String title = "Welcome - LambdaTest";

String actualTitle = driver.getTitle();

Assert.assertEquals(actualTitle,title,"Page title doesnt match");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the tests for Selenium Java automation testing are executed, you need to close the browser instance, which is considered the best practice in finishing the test execution.&lt;/p&gt;

&lt;p&gt;You can close the browser by using two different WebDriver commands, these are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;close(): Closes the current browser window.&lt;/li&gt;
&lt;li&gt;quit(): Quit all the instantiated browser instances.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;driver.close(); // Closes the single browser window accessed by the WebDriver instance
driver.quit();   // Closes all the open browser windows instances
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code snippet for login functionality&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Package MyTests;

import org.openqa.Selenium.By;
import org.openqa.Selenium.WebDriver;
import org.openqa.Selenium.WebElement;
import org.openqa.Selenium.chrome.ChromeDriver;
import org.testng.Assert;

import java.util.concurrent.TimeUnit;

public class SimpleTest {
    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver","C:\\Users\\Shalini\\Downloads\\chromedriver_win\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();

        String url = "https://accounts.lambdatest.com/login";

        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);


        WebElement email = driver.findElement(By.id("email"));
        WebElement password = driver.findElement(By.id("password"));
        WebElement loginButton = driver.findElement(By.id("login-button"));

        email.clear();
        email.sendKeys("abc@gmail.com");

        password.clear();
        password.sendKeys("abc@123");

        loginButton.click();

        String title = "Welcome - LambdaTest";

        String actualTitle = driver.getTitle();

        Assert.assertEquals(actualTitle,title,"Page title doesnt match");


System.out.println("User logged in successfully");


driver.quit();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use our local setup or a cloud grid set up to run the above code. Let me show you both the ways.&lt;/p&gt;

&lt;p&gt;To run in the local Selenium grid, right-click your test class and click Run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kwelhcwaowzows4lll1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kwelhcwaowzows4lll1.png" alt=" " width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will run our tests locally, and you will then see the results in the console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fucqii0avs22aoq7q0hhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fucqii0avs22aoq7q0hhv.png" alt=" " width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/input-search?utm_source=hashnode&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun22_sb&amp;amp;utm_term=sb&amp;amp;utm_content=web_technologies" rel="noopener noreferrer"&gt;Search input type&lt;/a&gt; or  is a very basic text field intended for entering search queries.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running Selenium test scripts on cloud Selenium Grid
&lt;/h2&gt;

&lt;p&gt;In this section, we will see how to write test scripts in Selenium and run it on a cloud Selenium Grid.&lt;/p&gt;

&lt;p&gt;With a cloud-based Selenium Grid like LambdaTest, you can now run your Selenium automated test cases on a scalable Selenium infrastructure running real browsers and operating systems. With more than 3000+ online browser and OS combinations available, &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt; tools like LambdaTest gives you the ability to run your Selenium Automation tests on any of these combinations.&lt;/p&gt;

&lt;p&gt;You can find the complete list of supported browsers and OS by LambdaTest on our list of pages.&lt;/p&gt;

&lt;p&gt;You can leverage the LambdaTest grid to realize cross browser testing through parallel execution of tests either in selenium or &lt;a href="https://www.lambdatest.com/cypress-parallel-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar17_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;cypress parallel testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For example, if you want to run your tests across 30 browsers and the test takes around 100 seconds for execution, it would take around 3000 seconds to complete the entire execution if the test is executed in each browser one by one. On the other hand, if we run our tests in parallel (say in three parallel threads), the total time taken for execution would be 1000 seconds which saves a lot of time!&lt;/p&gt;

&lt;p&gt;Let us run our tests in different browsers using the LambdaTest online Selenium Grid.&lt;/p&gt;

&lt;p&gt;To begin with, you need to create a &lt;a href="https://accounts.lambdatest.com/dashboard?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Account&lt;/a&gt;. Upon successful account creation, you can sign in to your account and navigate to the dashboard. Next, go to the LambdaTest Profile section under the Settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5bn2qvxabuj0xb9up0pn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5bn2qvxabuj0xb9up0pn.png" alt=" " width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can find your username and access token, which can be used in your tests to run them in the LambdaTest grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9t2sbp41qgomigeqbgc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9t2sbp41qgomigeqbgc4.png" alt=" " width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In your test script, you need to specify the username, access key, grid URL, and the website to be tested.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String username = "XXX"; //Enter your username
String accesskey = "XXXXXX"; //Enter your accesskey

static RemoteWebDriver driver;
String gridURL = "@hub.lambdatest.com/wd/hub";
String urlToTest = " https://accounts.lambdatest.com/login”;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step is to define the desired capabilities of our browser and the operating system in which our tests have to be run. We have to define the browser, its version and operating system under desired capabilities which can be done as below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("build", "your build name");
    capabilities.setCapability("name", "your test name");
    capabilities.setCapability("platform", "Windows 10");
    capabilities.setCapability("browserName", "Chrome");
    capabilities.setCapability("version","93.0");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have mentioned the desired capabilities for running our tests in a chrome browser with version 93 in Windows 10 operating system. Similarly, you can also define the desired capabilities for other browsers and operating systems. If you are not sure of writing your own desired capabilities, still LambdaTest extends its hand to assist you with it!&lt;/p&gt;

&lt;p&gt;You can generate the desired capabilities of different browser and OS combinations using the LambdaTest Desired Capabilities Generator.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8i2at793q6j3k1683u82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8i2at793q6j3k1683u82.png" alt=" " width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can select a specific operating system, browser, and its version and resolution and generate the desired capabilities for the selected configuration in the right-side panel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flnalvv62dn6rhff1k0m6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flnalvv62dn6rhff1k0m6.png" alt=" " width="698" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also specify the Selenium version and enable the headless mode option in our desired capabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0llannuaj0f2ji8ajbv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0llannuaj0f2ji8ajbv.png" alt=" " width="800" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under advanced configuration, you can set some additional parameters in the desired capabilities.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enable logs to be captured in the tests.&lt;/li&gt;
&lt;li&gt;Set the timezone.&lt;/li&gt;
&lt;li&gt;Enable capture for the screenshot.&lt;/li&gt;
&lt;li&gt;Enable video recording of the tests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1eay4g2ua08bxsel738.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1eay4g2ua08bxsel738.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let us start implementing our tests in the LambdaTest grid. We shall use the same login test logic used earlier.&lt;/p&gt;

&lt;p&gt;Let us run our login test in two different browsers – Chrome and Firefox. Use the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb09_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Desired Capabilities Generator&lt;/a&gt; for setting the desired capabilities in our tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code snippet&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package MyTests;

import org.openqa.Selenium.By;
import org.openqa.Selenium.WebDriver;
import org.openqa.Selenium.WebElement;
import org.openqa.Selenium.chrome.ChromeDriver;
import org.openqa.Selenium.remote.DesiredCapabilities;
import org.openqa.Selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class Demo {

    String username = "XXXX"; //Enter your username
    String accesskey = "XXX"; //Enter your accesskey

    static RemoteWebDriver driver;
    String gridURL = "@hub.lambdatest.com/wd/hub";
    String urlToTest = "https://accounts.lambdatest.com/login";

    @BeforeTest
    @Parameters("browser")
    public void setUp(String browser)throws MalformedURLException
    {
        if(browser.equalsIgnoreCase("Chrome"))
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("browserName", "chrome");   //To specify the browser
            capabilities.setCapability("version", "93.0");    //To specify the browser version
            capabilities.setCapability("platform", "win10");      // To specify the OS
            capabilities.setCapability("build", "LambdaTestApp");               //To identify the test
            capabilities.setCapability("name", "Test_Chrome");
            capabilities.setCapability("network", true);   // To enable network logs
            capabilities.setCapability("visual", true);          // To enable step by step screenshot
            capabilities.setCapability("video", true);       // To enable video recording
            capabilities.setCapability("console", true);         // To capture console logs
            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }

        else if(browser.equalsIgnoreCase("Firefox"))
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("browserName", "Firefox");  //To specify the browser
            capabilities.setCapability("version", "76.0");    //To specify the browser version
            capabilities.setCapability("platform", "win10");      // To specify the OS
            capabilities.setCapability("build", "LambdaTestApp");  //To identify the test
            capabilities.setCapability("name", "Test_Firefox");
            capabilities.setCapability("network", true);      // To enable network logs
            capabilities.setCapability("visual", true);          // To enable step by step screenshot
            capabilities.setCapability("video", true);                          // To enable video recording
            capabilities.setCapability("console", true);         // To capture console logs
            try {
                driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
            } catch (MalformedURLException e) {
                System.out.println("Invalid grid URL");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }
    }


    @Test
    public void Login() {

       driver.get(urlToTest);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement email = driver.findElement(By.id("email"));
        email.clear();
        email.sendKeys("XXX@gmail.com");

        WebElement password = driver.findElement(By.id("password"));
        password.clear();
        password.sendKeys("XXX@123");

        WebElement loginButton = driver.findElement(By.id("login-button"));
        loginButton.click();
        driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);
        String title = "Welcome - LambdaTest";

        String actualTitle = driver.getTitle();

        Assert.assertEquals(actualTitle,title,"Page title doesnt match");

        System.out.println("User logged in successfully");

    }

    @AfterTest
    public void tearDown() {
        driver.quit();
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!--?xml version="1.0" encoding="UTF-8"?--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the test in the LambdaTest grid, right-click on the TestNG.xml file and click Run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fknvp2k7at838q36ielii.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fknvp2k7at838q36ielii.png" alt=" " width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can see the tests running in two different browsers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8z6xd6d3qs0m74cggbyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8z6xd6d3qs0m74cggbyc.png" alt=" " width="478" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So how do we know that the tests ran in the LambdaTest grid?&lt;/p&gt;

&lt;p&gt;Go to the LambdaTest account and navigate to the Automation page. Here you can see the build name you provided in your tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Farrqpcnptxuu4mae5vhl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Farrqpcnptxuu4mae5vhl.png" alt=" " width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On further navigation, you will run the tests in the grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkydb7zhaj6ft9rzhqngm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkydb7zhaj6ft9rzhqngm.png" alt=" " width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see the tests run in the grid and the video recording captured during the test execution. This will help us identify the exact issue in case of any test failure.&lt;/p&gt;

&lt;p&gt;In the tests listed, we can see the browser and the OS configuration used for running them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to perform parallel testing on cloud Selenium Grid
&lt;/h2&gt;

&lt;p&gt;In this section, we will see how to write test scripts in Selenium and run it parallely over a cloud Selenium Grid.&lt;/p&gt;

&lt;p&gt;Parallel testing is a way of simultaneously carrying out the test execution in various environments. This helps reduce the total execution time and efforts, thereby meeting the quality of the code as well. Moreover, it helps in covering wider compatibility in a very short duration.&lt;/p&gt;

&lt;p&gt;Let us understand how to run our tests in parallel in the cloud Selenium Grid.&lt;/p&gt;

&lt;p&gt;To run our tests in parallel we will use TestNG in this article.&lt;/p&gt;

&lt;p&gt;To use TestNG we need to add the dependency in the pom.xml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    org.testng
    testng
    6.14.3
    test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding the dependency, we have to create a TestNG.xml file that can be used to customize the execution of the tests. This file helps in parameterizing the tests, grouping the tests, and running the tests in parallel in TestNG. As our goal is to run our tests in parallel, we will add the parallel attribute in this file to execute the tests in different threads in parallel.&lt;/p&gt;

&lt;p&gt;Moreover, we can have different values for this parallel attribute, each having its purpose.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;classes – it runs all the tests inside the classes in parallel&lt;/li&gt;
&lt;li&gt;methods – it runs all the methods with &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotation in parallel&lt;/li&gt;
&lt;li&gt;tests – it runs all the tests within the  tag in parallel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So now you must have got some idea on the parallel test execution. To run the tests in parallel, we have to define the threads used for the execution. We can define the thread count in the TestNG.xml file as below.&lt;/p&gt;

&lt;p&gt;So the above line will run the methods annotated with &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; in the suite in 4 parallel threads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running test methods in parallel in cloud Selenium Grid
&lt;/h3&gt;

&lt;p&gt;In this section of the article on how to write test scripts in Selenium, let us create two test methods in a class and run them parallel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test 1: Login to LambdaTest website&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch LambdaTest website&lt;/li&gt;
&lt;li&gt;Enter valid credentials&lt;/li&gt;
&lt;li&gt;Click Login button&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Test 2: Get the title of the LambdaTest playground website&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch LambdaTest playground website &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Print the title of the webpage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Code snippet&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package MyTests.ParallelTests;

import org.openqa.Selenium.By;
import org.openqa.Selenium.WebElement;
import org.openqa.Selenium.remote.DesiredCapabilities;
import org.openqa.Selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class MethodsInParallel {
   public String username = "YOUR_USERNAME";
   public String accesskey = "YOUR_ACCESSKEY";
   public RemoteWebDriver driver = null;
   public String gridURL = "@hub.lambdatest.com/wd/hub";

   @BeforeMethod
   @Parameters(value={"browser"})
   public void setUp(String browser) throws Exception {
       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("browserName", browser);
       capabilities.setCapability("version", "97.0");
       capabilities.setCapability("platform","win10" ); // If this cap isn't specified, it will just get the any available one
       capabilities.setCapability("build", "ParallelExecution_TestMethods");
       capabilities.setCapability("name", "ParallelExecution_TestMethods");
       capabilities.setCapability("network", true); // To enable network logs
       capabilities.setCapability("visual", true); // To enable step by step screenshot
       capabilities.setCapability("video", true); // To enable video recording
       capabilities.setCapability("console", true); // To capture console logs
       try {
           driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) {
           System.out.println("Invalid grid URL");
       } catch (Exception e) {
           System.out.println(e.getMessage());
       }
   }


   @Test
   public void login() {
       String url = "https://accounts.lambdatest.com/login";

       driver.get(url);
       driver.manage().window().maximize();
       driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

       WebElement email = driver.findElement(By.id("email"));
       email.clear();
       email.sendKeys("abc@gmail.com");

       WebElement password = driver.findElement(By.id("password"));
       password.clear();
       password.sendKeys("abc@123");

       WebElement loginButton = driver.findElement(By.id("login-button"));
       loginButton.click();
   }

   @Test
   public void printTitle() {
       String urlToTest = "https://www.lambdatest.com/selenium-playground/";
       driver.get(urlToTest);
       driver.manage().window().maximize();
       String title = driver.getTitle();

       System.out.println("The title of the page is ==&amp;amp;gt; " +title);

   }

   @AfterMethod
   public void tearDown() throws Exception {
       if (driver != null) {
           driver.quit();
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**TestNG.xml&lt;/p&gt;

&lt;p&gt;**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!--?xml version="1.0" encoding="UTF-8"?--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the TestNG.xml file, we set the parallel attribute with methods and the thread count as two, which will now run the test methods in parallel in 2 threads.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xjbf4w390py3auc7nh4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xjbf4w390py3auc7nh4.png" alt=" " width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you run the tests, you will see the two tests running in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftiz5yrznswx33jdcgg7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftiz5yrznswx33jdcgg7g.png" alt=" " width="800" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/link-icon-png?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun22_sb&amp;amp;utm_term=sb&amp;amp;utm_content=web_technologies" rel="noopener noreferrer"&gt;PNG favicons&lt;/a&gt; are preferred to utilize icons to identify a webpage or site. While all browsers accept the '.ico' format.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Running test classes in parallel in cloud Selenium Grid
&lt;/h3&gt;

&lt;p&gt;In this section of the article on how to write test scripts in Selenium, let us now see how to run the test classes in parallel using cloud Selenium Grid.&lt;/p&gt;

&lt;p&gt;First, we have to create two test classes containing a test method. Let us use the same example as used in the previous section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test class 1: Login&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package MyTests.ClassInParallel;

import org.openqa.Selenium.By;
import org.openqa.Selenium.WebElement;
import org.openqa.Selenium.remote.DesiredCapabilities;
import org.openqa.Selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class ClassA {
   public String username = "YOUR_USERNAME";
   public String accesskey = "YOUR_ACCESSKEY";
   public RemoteWebDriver driver = null;
   public String gridURL = "@hub.lambdatest.com/wd/hub";

   @BeforeMethod
   @Parameters(value={"browser"})
   public void setUp(String browser) throws Exception {
       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("browserName", browser);
       capabilities.setCapability("version", "97.0");
       capabilities.setCapability("platform","win10" ); // If this cap isn't specified, it will just get the any available one
       capabilities.setCapability("build", "ParallelExecution_TestClassA");
       capabilities.setCapability("name", "ParallelExecution_TestClassA");
       capabilities.setCapability("network", true); // To enable network logs
       capabilities.setCapability("visual", true); // To enable step by step screenshot
       capabilities.setCapability("video", true); // To enable video recording
       capabilities.setCapability("console", true); // To capture console logs
       try {
           driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) {
           System.out.println("Invalid grid URL");
       } catch (Exception e) {
           System.out.println(e.getMessage());
       }
   }


   @Test
   public void login() {
       String url = "https://accounts.lambdatest.com/login";
       driver.get(url);
       driver.manage().window().maximize();
       driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
       WebElement email = driver.findElement(By.id("email"));
       email.clear();
       email.sendKeys("abc@gmail.com");
       WebElement password = driver.findElement(By.id("password"));
       password.clear();
       password.sendKeys("abc@123");
       WebElement loginButton = driver.findElement(By.id("login-button"));
       loginButton.click();
   }


   @AfterMethod
   public void tearDown() throws Exception {
       if (driver != null) {
           driver.quit();
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test class 2: Print title&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package MyTests.ClassInParallel;

import org.openqa.Selenium.By;
import org.openqa.Selenium.WebElement;
import org.openqa.Selenium.remote.DesiredCapabilities;
import org.openqa.Selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class ClassB {
   public String username = "YOUR_USERNAME";
   public String accesskey = "YOUR_ACCESSKEY";
   public RemoteWebDriver driver = null;
   public String gridURL = "@hub.lambdatest.com/wd/hub";

   @BeforeMethod
   @Parameters(value={"browser"})
   public void setUp(String browser) throws Exception {
       DesiredCapabilities capabilities = new DesiredCapabilities();
       capabilities.setCapability("browserName", browser);
       capabilities.setCapability("version", "97.0");
       capabilities.setCapability("platform","win10" ); // If this cap isn't specified, it will just get the any available one
       capabilities.setCapability("build", "ParallelExecution_TestClassB");
       capabilities.setCapability("name", "ParallelExecution_TestClassB");
       capabilities.setCapability("network", true); // To enable network logs
       capabilities.setCapability("visual", true); // To enable step by step screenshot
       capabilities.setCapability("video", true); // To enable video recording
       capabilities.setCapability("console", true); // To capture console logs
       try {
           driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) {
           System.out.println("Invalid grid URL");
       } catch (Exception e) {
           System.out.println(e.getMessage());
       }
   }


   @Test
   public void printTitle() {
       String urlToTest = "https://www.lambdatest.com/selenium-playground/";
       driver.get(urlToTest);
       driver.manage().window().maximize();
       String title = driver.getTitle();

       System.out.println("The title of the page is ==&amp;amp;gt; " +title);

   }

   @AfterMethod
   public void tearDown() throws Exception {
       if (driver != null) {
           driver.quit();
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TestNG.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!--?xml version="1.0" encoding="UTF-8"?--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the TestNG.xml file, we have set the value as classes in the parallel attribute with the thread count as 2. Therefore, this will execute two test classes in parallel.&lt;/p&gt;

&lt;p&gt;Now you will see two classes running in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkylvg0w2z4bh7s9p3jfo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkylvg0w2z4bh7s9p3jfo.png" alt=" " width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the LambdaTest grid, you will see the two test classes Class A and Class B, run parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcl2v8fpw12cfqjg2fzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcl2v8fpw12cfqjg2fzc.png" alt=" " width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s a short glimpse of the Selenium Advanced certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DK21aHjuUE4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up!
&lt;/h2&gt;

&lt;p&gt;To summarize this article on how to write test scripts in Selenium, we have seen basic steps in setting up the requirements for running our simple test in Selenium, steps to write our first Selenium test and finally, the different ways to run our tests. It has always been easy to run the tests in a cloud-based Selenium Grid like LambdaTest as it is easy to use and provides multiple features like parallel testing, live interactive testing, mobile app testing, and most importantly, visual testing.&lt;/p&gt;

&lt;p&gt;Thus, it provides a robust and scalable platform to execute tests at ease. I hope this article is informative and helps in running your first Selenium test. Please feel free to provide your feedback in the comment section. Until then, keep exploring and try your hands on the LambdaTest platform.&lt;/p&gt;

&lt;p&gt;Happy Testing …!&lt;/p&gt;

</description>
      <category>testing</category>
      <category>selenium</category>
    </item>
    <item>
      <title>JUnit 5 vs. TestNG: Choosing The Right Framework For Selenium Automation Testing</title>
      <dc:creator>Shalini Baskaran</dc:creator>
      <pubDate>Tue, 08 Feb 2022 14:13:23 +0000</pubDate>
      <link>https://forem.com/testmuai/junit-5-vs-testng-choosing-the-right-framework-for-selenium-automation-testing-g28</link>
      <guid>https://forem.com/testmuai/junit-5-vs-testng-choosing-the-right-framework-for-selenium-automation-testing-g28</guid>
      <description>&lt;p&gt;A framework is a backbone for testing or development activities. It is a set of components that helps frame the tests, execute the tests, and generate the final report of execution. The approach used for designing the &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; framework plays a crucial part in the testing activity.&lt;/p&gt;

&lt;p&gt;JUnit and TestNG are considered some of the best Java testing frameworks for Selenium automation testing. You should choose the appropriate test framework for your project’s requirements. JUnit 5 is the latest version of the JUnit framework. In this blog, we do a JUnit 5 vs. TestNG comparison.&lt;/p&gt;

&lt;p&gt;The TestNG framework is inspired by the JUnit and NUnit frameworks. However, TestNG outperforms JUnit 5 in parameterized testing, suite testing, and dependency testing.&lt;/p&gt;

&lt;p&gt;In this blog on JUnit 5 vs. TestNG comparison, we explore the differences between the JUnit 5 and TestNG from the perspective of Selenium WebDriver. By the end of this blog, you would be in a position to choose the best-suited framework for realizing your Selenium automation testing tasks.&lt;/p&gt;

&lt;p&gt;Let’s begin!&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview of JUnit5
&lt;/h2&gt;

&lt;p&gt;JUnit is one of the best unit testing frameworks for Selenium Java automation testing. The entire application being developed would first undergo unit testing that the developers perform on small code chunks. Thus, by testing individual code chunks, the developer would be able to test the code and locate bugs (if any).&lt;/p&gt;

&lt;p&gt;The latest version of JUnit is JUnit 5, and it has three different sub-components – JUnit Platform, JUnit Jupiter, and JUnit Vintage. The JUnit platform is the basic foundation of the JUnit 5 framework. JUnit Jupiter is used for writing the tests and the JUnit Vintage is used for running earlier versions of JUnit tests such as JUnit 3 and JUnit 4 based tests.&lt;/p&gt;

&lt;p&gt;Refer to our learning hub on the &lt;a href="https://www.lambdatest.com/learning-hub/junit-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium JUnit tutorial&lt;/a&gt; to delve deeper into the JUnit framework.&lt;/p&gt;

&lt;p&gt;If you still use JUnit 4 or previous versions and wish to migrate your tests to JUnit 5, please explore JUnit 4 vs. JUnit 5 comparison.&lt;/p&gt;

&lt;p&gt;This JUnit Tutorial for beginners and professionals will help you learn how to use JUnit framework with Selenium and Java for performing Selenium automation testing.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/HXtC-a_4HAc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview of TestNG
&lt;/h2&gt;

&lt;p&gt;TestNG is another popular open-source Java-based unit testing framework that provides complete control over the test cases and their execution. It aids in writing robust and flexible test cases by using various features like TestNG annotations, prioritization, grouping, and parameterization.&lt;br&gt;
It simplifies the way of writing test cases. It is relatively simple to implement tests with TestNG, making it easy for the users to implement and maintain the code. It has multiple built-in features that eliminate the need for external plugins. For more information around the TestNG framework for Selenium automation testing, check out our learning hub on the &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium TestNG tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/html-media-capture?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun21_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;HTML Media Capture&lt;/a&gt; allows the user to access the media capture mechanism of their device, such as a camera or microphone, from within a file upload control.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Difference between JUnit 5 vs. TestNG
&lt;/h2&gt;

&lt;p&gt;To choose the perfect framework between JUnit vs. TestNG for Selenium automation, let us first understand the differences between JUnit 5 and TestNG. It is important to note that we are comparing JUnit 5 (and not JUnit 4) with TestNG. Also, some features like parallel execution with JUnit 5 are still in the Beta stage; though the features work as per the expectations!&lt;/p&gt;
&lt;h3&gt;
  
  
  JUnit 5 and TestNG: Setup and Installation
&lt;/h3&gt;

&lt;p&gt;In this section of the JUnit vs TestNG framework comparison, we look at how to install and configure JUnit and TestNG framework.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Installing and setting up JUnit5
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Step 1: **JUnit 5 requires Java version 8 or above versions for running the tests. You can download Java from the official website &lt;a href="https://www.oracle.com/java/technologies/downloads/" rel="noopener noreferrer"&gt;https://www.oracle.com/java/technologies/downloads/&lt;/a&gt;.&lt;br&gt;
**Step 2:&lt;/strong&gt; In the case of a Java project, download the JUnit 5 jars from &lt;a href="https://junit.org/junit5/" rel="noopener noreferrer"&gt;https://junit.org/junit5/&lt;/a&gt;.&lt;br&gt;
&lt;strong&gt;Step 3:&lt;/strong&gt; Open the project and add these external jars through build path configuration.&lt;br&gt;
&lt;strong&gt;Step 4:&lt;/strong&gt; In the case of the Maven project, download maven from the official website &lt;a href="https://maven.apache.org/download.cgi" rel="noopener noreferrer"&gt;https://maven.apache.org/download.cgi&lt;/a&gt;.&lt;br&gt;
&lt;strong&gt;Step 5:&lt;/strong&gt; Set up the environment variables.&lt;br&gt;
&lt;strong&gt;Step 6:&lt;/strong&gt; Add the below dependencies in pom.xml for running our JUnit 5 tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependencies&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;junit-jupiter-engine&amp;lt;/artifactId&amp;gt;
                  &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.junit.platform&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;junit-platform-runner&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;junit-jupiter-api&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
                  &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
              &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also refer to our JUnit video tutorial on how to install JUnit.&lt;/p&gt;

&lt;p&gt;{&amp;amp; youtube cggWYDNDrAw %}&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Installing and Setting up of TestNG
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Step1:&lt;/strong&gt; Download Java from the official website &lt;a href="https://www.oracle.com/java/technologies/downloads/" rel="noopener noreferrer"&gt;https://www.oracle.com/java/technologies/downloads/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; In the case of a Java project, download the jar from &lt;a href="https://mvnrepository.com/artifact/org.TestNG/TestNG/6.7" rel="noopener noreferrer"&gt;https://mvnrepository.com/artifact/org.TestNG/TestNG/6.7&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Open the project and add these external jars through build path configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; In the case of the Maven project, download maven from the official website &lt;a href="https://maven.apache.org/download.cgi" rel="noopener noreferrer"&gt;https://maven.apache.org/download.cgi&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Set up the environment variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt; Add the TestNG dependency in the pom.xml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.TestNG&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;TestNG&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;7.4.0&amp;lt;/version&amp;gt;
    &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the setup is completed, you are ready to go…!&lt;/p&gt;

&lt;h3&gt;
  
  
  ‘Test Suites’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;A test suite is a collection of tests to be executed in a framework. The test suite defines the test cases and can be quickly executed.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. JUnit 5 suite
&lt;/h4&gt;

&lt;p&gt;In JUnit 5, the test suite is defined with @ RunWith and @ Suite annotations.&lt;/p&gt;

&lt;p&gt;When we annotate a class with @ RunWith annotation, the framework will invoke the given class as the test runner instead of running the default one. The below example specifies a group of test classes to be run along with the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RunWith(Suite.class)
@Suite.SuiteClasses(
{
         JUnitTest1.class,
         JUnitTest2.class
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. TestNG suite
&lt;/h4&gt;

&lt;p&gt;In TestNG, the suite is defined in an XML file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://TestNG.org/TestNG-1.0.dtd"&amp;gt;
    &amp;lt;suite name="TestSuite" parallel="tests"&amp;gt;
        &amp;lt;test name="DemoTest"&amp;gt;
           &amp;lt;classes&amp;gt;
            &amp;lt;class name="com.pages.LoginPageTest"&amp;gt;&amp;lt;/class&amp;gt;
            &amp;lt;class name="com.pages.HomePageTest"&amp;gt;&amp;lt;/class&amp;gt;
            &amp;lt;class name="com.pages.ProductPageTest"&amp;gt;&amp;lt;/class&amp;gt;
           &amp;lt;/classes&amp;gt;
        &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s a short glimpse of the TestNG certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/dzXX2hJhuCY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  ‘Annotations’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;Annotations give additional information about the class or test method in the test automation framework. Read our detailed tutorial on &lt;a href="https://www.lambdatest.com/blog/complete-guide-on-testng-annotations-for-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG annotations for Selenium&lt;/a&gt; automation to know more about the usage of annotations in TestNG.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. JUnit 5 annotations
&lt;/h4&gt;

&lt;p&gt;The annotations in JUnit 5 are a bit different, even from its previous versions of JUnit. Shown below are some of the popular JUnit 5 annotations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;*&lt;em&gt;@ Test *&lt;/em&gt; – This annotation is used for declaring a test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ TestFactory&lt;/strong&gt; – This annotation is used for defining a method which is a test factory. It is used for the runtime generation of dynamic tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ RepeatedTest&lt;/strong&gt; – This annotation is used to specify that the method is a template for the tests that can be repeated a specific number of times. For example, the below test method is annotated with @ RepeatedTest for a specific number 5, which indicates that this test will be repeated automatically five times.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RepeatedTest(5)

public void print(){

  // write some code to be executed

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;@ ParameterizedTest&lt;/strong&gt; – This annotation is used to indicate that the method is a parameterized test. These parameterized tests are similar to standard test methods but we have to specify a source to provide parameters that would be used for every test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ TestMethodOrder&lt;/strong&gt; – This annotation is used to define the order of the test execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ DisplayName&lt;/strong&gt; – This annotation is used to specify a customized display name for the method or class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ Tag&lt;/strong&gt; – This annotation is used for filtering the tests at the method or class level by defining the tags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@Disabled&lt;/strong&gt; – This annotation is used to disable a test method or class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ BeforeEach&lt;/strong&gt; – This annotation is used to specify that the said test method has to be executed before each &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterEach&lt;/strong&gt; – This annotation is used to specify that the specific test method has to be executed after each &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ BeforeAll&lt;/strong&gt; –  This annotation is used to specify that the specific test method has to be executed before all  &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt;, @RepeatedTest, @ParameterizedTest, or @TestFactory methods.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterAll&lt;/strong&gt; – This annotation is used to specify that the specific test method has to be executed after all  @ Test, @ RepeatedTest, @ ParameterizedTest, or @ TestFactory methods.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  2. TestNG annotations
&lt;/h4&gt;

&lt;p&gt;Below are the various annotations used in TestNG: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;@ BeforeMethod&lt;/strong&gt; – This will be executed before every &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotated method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterMethod&lt;/strong&gt;: This annotation will be executed after every @ Test annotated method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ BeforeClass&lt;/strong&gt; – This will be executed before the first &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; method execution. It will be executed one only time throughout the test case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterClass&lt;/strong&gt; – This will be executed after all test methods in the current class have been run&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ BeforeTest&lt;/strong&gt; – This will be executed before the first &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotated method. It can be executed multiple times before the test case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterTest&lt;/strong&gt; – A method with this annotation will be executed when all &lt;a class="mentioned-user" href="https://dev.to/test"&gt;@test&lt;/a&gt; annotated methods complete the execution of those classes inside the  tag in the testng.xml file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ BeforeSuite&lt;/strong&gt; – It will run only once before all tests in the suite are executed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterSuite&lt;/strong&gt; – A method with this annotation will run once after the execution of all tests in the suite is complete.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@  BeforeGroups&lt;/strong&gt; – This method will run before the first test run of that specific group.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ AfterGroups&lt;/strong&gt; – This method will run after all test methods of that group complete their execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ Test&lt;/strong&gt;  – This is used for declaring a test.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Quick Comparison of JUnit 5 and TestNG Annotations
&lt;/h4&gt;

&lt;p&gt;Let’s compare the annotations between JUnit 5 vs. TestNG.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;TestNG&lt;/th&gt;
&lt;th&gt;JUnit 5&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Defines the method as the test method&lt;/td&gt;
&lt;td&gt;@ Test&lt;/td&gt;
&lt;td&gt;@T est&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed before the first test method of the class&lt;/td&gt;
&lt;td&gt;@ BeforeClass&lt;/td&gt;
&lt;td&gt;@ BeforeAll&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed after all the test methods of the current class have been executed.&lt;/td&gt;
&lt;td&gt;@ AfterClass&lt;/td&gt;
&lt;td&gt;@ AfterAll&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed before each test method&lt;/td&gt;
&lt;td&gt;@ BeforeMethod&lt;/td&gt;
&lt;td&gt;@ BeforeEach&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed after each test method&lt;/td&gt;
&lt;td&gt;@ AfterMethod&lt;/td&gt;
&lt;td&gt;@ AfterEach&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed before the suit.&lt;/td&gt;
&lt;td&gt;@ BeforeSuite&lt;/td&gt;
&lt;td&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed after suit.&lt;/td&gt;
&lt;td&gt;@ AfterSuite&lt;/td&gt;
&lt;td&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed before the test.&lt;/td&gt;
&lt;td&gt;@ BeforeTest&lt;/td&gt;
&lt;td&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed before the test.&lt;/td&gt;
&lt;td&gt;@ AfterTest&lt;/td&gt;
&lt;td&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed before the first test method of any of these groups.&lt;/td&gt;
&lt;td&gt;@ BeforeGroups&lt;/td&gt;
&lt;td&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The method that is annotated is executed after the first test method of any of these groups.&lt;/td&gt;
&lt;td&gt;@ AfterGroups&lt;/td&gt;
&lt;td&gt;NA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here’s a short glimpse of the JUnit certification from LambdaTest:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fWsCwrtElAw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  ‘Ignoring Tests’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;In our automation framework, we would have some test cases which have to be avoided for some reason. For example, it would have been obsolete or changed the requirement. In such cases, those cases have to be ignored so that they are not considered in the test run. Let us now see how to handle such cases in JUnit 5 and TestNG.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Ignoring tests in JUnit 5
&lt;/h4&gt;

&lt;p&gt;To ignore a test, we can use @ Ignore annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Ignore
public void oldTest(){
    System.out.println("This test has to be ignored");
}

@Test
public void newTest(){
    System.out.println("Test has been executed");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the above tests would ignore the first test, which is annotated with @ Ignore annotation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdynhknrxqyzmk3x6ytx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdynhknrxqyzmk3x6ytx.png" alt=" " width="512" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Ignoring tests in TestNG
&lt;/h4&gt;

&lt;p&gt;To ignore a test in TestNG, we can pass a parameter in the @ Test method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;

import org.TestNG.annotations.Test;

public class SimpleTest {

    @Test
    public void test1() {
        System.out.println("This is test1");
    }

    @Test(enabled = false)
    public void test2() {
        System.out.println("This is test2");
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second test has been disabled, so running the class would ignore the second case.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Console Output:&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrxzy2s4nrtr5708mt0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrxzy2s4nrtr5708mt0h.png" alt=" " width="512" height="61"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ‘Grouping Tests’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;Grouping of tests helps us to identify the tests and execute them quickly. Let us now see how to group the tests in TestNG and JUnit 5.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Grouping tests in JUnit 5
&lt;/h4&gt;

&lt;p&gt;In JUnit 5 we can use an annotation @Tag which helps us to group our tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package demo;

import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public class SimpleTest {

    @Test
    @Tag("Smoke")
    public void Test_1(){
        System.out.println("Test1 has been executed");
    }

    @Test
    @Tag("Smoke")
    public void Test_2(){
        System.out.println("Test2 has been executed");
    }
    @Test
    @Tag("Regression")
    public void Test_3(){
        System.out.println("Test3 has been executed");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We add the tag in the Run configurations to execute our tests specific to a tag and then execute it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsqgfoic51yjno0ffvttv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsqgfoic51yjno0ffvttv.png" alt=" " width="512" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example, we have grouped only one test under Regression, and hence only one will be executed when the Regression tag is specified.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajad56shk9dwi02qmpaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajad56shk9dwi02qmpaq.png" alt=" " width="512" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Grouping tests in TestNG
&lt;/h4&gt;

&lt;p&gt;For grouping tests in TestNG under the same category, we use groups parameters along with @ Test annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;


import org.TestNG.annotations.AfterTest;
import org.TestNG.annotations.BeforeTest;
import org.TestNG.annotations.Test;

public class DemoTest1 {

    @BeforeTest
    public static void start() {
        System.out.println("=======Starting TestNG tests========");
    }

    @Test(groups = { "Sanity", "Regression" })
    public void test_method1()
    {
        //Test implementation
    }

    @Test(groups = {"Sanity"} )
    public void test_method2()
    {
        //Test implementation
    }

    @Test(groups = {"Regression"})
    public void test_method3()
    {
        //Test implementation
    }


    @AfterTest
    public static void end() {
        System.out.println("All the tests are executed successfully");

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To execute the tests belonging to a specific category, we have to add the group name in the testng.xml file. We can include (or exclude) multiple groups before executing the tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://TestNG.org/TestNG-1.0.dtd"&amp;gt;
&amp;lt;suite name="TestSuite" parallel="methods" thread-count="4"&amp;gt;
    &amp;lt;test name="DemoTest"&amp;gt;
            &amp;lt;groups&amp;gt;
                &amp;lt;run&amp;gt;
                    &amp;lt;include name = "Sanity"&amp;gt;&amp;lt;/include&amp;gt;
                    &amp;lt;exclude name="Regression"&amp;gt;&amp;lt;/exclude&amp;gt;
                &amp;lt;/run&amp;gt;
            &amp;lt;/groups&amp;gt;
            &amp;lt;classes&amp;gt;
                &amp;lt;class name="com.pages.DemoTest1"&amp;gt;&amp;lt;/class&amp;gt;
            &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above snippet, we have two groups – Sanity and Regression. In the testng.xml, we have included the Sanity group and excluded the Regression group. After test execution, we could only see the second test being executed as it belongs only to the Sanity group.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Console Output:&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg1cxzzu2dchyck5d93l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg1cxzzu2dchyck5d93l.png" alt=" " width="512" height="245"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ‘Parameterizing Tests’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;Parameterizing the tests helps us provide different sets of inputs to test the same test scenario. Now let us see how to parameterize the tests using JUnit 5 and TestNG.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Parameterizing tests in TestNG
&lt;/h4&gt;

&lt;p&gt;There are two ways to parameterize the tests in TestNG.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using @ Parameters and passing the value of the parameter in the TestNG XML file&lt;/li&gt;
&lt;li&gt;Using @ DataProvider annotation in TestNG&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Parameterizing the tests using @ Parameters
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;

import org.TestNG.annotations.Parameters;
import org.TestNG.annotations.Test;

public class SimpleTest {


    @Test()
    @Parameters("username")
    public void test1(String username) {
        System.out.println("The username "+username + " is passed");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the above example, we have used @Parameter annotation to provide a username. The value will be specified in the testng.xml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://TestNG.org/TestNG-1.0.dtd"&amp;gt;
&amp;lt;suite name="TestSuite" parallel="tests"&amp;gt;
    &amp;lt;test name="DemoTest"&amp;gt;
        &amp;lt;parameter name = "username" value = "Alex"/&amp;gt;

        &amp;lt;classes&amp;gt;
            &amp;lt;class name="com.pages.SimpleTest"&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdce9gxsr4fb8teaea04q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdce9gxsr4fb8teaea04q.png" alt=" " width="512" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Parameterizing using @ DataProvidersThe @ DataProviders annotation is used to provide multiple input values to the test. It has a separate data provider method that is used to pass the parameters.Scenario: To test the login functionality of a webpage using different sets of credentials.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.TestNG.annotations.*;

import java.util.concurrent.TimeUnit;

public class SimpleTest {

    WebDriver driver;
    String url = "https://www.lambdatest.com/";

@BeforeTest
    public void setup() {
        System.out.println("Setting up the drivers");
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver_latest94\\chromedriver.exe");
        driver = new ChromeDriver();
    }
    @Test(dataProvider = "credentials")
    public void LoginTest(String username,String password) {
        driver.get(url);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        WebElement login = driver.findElement(By.xpath("//a[text()='Login']"));
        login.click();
        WebElement name = driver.findElement(By.xpath("//input[@name=\"email\"]"));
        WebElement passwd = driver.findElement(By.xpath("//input[@name=\"password\"]"));
        WebDriverWait wait = new WebDriverWait(driver,20);
        wait.until(ExpectedConditions.visibilityOf(name));
        name.clear();
        name.sendKeys(username);
        passwd.clear();
        passwd.sendKeys(password);
        WebElement loginButton = driver.findElement(By.xpath("//button[text()='Login']"));
        loginButton.click();
        System.out.println("Logged in successfully");
    }

    @DataProvider(name = "credentials")
    public Object[][] getUserInput() {
        return new Object[][]{
                {"abc@gmail.com", "xaxxdssc"},
                {"alexdan@gmail.com", "mypasswd"},
                {"myemail123@yahoo.com", "textmypass"}
        };
    }
    @AfterTest
    public void tearDown(){
        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the above example, we have added a test case for the login functionality in a webpage.First, we would locate the webelements for entering the username and password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebElement name = driver.findElement(By.xpath("//input[@name=\"email\"]"));

WebElement passwd = driver.findElement(By.xpath("//input[@name=\"password\"]"));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After locating the elements we need to pass different sets of inputs to username and password.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  name.clear();
        name.sendKeys(username);
        passwd.clear();
        passwd.sendKeys(password);
        WebElement loginButton =      driver.findElement(By.xpath("//button[text()='Login']"));
        loginButton.click();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As mentioned earlier, in order to pass different parameters we would use @ Dataproviders.&lt;/p&gt;

&lt;p&gt;We implement a Dataprovider method to pass different sets of input and will provide a unique name to identify the data provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @DataProvider(name = "credentials")
    public Object[][] getUserInput() {
        return new Object[][]{
                {"abc@gmail.com", "xaxxdssc"},
                {"alexdan@gmail.com", "mypasswd"},
                {"myemail123@yahoo.com", "textmypass"}
        };
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use these inputs in our tests, we provide a parameter dataprovider along with the unique name within the @ Test annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @Test(dataProvider = "credentials")
    public void LoginTest(String username,String password) {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FileName – testng.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://TestNG.org/TestNG-1.0.dtd"&amp;gt;
&amp;lt;suite name="TestSuite" parallel="tests"&amp;gt;
    &amp;lt;test name="DemoTest"&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="com.pages.SimpleTest"&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7yb98ornjqtgkmt1yrz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7yb98ornjqtgkmt1yrz1.png" alt=" " width="512" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Parameterizing tests in JUnit 5
&lt;/h4&gt;

&lt;p&gt;JUnit provides different ways to parameterize the tests, akin to parameterizing in JUnit 4 framework.&lt;/p&gt;

&lt;p&gt;As this article primarily focuses on JUnit 5 let us see how to parameterize the tests in JUnit 5. You will have to add the below dependency to parameterize the tests in JUnit 5.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
   &amp;lt;groupId&amp;gt;org.junit.jupiter&amp;lt;/groupId&amp;gt;
   &amp;lt;artifactId&amp;gt;junit-jupiter-params&amp;lt;/artifactId&amp;gt;
   &amp;lt;version&amp;gt;5.7.1&amp;lt;/version&amp;gt;
   &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the code snippet to run our tests in different browsers by parameterizing the browsers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import static org.junit.jupiter.params.provider.Arguments.arguments;

public class JUnitParamTest {


    String urlToTest = "https://www.lambdatest.com/selenium-playground/simple-form-demo.php";
    WebDriver driver;

    public void browser_setup(String browser) {
        System.out.println("Setting up the drivers and browsers");

        if(browser.equalsIgnoreCase("Chrome")) {
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver_latest94\\chromedriver.exe");
            driver = new ChromeDriver();
              }
        if(browser.equalsIgnoreCase("Firefox")) {
            System.setProperty("webdriver.gecko.driver","C:\\Users\\Shalini\\Downloads\\geckodriver\\geckodriver.exe");
                    driver = new FirefoxDriver();
              }

    }



    @ParameterizedTest
    @MethodSource("browser")
    public void enterAndDisplayMessage(String browser) {
        browser_setup(browser);
        String inputString ="Hello";
        String methodName = Thread.currentThread()
                .getStackTrace()[1]
                .getMethodName();
        System.out.println("********Execution of "+methodName+" has been started********");
        System.out.println("Launching LambdaTest selenium playground website started..");
        driver.get(urlToTest);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement textBox = driver.findElement(By.xpath("//input[@id='user-message']"));
        textBox.sendKeys(inputString);

        WebElement showButton = driver.findElement(By.id("showInput"));
        showButton.click();

        WebElement messageDisplayed = driver.findElement(By.xpath("//div[@id='user-message']//span[@id = 'message']"));
        String message = messageDisplayed.getText();
        Assertions.assertEquals(inputString,message);
        System.out.println("********Execution of "+methodName+" has ended********");
    }


    @AfterEach
    public void tearDown() {
        System.out.println("Quitting the browsers has started");
        driver.quit();
        System.out.println("Quitting the browsers has ended");
    }

    @AfterAll
    public static void end() {
        System.out.println("Tests ended");
    }

    static Stream&amp;lt;Arguments&amp;gt; browser() {
        return Stream.of(
                arguments("Chrome"),
                arguments("Firefox")
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we have parameterized two different browsers, our tests will be executed in two browsers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqxh1jdwfzyq06c9noiz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqxh1jdwfzyq06c9noiz.png" alt=" " width="512" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/iframe-sandbox?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun21_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;sandbox attribute for iframes&lt;/a&gt; is a JavaScript library for running pages in iframes with reduced privileges.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ‘Prioritizing tests’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;Setting priority for the test cases is pretty important during the test execution as it helps find the critical defects in essential features. Though developing atomic test cases is considered as one of the Selenium best practices, there could be scenarios where you may have to devise inter-dependent tests.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Prioritizing the tests in JUnit 5
&lt;/h4&gt;

&lt;p&gt;In JUnit 5, the execution order of tests or priority of the tests can be set using @ Order annotation. We also have to use @ TestMethodOrder(MethodOrderer.OrderAnnotation.class)  to execute the tests in a pre-defined order.&lt;/p&gt;

&lt;p&gt;In the below example, we have two tests – enterAndDisplayMessage() and addAndDisplayResult(). The test enterAndDisplayMessage() has the order set to 2 and the test addAndDisplayResult() has the order set to 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.concurrent.TimeUnit;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class OrderTests {

    String urlToTest = "https://www.lambdatest.com/selenium-playground/simple-form-demo.php";
    WebDriver driver;

    @BeforeAll
    public static void start() {
        System.out.println("=======Starting junit 5 tests========");
    }

    @BeforeEach
    public void setup() {
        System.out.println("Setting up the drivers");
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver_latest94\\chromedriver.exe");
        driver = new ChromeDriver();
    }
    @Test
    @Order(2)
    public void enterAndDisplayMessage() {
        String inputString ="Hello World";
        String methodName = Thread.currentThread()
                .getStackTrace()[1]
                .getMethodName();
        System.out.println("********Execution of "+methodName+" has been started********");
        System.out.println("Launching LambdaTest selenium playground website started..");
        driver.get(urlToTest);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement textBox = driver.findElement(By.xpath("//input[@id='user-message']"));
        textBox.sendKeys(inputString);

        WebElement showButton = driver.findElement(By.id("showInput"));
        showButton.click();

        WebElement messageDisplayed = driver.findElement(By.xpath("//div[@id='user-message']//span[@id = 'message']"));
        String message = messageDisplayed.getText();
        Assertions.assertEquals(inputString,message);
        System.out.println("********Execution of "+methodName+" has ended********");
    }


    @Test
    @Order(1)
    public void addAndDisplayResult(){
        String methodName = Thread.currentThread()
                .getStackTrace()[1]
                .getMethodName();

        System.out.println("********Execution of "+methodName+" has been started********");
        System.out.println("Launching LambdaTest selenium playground website started..");
        driver.get(urlToTest);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement input1 = driver.findElement(By.id("sum1"));
        input1.sendKeys("1");
        WebElement input2 = driver.findElement(By.id("sum2"));
        input2.sendKeys("3");

        WebElement addButton = driver.findElement(By.xpath("//*[@id='gettotal']//button[contains(@class,'selenium_btn')]"));
        addButton.click();
        WebElement resultDisplayed = driver.findElement(By.id("addmessage"));
        String result = resultDisplayed.getText();

        Assertions.assertEquals("4",result);
        System.out.println("********Execution of "+methodName+" has ended********");
    }
    @AfterEach
    public void tearDown() {
        System.out.println("Quitting the browsers has started");
        driver.quit();
        System.out.println("Quitting the browsers has ended");
    }

    @AfterAll
    public static void end() {
        System.out.println("Tests ended");
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Upon execution, we could see the tests being executed in the order provided.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp9tlld3z8mrm7izhvn9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp9tlld3z8mrm7izhvn9r.png" alt=" " width="512" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Prioritizing tests in TestNG
&lt;/h4&gt;

&lt;p&gt;In TestNG, we can set the execution order or priority by providing the parameter @ priority and the @ Test annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.TestNG.Assert;
import org.TestNG.annotations.AfterTest;
import org.TestNG.annotations.BeforeTest;
import org.TestNG.annotations.Test;

import java.util.concurrent.TimeUnit;

public class TestNGOrder {

    String urlToTest = "https://www.lambdatest.com/selenium-playground/simple-form-demo.php";
    WebDriver driver;

    @BeforeTest
    public void setup() {
        System.out.println("Setting up the drivers");
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Shalini\\Downloads\\chromedriver_latest94\\chromedriver.exe");
        driver = new ChromeDriver();
    }
    @Test(priority = 1)
    public void enterAndDisplayMessage() {
        String inputString ="Hello World";
        String methodName = Thread.currentThread()
                .getStackTrace()[1]
                .getMethodName();
        System.out.println("********Execution of "+methodName+" has been started********");
        System.out.println("Launching LambdaTest selenium playground website started..");
        driver.get(urlToTest);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement textBox = driver.findElement(By.xpath("//input[@id='user-message']"));
        textBox.sendKeys(inputString);

        WebElement showButton = driver.findElement(By.id("showInput"));
        showButton.click();

        WebElement messageDisplayed = driver.findElement(By.xpath("//div[@id='user-message']//span[@id = 'message']"));
        String message = messageDisplayed.getText();
        Assert.assertEquals(inputString,message);
        System.out.println("********Execution of "+methodName+" has ended********");
    }


    @Test(priority = 2)
    public void addAndDisplayResult(){
        String methodName = Thread.currentThread()
                .getStackTrace()[1]
                .getMethodName();

        System.out.println("********Execution of "+methodName+" has been started********");
        System.out.println("Launching LambdaTest selenium playground website started..");
        driver.get(urlToTest);
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

        WebElement input1 = driver.findElement(By.id("sum1"));
        input1.sendKeys("1");
        WebElement input2 = driver.findElement(By.id("sum2"));
        input2.sendKeys("3");

        WebElement addButton = driver.findElement(By.xpath("//*[@id='gettotal']//button[contains(@class,'selenium_btn')]"));
        addButton.click();
        WebElement resultDisplayed = driver.findElement(By.id("addmessage"));
        String result = resultDisplayed.getText();

        Assert.assertEquals("4",result);
        System.out.println("********Execution of "+methodName+" has ended********");
    }

    @AfterTest
    public void tearDown() {
        driver.quit();
    }



}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzpei4mo843bmct66gh4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzpei4mo843bmct66gh4.png" alt=" " width="512" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If there is no priority given for the tests, the tests will be executed in alphabetical order.&lt;/p&gt;

&lt;p&gt;Consider the same code used above, and we don’t provide any priority explicitly. In that case, you can see the tests executed in alphabetical order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yxme9x91hgmfo0e6rc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yxme9x91hgmfo0e6rc4.png" alt=" " width="512" height="257"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ‘Creating Test Dependency’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;Creating inter-dependent tests is one of the non-recommended practices in Selenium. However, it can be useful when you want to avoid (or skip) the execution of tests depending on the result of some other tests.&lt;/p&gt;
&lt;h4&gt;
  
  
  1. Creating dependency in JUnit 5
&lt;/h4&gt;

&lt;p&gt;The @ TestMethodOrder annotation that is used to configure the test execution order is also used for creating test dependencies in JUnit 5. It provides similar functionality that is offered by the @ FixMethodOrder annotation in the JUnit 4 framework.&lt;/p&gt;

&lt;p&gt;Fixing the execution order is particularly useful when writing functional tests or integration tests. It is majorly used in conjunction with @ TestInstance(Lifecycle.PER_CLASS).&lt;/p&gt;

&lt;p&gt;For controlling the execution order of the test methods, test classes (or test methods) are annotated with the @ TestMethodOrder annotation. The desired order is specified using the MethodOrderer implementation.&lt;/p&gt;
&lt;h4&gt;
  
  
  2. Creating dependency in TestNG
&lt;/h4&gt;

&lt;p&gt;In the below example, we have written three tests – editProfileTest(), selectProduct(), and loginTest(). The former two tests are dependent on loginTest().&lt;/p&gt;

&lt;p&gt;So when the main test i.e., loginTest() itself, fails, the dependent tests can be skipped as there is no point in testing when the login functionality is not working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;

import org.TestNG.annotations.Test;

public class dependentTest {

    @Test(dependsOnMethods = {"loginTest"})
    public void editProfileTest(){
        System.out.println("The user has successfully edited his profile");
    }
    @Test(dependsOnMethods = {"loginTest"})
    public void selectProduct(){
        System.out.println("The product has been added into the cart");
    }
    @Test
    public void loginTest(){
        System.out.println("The user is successfully logged in");
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfdtteh9imowupwoz1mx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfdtteh9imowupwoz1mx.png" alt=" " width="512" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Did you know? &lt;a href="https://www.lambdatest.com/web-technologies/iframe-srcdoc?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jun21_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;srcdoc attribute for iframes&lt;/a&gt; allows you to override text specified as the content of an image source attribute ( if present ) with HTML content.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Parallel Test Execution in JUnit 5 and TestNG
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/what-is-parallel-testing-and-why-to-adopt-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Parallel testing&lt;/a&gt; is one of the crucial features to be kept in mind when implementing Selenium test scenarios. It has to be utilized from the early stages of testing. Parallel execution of tests would highly help in cutting the execution time.&lt;/p&gt;

&lt;p&gt;Now let us run our tests in parallel using JUnit 5 and TestNG. We can utilize the LambdaTest cloud Selenium Grid to execute our tests in parallel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JUnit 5 Parallel Test Execution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Until JUnit 4, the parallel test execution wasn’t supported, which was the biggest drawback of using the Junit in the automation framework. But this was overcome in JUnit 5.&lt;/p&gt;

&lt;p&gt;Let’s understand how to perform parallel testing in JUnit with an example. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1: Verify the login functionality of LambdaTest Selenium playground.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;Step 2: Enter the valid username and password.&lt;/p&gt;

&lt;p&gt;Step 3: Click Login.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2: Verify if the user is able to see the message entered in the form.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;Step 2: On the main page, click the Simple Form Demo option.&lt;/p&gt;

&lt;p&gt;Step 3: Once the page is navigated to a simple form, enter the message box.&lt;/p&gt;

&lt;p&gt;Step 4: Click the Show Message button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 3: Verify if the user can select the first option in the checkbox&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Step 1: Launch &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;https://www.lambdatest.com/selenium-playground/&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;Step 2: On the main page, click the CheckBox Demo option.&lt;/p&gt;

&lt;p&gt;Step 3: Upon navigation, select the first checkbox.&lt;/p&gt;

&lt;p&gt;Step 4: Verify if the first checkbox is selected or not.&lt;/p&gt;

&lt;p&gt;We have three tests to be run in parallel in LambdaTest Selenium Grid. Let us now run these tests across different browsers in parallel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package ParallelTestsInJnit;

import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import static org.junit.jupiter.params.provider.Arguments.arguments;

public class ParallelTestsInGrid {

   String username = "YOUR_USERNAME"; //Enter your username
   String accesskey = "YOUR_ACCESSKEY"; //Enter your accesskey

   static RemoteWebDriver driver = null;
   String gridURL = "@hub.lambdatest.com/wd/hub";
   String urlToTest = "http://labs.lambdatest.com/selenium-playground/";

   @BeforeAll
   public static void start() {
       System.out.println("=======Running junit 5 tests in parallel in LambdaTest Grid has started========");
   }

   public void setup(String browser) {
       System.out.println("Setting up the drivers and browsers");

       DesiredCapabilities capabilities = new DesiredCapabilities();

       if(browser.equals("Chrome")) {
           capabilities.setCapability("platform", "Windows 10");// To specify the OS
           capabilities.setCapability("browserName", "Chrome"); //To specify the browser
           capabilities.setCapability("version","94.0");     //To specify the browser
           capabilities.setCapability("build", "ChromeTests");               //To identify the test
           capabilities.setCapability("name", "Parallel_JUnit5Tests");
       }

       else if (browser.equals("Firefox")){
           capabilities.setCapability("browserName", "Firefox");    //To specify the browser
           capabilities.setCapability("version", "93.0");        //To specify the browser version
           capabilities.setCapability("platform", "Windows 10");     // To specify the OS
           capabilities.setCapability("build", "FirefoxTests");               //To identify the test
           capabilities.setCapability("name", "Parallel_JUnit5Tests");
       }

       else if (browser.equals("Edge")){
           capabilities.setCapability("browserName", "MicrosoftEdge");
           capabilities.setCapability("platform", "Windows 10");
           capabilities.setCapability("version","94.0");     // To specify the OS
           capabilities.setCapability("build", "EdgeTests");               //To identify the test
           capabilities.setCapability("name", "Parallel_JUnit5Tests");
       }
       capabilities.setCapability("network", true);      // To enable network logs
       capabilities.setCapability("visual", true);          // To enable step by step screenshot
       capabilities.setCapability("video", true);       // To enable video recording
       capabilities.setCapability("console", true);         // To capture console logs
       try {
           driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) {
           System.out.println("Invalid grid URL");
       } catch (Exception e) {
           System.out.println(e.getMessage());
       }
   }


   @ParameterizedTest
   @MethodSource("browser")
   @DisplayName("LoginTest")
   @Order(1)
   public void test1(String browser){
       setup(browser);
       String methodName = Thread.currentThread()
               .getStackTrace()[1]
               .getMethodName();
       System.out.println("********Execution of "+methodName+" has been started********");

       driver.get(urlToTest);
       driver.manage().window().maximize();
       driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);

       List&amp;lt;WebElement&amp;gt; elements = driver.findElements(By.xpath("//a[@class='nav-link']"));
       for(WebElement e : elements){
           if (e.getText().equals("Login")){
               e.click();
               WebElement username = driver.findElement(By.id("email"));
               username.sendKeys("testuser");

               WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
               password.sendKeys("mypassword");

               WebElement loginBtn = driver.findElement(By.xpath("//button[@id='login-button']"));
               loginBtn.click();
           }
       }
       System.out.println("********Execution of "+methodName+" has ended********");

   }

   @ParameterizedTest
   @MethodSource("browser")
   @DisplayName("FormTest")
   @Order(2)
   public void test2(String browser){
       setup(browser);
       String methodName = Thread.currentThread()
               .getStackTrace()[1]
               .getMethodName();
       System.out.println("********Execution of "+methodName+" has been started********");
       driver.get(urlToTest);
       driver.manage().window().maximize();
       driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
       driver.findElement(By.xpath("//a[contains(@class,'btn_close_ck')]")).click();
       WebElement element = driver.findElement(By.linkText("Simple Form Demo"));
       element.click();
       driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);
       WebElement textBox = driver.findElement(By.xpath("//input[@id='user-message']"));
       textBox.sendKeys("Hello World");

       WebElement submitBtn = driver.findElement(By.id("showInput"));
       submitBtn.click();
       System.out.println("********Execution of "+methodName+" has ended********");


   }

   @ParameterizedTest
   @MethodSource("browser")
   @DisplayName("CheckBoxTest")
   @Order(3)
   public void test3(String browser){
       setup(browser);
       String methodName = Thread.currentThread()
               .getStackTrace()[1]
               .getMethodName();
       System.out.println("********Execution of "+methodName+" has been started********");
       driver.get(urlToTest);
       driver.manage().window().maximize();
       driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
       driver.findElement(By.xpath("//a[contains(@class,'btn_close_ck')]")).click();

       WebElement option = driver.findElement(By.linkText("Checkbox Demo"));
       option.click();
       driver.manage().timeouts().pageLoadTimeout(10,TimeUnit.SECONDS);
       WebElement checkBox1 = driver.findElement(By.xpath("//input[@id='ex1-check1']"));
       checkBox1.click();

       boolean flag = checkBox1.isSelected();
       if(!flag){
           Assertions.fail("The checkbox is not selected");
       }


       System.out.println("********Execution of "+methodName+" has ended********");

   }


   static Stream&amp;lt;Arguments&amp;gt; browser() {
       return Stream.of(
               arguments("Chrome"),
               arguments("Firefox"),
               arguments("Edge")
       );
   }

   @AfterEach
   public void tearDown() {
       System.out.println("Quitting the browsers has started");
       driver.quit();
       System.out.println("Quitting the browsers has ended");

   }

   @AfterAll
   public static void end() {
       System.out.println("Tests ended");

   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the tests in parallel, you can add the below arguments in VM options.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-Djunit.jupiter.execution.parallel.enabled=true

-Djunit.jupiter.execution.parallel.mode.default=concurrent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0yhpvqwz8s60wquemtw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0yhpvqwz8s60wquemtw.png" alt=" " width="512" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;We will see the tests running in different browsers in parallel upon execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxec2n732jpptcas5wtb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxec2n732jpptcas5wtb1.png" alt=" " width="512" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to the LambdaTest Automation dashboard; you will notice the three builds run in parallel. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz8zwv4t2fhw94fflb4kt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz8zwv4t2fhw94fflb4kt.png" alt=" " width="512" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may also read this article &lt;a href="https://www.lambdatest.com/blog/parallel-testing-with-junit5-and-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb08_sb&amp;amp;utm_term=sb&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Running JUnit 5 tests in parallel&lt;/a&gt; to understand the concept of running the tests in parallel in JUnit5 in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  TestNG Parallel Test Execution
&lt;/h3&gt;

&lt;p&gt;Parallel test execution in TestNG can be achieved with ease. However, first, you need to define the parallel execution in testng.xml.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;suite name="Parallel_Testing" parallel="methods" thread-count="8"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parallelism can be achieved at the methods, classes, tests, and instances level. In addition, you can define the number of threads in which the tests have to be executed in parallel. Defining the thread- count, like 8 in the above example, will use eight threads for execution. When the number of tests or methods is greater, the tests will run in a serial manner and wait for the completion of other tests.&lt;/p&gt;

&lt;p&gt;For demonstration, we will use the same tests as those in JUnit 5 parallel testing with minor changes for running tests in parallel in TestNG.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.TestNG.Assert;
import org.TestNG.annotations.AfterTest;
import org.TestNG.annotations.BeforeTest;
import org.TestNG.annotations.Parameters;
import org.TestNG.annotations.Test;


import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;


public class DemoTest1 {

   String username = "YOUR_USERNAME"; //Enter your username
   String accesskey = "YOUR_ACCESSKEY"; //Enter your accesskey

   static RemoteWebDriver driver = null;
   String gridURL = "@hub.lambdatest.com/wd/hub";
   String urlToTest = "http://labs.lambdatest.com/selenium-playground/";


   @BeforeTest
   @Parameters("browser")
   public void setup(String browser) {
       System.out.println("Setting up the drivers and browsers");

       DesiredCapabilities capabilities = new DesiredCapabilities();

       if(browser.equals("Chrome")) {
           capabilities.setCapability("platform", "Windows 10");// To specify the OS
           capabilities.setCapability("browserName", "Chrome"); //To specify the browser
           capabilities.setCapability("version","94.0");     //To specify the browser
           capabilities.setCapability("build", "ChromeTests");               //To identify the test
           capabilities.setCapability("name", "Parallel_JUnit5Tests");
       }

       else if (browser.equals("Firefox")){
           capabilities.setCapability("browserName", "Firefox");    //To specify the browser
           capabilities.setCapability("version", "93.0");        //To specify the browser version
           capabilities.setCapability("platform", "Windows 10");     // To specify the OS
           capabilities.setCapability("build", "FirefoxTests");               //To identify the test
           capabilities.setCapability("name", "Parallel_JUnit5Tests");
       }

       else if (browser.equals("Edge")){
           capabilities.setCapability("browserName", "MicrosoftEdge");
           capabilities.setCapability("platform", "Windows 10");
           capabilities.setCapability("version","94.0");     // To specify the OS
           capabilities.setCapability("build", "EdgeTests");               //To identify the test
           capabilities.setCapability("name", "Parallel_JUnit5Tests");
       }
       capabilities.setCapability("network", true);      // To enable network logs
       capabilities.setCapability("visual", true);          // To enable step by step screenshot
       capabilities.setCapability("video", true);       // To enable video recording
       capabilities.setCapability("console", true);         // To capture console logs
       try {
           driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
       } catch (MalformedURLException e) {
           System.out.println("Invalid grid URL");
       } catch (Exception e) {
           System.out.println(e.getMessage());
       }
   }


   @Test
   public void test1(){
       // Code Implementation
}

   @Test
   public void test2(){

     //Code Implementation
   }

   @Test
   public void test3(){
          //Code Implementation       
   }

   @AfterTest
   public void tear(){
       driver.close();
   }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TestNG.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "http://TestNG.org/TestNG-1.0.dtd"&amp;gt;
&amp;lt;suite name="TestSuite" parallel="tests" thread-count="4"&amp;gt;
   &amp;lt;test name="ChromeBrowserTest"&amp;gt;
       &amp;lt;parameter name="browser" value="Chrome"/&amp;gt;
       &amp;lt;classes&amp;gt;
           &amp;lt;class name="com.pages.DemoTest1"&amp;gt;
           &amp;lt;/class&amp;gt;
       &amp;lt;/classes&amp;gt;
   &amp;lt;/test&amp;gt;
   &amp;lt;test name="FirefoxBrowserTest"&amp;gt;
       &amp;lt;parameter name="browser" value="Firefox" /&amp;gt;
       &amp;lt;classes&amp;gt;
           &amp;lt;class name="com.pages.DemoTest1"&amp;gt;
           &amp;lt;/class&amp;gt;
       &amp;lt;/classes&amp;gt;
   &amp;lt;/test&amp;gt;

   &amp;lt;test name="EdgeBrowserTest"&amp;gt;
       &amp;lt;parameter name="browser" value="Edge" /&amp;gt;
       &amp;lt;classes&amp;gt;
           &amp;lt;class name="com.pages.DemoTest1"&amp;gt;
           &amp;lt;/class&amp;gt;
       &amp;lt;/classes&amp;gt;
   &amp;lt;/test&amp;gt;
&amp;lt;/suite&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the TestNG.xml file, we pass different browsers as parameters for cross browser testing, and we use parallel = “tests” and thread-count=”4” parameters to run our tests in parallel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6a41w4l5hai05fk1qooi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6a41w4l5hai05fk1qooi.png" alt=" " width="512" height="354"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ‘Customizing Test Names’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;The TestNG framework does not allow for the customization of test names. However, we can give the tests a customized name in JUnit 5.&lt;/p&gt;
&lt;h4&gt;
  
  
  Customizing the test name in JUnit 5
&lt;/h4&gt;

&lt;p&gt;JUnit 5 provides an annotation @ DisplayName which aids in customizing the test names for better readability.&lt;/p&gt;

&lt;p&gt;Consider the below class with multiple tests, namely DemoTest1_A, DemoTest1_B, and DemoTest1_C. Most of the time, the method name wouldn’t be easier to depict the actual purpose of the test. However, in such cases, we can use the @ DisplayName annotation followed by a customized name which would help identify and understand the feature of the test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package ParallelTestsInJUnit;

import org.junit.jupiter.api.*;

public class DemoTest1 {

    @BeforeAll
    public static void start() {
        System.out.println("=======Starting junit 5 tests========");
    }

    @Test
    @DisplayName("Login_Test")
    void DemoTest1_A() {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName()+" =&amp;gt; executed successfully");
    }

    @Test
    @DisplayName("Product_Test")
    void DemoTest1_B() {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName()+" =&amp;gt; executed successfully");
    }

    @Test
    @DisplayName("Home_Test")
    void DemoTest1_C() {
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName()+" =&amp;gt; executed successfully");
    }

    @AfterAll
    public static void end() {
        System.out.println("All the tests are executed successfully");

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The console output shows the tests being named after the customized names given in the @ DisplayName annotation. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Console Output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdk8nv69pdu8gkqegd32u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdk8nv69pdu8gkqegd32u.png" alt=" " width="512" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, TestNG doesn’t support customizing the names of the test.&lt;/p&gt;

&lt;h3&gt;
  
  
  ‘Reporting’ in JUnit 5 and TestNG
&lt;/h3&gt;

&lt;p&gt;JUnit 5 doesn’t support any built-in report. But it can be integrated with plugins to generate reports.&lt;/p&gt;

&lt;p&gt;While that’s not the case in TestNG, it has an inbuilt HTML report generated after the test execution. Once the tests are executed by running the TestNG.xml file, a test- output folder will be created, which can be found after refreshing the project.&lt;/p&gt;

&lt;p&gt;The report will be named emailable-report.html. Right-click the report 🡪 Open With 🡪 Web Browser.&lt;/p&gt;

&lt;p&gt;The TestNG report would appear to be similar to the one below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn74614z8c0jufrr0qwkb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn74614z8c0jufrr0qwkb.png" alt=" " width="512" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The TestNG report would appear to be similar to the one below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdx7goewpamnnffc4w4u0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdx7goewpamnnffc4w4u0.png" alt=" " width="512" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AnotherTestNG report – index.html, can be viewed by right-clicking the test-output folder 🡪 Open With 🡪 Web Browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Index.html report&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkia4qzdnhzta2h7gr4ce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkia4qzdnhzta2h7gr4ce.png" alt=" " width="512" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the Right framework!
&lt;/h2&gt;

&lt;p&gt;So far, we have debated the various features available in JUnit 5 vs. TestNG. Choosing the right framework between JUnit 5 vs. TestNG has always been a common debate happening over the years. Both JUnit 5 and TestNG have been popular unit testing automation frameworks. &lt;/p&gt;

&lt;p&gt;Though JUnit had some drawbacks, it has been fixed and has most of the features as TestNG. Yet there are some differences between JUnit and TestNG. So depending upon the requirement and the features available in these frameworks, we have to choose the right framework for automation.&lt;/p&gt;

&lt;p&gt;I hope this comparative study will help you figure out the right automation framework. I would love to hear your comments on this article.&lt;/p&gt;

&lt;p&gt;Happy Testing!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
