<?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>DEV Community: Faisalkhatri123</title>
    <description>The latest articles on DEV Community by Faisalkhatri123 (@faisalkhatri123).</description>
    <link>https://dev.to/faisalkhatri123</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%2F956951%2Fa0c2da1d-31c6-4fac-a6c2-98d781cfaf06.jpeg</url>
      <title>DEV Community: Faisalkhatri123</title>
      <link>https://dev.to/faisalkhatri123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/faisalkhatri123"/>
    <language>en</language>
    <item>
      <title>Automating Flutter Apps Using Appium Flutter Driver With Java</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Mon, 12 Feb 2024 14:45:06 +0000</pubDate>
      <link>https://dev.to/testmuai/automating-flutter-apps-using-appium-flutter-driver-with-java-57l6</link>
      <guid>https://dev.to/testmuai/automating-flutter-apps-using-appium-flutter-driver-with-java-57l6</guid>
      <description>&lt;p&gt;Mobile users worldwide have been constantly increasing over the recent years. Mobile applications have enabled the delivery of daily-use goods to luxury commodities at the customers’ doorstep.&lt;/p&gt;

&lt;p&gt;As per &lt;a href="https://www.statista.com/statistics/271644/worldwide-free-and-paid-mobile-app-store-downloads/" rel="noopener noreferrer"&gt;Statista&lt;/a&gt;, mobile app downloads increased to 255 billion in 2022, up by more than 80 percent from 140.7 billion app downloads in 2016. Users downloaded almost 77 billion mobile applications worldwide during the first half of 2023.&lt;/p&gt;

&lt;p&gt;The growing demand for mobile applications necessitates continuous development of robust frameworks that enable quick and adaptable mobile app creation, keeping pace with rapidly evolving business needs.&lt;/p&gt;

&lt;p&gt;There are many native mobile application development frameworks, like React Native, Ionic, Xamarin, Swift, etc., that are popular and trending in the market. Flutter is the latest addition to these frameworks that support building cross-platform application development. As shown below, Flutter has gained immense popularity compared to other cross-platform &lt;a href="https://www.lambdatest.com/blog/best-mobile-app-testing-framework/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;mobile app testing frameworks&lt;/a&gt; available in the market!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learn why Python is the top choice for automation testing. This comprehensive tutorial provides a step-by-step guide to&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Python automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to help you streamline your testing process.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2At94JyPZfbdGmCGJA.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%2F1200%2F0%2At94JyPZfbdGmCGJA.png" alt="image" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.statista.com/statistics/869224/worldwide-software-developer-working-hours/" rel="noopener noreferrer"&gt;&lt;em&gt;Source&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For faster feedback on the build quality, it is recommended to perform &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; as it can provide accurate results on executing the same tests multiple times.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium testing&lt;/a&gt; tutorial, we will learn to test the Flutter mobile application using the Appium Flutter Driver with Java. We will also deep dive into installing Flutter, using Inspector, and writing mobile automation tests using Appium.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Flutter?
&lt;/h3&gt;

&lt;p&gt;Flutter is Google’s cross-platform open-source mobile development framework for developing Android and iOS applications using a single code base. Introduced in May 2017, it is a comprehensive framework encompassing widgets, a rendering engine, testing and integration tools, and APIs. This all-inclusive framework empowers developers to build and deploy mobile applications effortlessly.&lt;/p&gt;

&lt;p&gt;Since its launch, it has proven to be a great cross-platform framework that can be used to develop high-quality applications that look like native Android and iOS apps. Examples of applications built using Flutter include Google, Alibaba, and many others.&lt;/p&gt;

&lt;p&gt;Flutter is a convenient toolkit that is easy for creating animations and high-quality UI components. It has 250.9K followers over X (earlier Twitter), 160K Stars on &lt;a href="https://github.com/flutter/flutter" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, and 124K followers on &lt;a href="https://www.reddit.com/r/FlutterDev/?rdt=65335" rel="noopener noreferrer"&gt;Reddit&lt;/a&gt;. When writing this blog, the latest version of Flutter is 3.16.&lt;/p&gt;

&lt;h3&gt;
  
  
  Different types of mobile applications
&lt;/h3&gt;

&lt;p&gt;There are three different &lt;a href="https://www.lambdatest.com/blog/types-of-mobile-apps/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;types of mobile applications&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Native mobile app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mobile web app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hybrid mobile app&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What are native mobile applications?
&lt;/h3&gt;

&lt;p&gt;Native mobile applications are developed specifically for the phone’s operating system. Almost 98% of the phones run on either Android or iOS. These applications are installed on the device and store the data on it. These applications have access to essential phone peripherals like cameras, GPS, microphones, and more.&lt;/p&gt;

&lt;p&gt;While developing native Android applications, developers commonly use languages like Kotlin or Java, while the development of iOS applications typically involves languages such as Swift and Objective-C. Some native mobile applications include the Calculator app, Google Maps, and popular games like Pokémon GO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&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&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;mobile testing platform with real devices&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are mobile web applications?
&lt;/h3&gt;

&lt;p&gt;Mobile web applications are web applications that are optimized for mobile screen(s). They are websites written in HTML/CSS, run by a browser, and aren’t mobile applications.&lt;/p&gt;

&lt;p&gt;These applications don’t need to be downloaded and installed on the phone. It can access a limited amount of the device’s native features and information like geolocation, media, etc. Examples of mobile web applications include the Uber app and shopping websites like amazon.com. These websites can run on the mobile browser and perform all the functions like a mobile application.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are hybrid mobile applications?
&lt;/h3&gt;

&lt;p&gt;Hybrid applications combine elements of both Native and Web applications. The core application is built using web technologies like HTML, CSS, and JavaScript and then wrapped within a native application.&lt;/p&gt;

&lt;p&gt;The app is run within a native application and its embedded browser rather than being shown using a mobile browser. An Android application uses the WebView element to display the app, while the iOS application uses the WKWebView for the same function.&lt;/p&gt;

&lt;p&gt;In short, Hybrid Mobile app = Native app + Mobile Web app. Examples of Hybrid applications include Facebook, Twitter, LinkedIn and Instagram.&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%2F1200%2F0%2ALKMxUJfcWZtyCWux.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%2F1200%2F0%2ALKMxUJfcWZtyCWux.png" alt="image" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Flutter applications v/s Native applications
&lt;/h3&gt;

&lt;p&gt;Assessing native applications is straightforward, thanks to the availability of tools and frameworks designed for conducting &lt;a href="https://www.lambdatest.com/learning-hub/unit-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;unit testing&lt;/a&gt; on these applications.&lt;/p&gt;

&lt;p&gt;The Espresso framework by Android can be used to test native Android applications. Similarly, the XCTest framework can be used to test iOS applications. Over and above these frameworks, other &lt;a href="https://www.lambdatest.com/blog/mobile-app-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;mobile app testing tools&lt;/a&gt; like &lt;a href="https://www.lambdatest.com/learning-hub/webdriverio?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;WebdriverIO&lt;/a&gt; and &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt; are popular and used for testing mobile applications thoroughly. Recently, Appium released a 2.0 version with more advanced features, making it a more robust framework.&lt;/p&gt;

&lt;p&gt;For testing the Flutter app, the &lt;em&gt;flutter_driver&lt;/em&gt; that comes pre-installed with Flutter SDK can be used to write automated tests. However, the problem in using &lt;em&gt;flutter_driver&lt;/em&gt; is that the test engineer should be well versed in Dart programming language to write tests using &lt;em&gt;flutter_driver&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Flutter applications can be automated using the &lt;a href="https://github.com/appium-userland/appium-flutter-driver" rel="noopener noreferrer"&gt;Appium Flutter Driver&lt;/a&gt;, developed by the Appium community. With the Appium Flutter Driver, there is no need to get exposure to the Dart programming language. The automation tests of the Flutter application can be written in Java, JavaScript, Python, etc., the languages supported by the Appium framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learn why Python is the top choice for automation testing. This comprehensive tutorial provides a step-by-step guide to&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Python automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to help you streamline your testing process.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To automate any mobile application, we need to locate the selectors that can be used to locate the mobile elements on the application and interact with them. The &lt;a href="https://www.lambdatest.com/blog/appium-inspector-for-apps/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Appium Inspector&lt;/a&gt; tool cannot be used to find the Flutter application’s selectors.&lt;/p&gt;

&lt;p&gt;The Flutter Widget Inspector tool can visualize and explore Flutter widget trees and help understand the existing layouts. We will also require help from developers and ask them to add the respective locators in the application so that they can be used in the automated tests to interact easily with the mobile elements.&lt;/p&gt;

&lt;p&gt;The following is a summarized list that shows the difference between testing the Native and Flutter applications:&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%2F1200%2F1%2AxPrBBXJ8K_OPtRnLwyFr2A.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%2F1200%2F1%2AxPrBBXJ8K_OPtRnLwyFr2A.png" alt="image" width="800" height="669"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s dive deep into how to perform automated &lt;a href="https://www.lambdatest.com/blog/flutter-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Flutter testing&lt;/a&gt; using the Appium Flutter Driver with Java.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting started with Flutter
&lt;/h3&gt;

&lt;p&gt;As we learned in the earlier section of this blog on using Appium Flutter Driver with Java, Appium Inspector cannot inspect and locate the Flutter application’s mobile elements. Hence, we need a Flutter Widget Inspector for it.&lt;/p&gt;

&lt;p&gt;In this section, we will learn about downloading and installing Flutter SDK. Next, we will check out a Flutter sample app and update the required settings in Android Studio. Finally, we will run the Flutter app on the &lt;a href="https://www.lambdatest.com/blog/android-emulators/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Android emulator&lt;/a&gt; and check out the Flutter Widget Inspector.&lt;/p&gt;

&lt;p&gt;We need access to the Flutter application’s code base for running the Flutter Widget Inspector. The following steps will help us install Flutter on the local machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Downloading and Installing Flutter SDK
&lt;/h3&gt;

&lt;p&gt;You can &lt;a href="https://docs.flutter.dev/get-started/install" rel="noopener noreferrer"&gt;download Flutter SDK&lt;/a&gt; from Flutter’s official website for Windows, macOS, Linux, and ChromeOS 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ATLIAb5g81KDhfsJR.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%2F1200%2F0%2ATLIAb5g81KDhfsJR.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am currently using macOS, so I will be clicking on the macOS box and navigating to the download page for further installation steps on macOS.&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%2F1200%2F0%2AXOkFUUrDy0jbJRAq.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%2F1200%2F0%2AXOkFUUrDy0jbJRAq.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the macOS installation details page, I will select and download the &lt;em&gt;Apple Silicon zip&lt;/em&gt; file, as I currently use the &lt;em&gt;Macbook Pro&lt;/em&gt; with an &lt;em&gt;M2&lt;/em&gt; chip. Another zip file for Macs with Intel chips can also be used.&lt;/p&gt;

&lt;p&gt;Once the zip file is downloaded, we must perform the following steps to install Flutter SDK on the local machine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extract the downloaded zip file.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Setting the Environment variable for Flutter.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Run Flutter Doctor.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Explore the Top 17 Programming for&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/top-test-automation-languages/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Automation testing Languages&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;in 2024.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloning the Flutter sample mobile app
&lt;/h3&gt;

&lt;p&gt;With the help of the following command, the Flutter sample repository can be cloned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone git@github.com:flutter/samples.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Opening the Flutter sample application in Android Studio
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://github.com/flutter/samples/tree/main/provider_shopper" rel="noopener noreferrer"&gt;Provider Shopper&lt;/a&gt; sample Flutter application will be used 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A05Lh2HH9T57reQNB.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%2F1200%2F0%2A05Lh2HH9T57reQNB.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the project in the Android Studio app after the successful cloning of the sample project repository is complete.&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%2F1200%2F0%2AuQQkpwKmEz_LZR18.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%2F1200%2F0%2AuQQkpwKmEz_LZR18.png" alt="image" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the Flutter plugin to Android Studio
&lt;/h3&gt;

&lt;p&gt;The Flutter plugin needs to be added to Android Studio as it helps compile and run the Flutter app. The Flutter plugin can be installed using the &lt;em&gt;Android Studio &amp;gt;&amp;gt; Settings &amp;gt;&amp;gt; Plugins&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AeIBZx_XkiOHzkhfI.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%2F1200%2F0%2AeIBZx_XkiOHzkhfI.png" alt="image" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting the Flutter SDK path in Android Studio
&lt;/h3&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%2F1200%2F0%2A2shdJLqTk10h1Mog.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%2F1200%2F0%2A2shdJLqTk10h1Mog.png" alt="image" width="800" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: The Flutter SDK includes the full Dart SDK and has the Dart command-line interface in its bin folder.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once Flutter SDK is configured, Dart SDK will be auto-configured.&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%2F1200%2F0%2A0wbNb4OCnpYwMim3.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%2F1200%2F0%2A0wbNb4OCnpYwMim3.png" alt="image" width="800" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating the dev dependencies in the pubspec.yml file
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;dev_dependencies&lt;/em&gt; for &lt;em&gt;flutter_test&lt;/em&gt;, &lt;em&gt;test,&lt;/em&gt; and &lt;em&gt;flutter_driver&lt;/em&gt; need to be added in the &lt;em&gt;pubspec.yml&lt;/em&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dev_dependencies:
 test: any
 flutter_test:
   sdk: flutter
 flutter_driver:
   sdk: flutter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The below screenshot of the &lt;em&gt;pubspec.yml&lt;/em&gt; file shows the additions of &lt;em&gt;dev_dependencies&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AF_Yg7xt0lG_KzlBL.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%2F1200%2F0%2AF_Yg7xt0lG_KzlBL.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Filename: pubspec.yml&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AXrQ4JBzFv2VhYHbR.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%2F1200%2F0%2AXrQ4JBzFv2VhYHbR.png" alt="image" width="800" height="980"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learn why Python is the top choice for automation testing. This comprehensive tutorial provides a step-by-step guide to&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Python automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to help you streamline your testing process.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Importing the dev dependencies
&lt;/h3&gt;

&lt;p&gt;The &lt;em&gt;dev_dependencies&lt;/em&gt; updated in the &lt;em&gt;pubspec.yml&lt;/em&gt; need to be imported, which can be done using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter pub get
&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2As9TXltlsZw0kHM34.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%2F1200%2F0%2As9TXltlsZw0kHM34.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Updating the main.dart file
&lt;/h3&gt;

&lt;p&gt;The following import statement needs to be added to the &lt;em&gt;main.dart&lt;/em&gt; file for importing &lt;em&gt;flutter_driver_extension&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;import 'package:flutter_driver/driver_extension.dart';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;enableFlutterDriverExtension()&lt;/em&gt; method should be added in the &lt;em&gt;main()&lt;/em&gt; method before the &lt;em&gt;runApp&lt;/em&gt; statement in the &lt;em&gt;main.dart&lt;/em&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() {
    enableFlutterDriverExtension();
    runApp(MyApp());
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the screenshot of the &lt;em&gt;main.dart&lt;/em&gt; file after adding the code mentioned above statements:&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%2F1200%2F0%2ALUi70vDO_PBE7AZN.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%2F1200%2F0%2ALUi70vDO_PBE7AZN.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Starting the Flutter Android application on the Android emulator
&lt;/h3&gt;

&lt;p&gt;The Flutter application can be run on the Android emulator by using the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Start the Android emulator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select the Android emulator name from the dropdown box, click the &lt;strong&gt;Play&lt;/strong&gt; button to build the Provider Shopper application locally, and run it on the selected emulator.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How to test Android Flutter applications using Appium Flutter Driver?
&lt;/h3&gt;

&lt;p&gt;The following are the details about the technical stack used in this blog to automate the Flutter application using Appium Flutter Driver with Java.&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%2F1200%2F1%2AeG34qo3V4PQFjTu8xI2vqA.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%2F1200%2F1%2AeG34qo3V4PQFjTu8xI2vqA.png" alt="image" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first step in automating any mobile application is to locate the mobile elements to perform the interactions on it. In the case of Flutter applications, the Flutter Widget Inspector, which comes as an inbuilt tool with Flutter, will be used to inspect elements. The Appium Inspector is incapable of locating the Flutter mobile elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&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 test on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;online real device&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Flutter Widget Inspector?
&lt;/h3&gt;

&lt;p&gt;Within the Flutter framework, Widgets serve as the fundamental building blocks. They encompass form controls like textboxes and buttons and layouts like centering, padding, and rows.&lt;/p&gt;

&lt;p&gt;Flutter widget trees can be explored and visualized using the Flutter Widget Inspector. It helps in understanding existing layouts and diagnosing the layout issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Flutter Widget Inspector&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AI28LYIoOInLYzCje.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%2F1200%2F0%2AI28LYIoOInLYzCje.png" alt="image" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Flutter Inspector is a tool that helps explore and visualize the Flutter widget trees. It can help locate the selectors for the mobile elements used in the &lt;a href="https://www.lambdatest.com/mobile-automation-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile automation tests&lt;/a&gt;. It can also be used to understand the existing layouts and diagnose related issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use Flutter Widget Inspector?
&lt;/h3&gt;

&lt;p&gt;Flutter Widget Inspector can only be started after the local build is created and the Flutter application runs in the Emulator/Simulator. To showcase the work of Flutter Widget Inspector, we will be running the local build on an Android emulator.&lt;/p&gt;

&lt;p&gt;Flutter Widget Inspector can be started by clicking on the Flutter Inspector toolbar on the extreme right of the Android Studio screen.&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%2F1200%2F0%2AD9yzyL3n-fcDmrVf.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%2F1200%2F0%2AD9yzyL3n-fcDmrVf.png" alt="image" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Flutter Widget Inspector should open as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AszW1wo4NCy-M1F0L.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%2F1200%2F0%2AszW1wo4NCy-M1F0L.png" alt="image" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to follow the below steps to locate the mobile elements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on the &lt;strong&gt;Select Widget Mode&lt;/strong&gt; button in Flutter Inspector.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the Android emulator and select the field for which the mobile element needs to be located.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s locate the mobile element for the Username field of the Provider Shopper app by clicking on the &lt;strong&gt;Select Widget Mode&lt;/strong&gt; button and selecting the Username field in the app. It will locate the mobile element for the Username field, and as shown in the screenshot below, it shows the mobile element as “TextFormField”.&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%2F1200%2F0%2AcCzAAsqJf8gBFGdq.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%2F1200%2F0%2AcCzAAsqJf8gBFGdq.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, if you notice, there is no key attached to it. Hence, it will be challenging to locate this field as we can see other elements for which the same element, “TextFormField,” is shown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need to convert BCD codes to Decimal quickly? Our&lt;/em&gt;&lt;/strong&gt; &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=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;BCD to Decimal&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Converter tool provides an easy way to convert BCD codes to Decimal. Try it now and save time.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s add a key to the Username field to make it unique so we can locate it easily.&lt;/p&gt;

&lt;p&gt;To add a key, we need to minimize the Flutter Widget Inspector window; just below it, we will notice the &lt;em&gt;login.dart&lt;/em&gt; file is already open. This file houses all the elements and their respective properties for the login 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%2F1200%2F0%2AiznQYSaihO1eyy1Q.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%2F1200%2F0%2AiznQYSaihO1eyy1Q.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s add the key for the Username field by adding the following line of code:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;key: const Key("username"),&lt;/code&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%2F1200%2F0%2AAlQsLthvEEiW7E7P.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%2F1200%2F0%2AAlQsLthvEEiW7E7P.png" alt="image" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save the login.dart file after adding the key for the Username field.&lt;/p&gt;

&lt;p&gt;Halt the locally running app, restart it, and build it locally. Then, utilize the Flutter Widget Inspector to confirm the successful addition of the key by inspecting the Username field.&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%2F1200%2F0%2AA1R4mLJRFt1SHjia.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%2F1200%2F0%2AA1R4mLJRFt1SHjia.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also see that the key value “username” is displayed next to the &lt;em&gt;TextFormField&lt;/em&gt; for &lt;em&gt;Username&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Congratulations! The key for the Username field is successfully added and can be used as a locator for locating this field in the automation tests.&lt;/p&gt;

&lt;p&gt;Let’s repeat the same steps for the Password field and update its key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Update Key for Password field&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AgUKH4iMAaW8gvhui.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%2F1200%2F0%2AgUKH4iMAaW8gvhui.png" alt="image" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Password Key updated successfully can be viewed in Flutter Widget Inspector&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AxYdERqwKpMjqtJWX.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%2F1200%2F0%2AxYdERqwKpMjqtJWX.png" alt="image" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we need to locate the mobile element for the &lt;strong&gt;ENTER&lt;/strong&gt; button to click on it to log in to the application.&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%2F1200%2F0%2Agf08tFGOaeHS0rNC.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%2F1200%2F0%2Agf08tFGOaeHS0rNC.png" alt="image" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will follow the same steps as we did for the Username and Password fields, but we will not be updating the key for this button; as we can see, it already has the mobile element — &lt;em&gt;TEXT&lt;/em&gt;– with the value “Enter”. This can be used in automated tests for interacting with this button.&lt;/p&gt;

&lt;p&gt;To run the Android automation tests, we would require the apk file to be generated. As we use Appium Flutter Driver with Java to interact with the app and run the automation tests, we must compile the build in &lt;code&gt;debug&lt;/code&gt; or &lt;code&gt;profile&lt;/code&gt; mode as Appium Flutter Driver does not support the apps in &lt;code&gt;release&lt;/code&gt; mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Decode&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/utf8-decode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;UTF8 encoded&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;data with ease using our online UTF8 Decode tool now and simplify your workflow! Decode your data quickly and accurately.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Generating the build for Android and iOS
&lt;/h3&gt;

&lt;p&gt;The following commands can be used to generate the Flutter app build in debug and profile mode for Android and debug, profile, and simulator mode for iOS.&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%2F1200%2F1%2A8sEPN3RFt1M-6iVnn6T85Q.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%2F1200%2F1%2A8sEPN3RFt1M-6iVnn6T85Q.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please make sure that before you run the command for generating the build, the local instance, if running, should be stopped by pressing the red &lt;strong&gt;Stop&lt;/strong&gt; button on the toolbar.&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%2F1200%2F0%2ABl0BizH7sdEh6Uxr.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%2F1200%2F0%2ABl0BizH7sdEh6Uxr.png" alt="image" width="800" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following command should be executed in the terminal for generating the Android build in &lt;em&gt;debug&lt;/em&gt; mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter build apk --debug 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the build generation is finished, the build output path will be printed 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ALI3PXlGd0vqyENgC.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%2F1200%2F0%2ALI3PXlGd0vqyENgC.png" alt="image" width="800" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s navigate to the path printed in the console and copy the apk file generated so we can use it in our automation 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ACwWBlY1iyDl-0Rwz.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%2F1200%2F0%2ACwWBlY1iyDl-0Rwz.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing the automated tests for the Flutter app
&lt;/h3&gt;

&lt;p&gt;The following are the summarized steps we did in the previous part of the blog before we wrote the automated tests using Appium Flutter Driver with Java:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Configure the Flutter SDK.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set up the Flutter app project in Android Studio.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Locate the mobile elements using Flutter Widget Inspector.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate the Android build.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, we are in the last stage of this blog on using Appium Flutter Driver with Java, where we will be writing the automated tests for the &lt;a href="https://github.com/flutter/samples/tree/main/provider_shopper" rel="noopener noreferrer"&gt;Provider Shopper&lt;/a&gt; — a sample app by Flutter. We will run the tests on the Samsung Galaxy S21 5G Real Device on the LambdaTest cloud grid that has Android 13 installed on it.&lt;/p&gt;

&lt;p&gt;LambdaTеst is an AI-powered tеst orchеstration and еxеcution platform that allows you to perform Flutter app tеsting on a &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;rеal dеvicе cloud&lt;/a&gt; both manually and automatically using tеsting framеworks such as Appium, Espresso, and XCUITеst.&lt;/p&gt;

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

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorials on &lt;a href="https://www.lambdatest.com/learning-hub/mobile-app-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;mobile app testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium automation&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;The following test scenario will be automated in the app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the Provider Shopper sample app on the Samsung Galaxy S21 5G real device on LambdaTest Cloud grid&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the Login Page, enter Username and Password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;ENTER&lt;/strong&gt; button to log in to the app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check that the title “Catalog” is displayed on the next page after successful login.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need to encode your text into UTF-8 format? Use our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/utf8-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;UTF-8 Encode tool&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to encode your text for seamless communication across all platforms and devices. Try it for free today.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Login Page of Provider Shopper app&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AAQzJk7iHv6QjEOWu.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%2F1200%2F0%2AAQzJk7iHv6QjEOWu.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Catalog Page of Provider Shopper app&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AshpalICOrXn6w3sZ.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%2F1200%2F0%2AshpalICOrXn6w3sZ.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation [Test Scenario]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before implementing the test scenarios, we must download and install the Appium Flutter Driver. It can be installed using the terminal with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; appium driver install --source=npm appium-flutter-driver 
&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AOHY0Gxj3bT1v8HQm.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%2F1200%2F0%2AOHY0Gxj3bT1v8HQm.png" alt="image" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the installation of Appium Flutter Driver, we are now ready to start writing the test automation scripts for the Provider Shopper Flutter app.&lt;/p&gt;

&lt;p&gt;A Maven project needs to be created, and the dependencies for Appium, Appium Flutter Finder, and TestNG should be added to the &lt;em&gt;pom.xml&lt;/em&gt; 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;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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;flutter-lambdatest-demo&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

    &amp;lt;name&amp;gt;flutter-lambdatest-demo&amp;lt;/name&amp;gt;
    &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

    &amp;lt;properties&amp;gt;
        &amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
        &amp;lt;appium-java-client-version&amp;gt;9.0.0&amp;lt;/appium-java-client-version&amp;gt;
        &amp;lt;testng.version&amp;gt;7.8.0&amp;lt;/testng.version&amp;gt;
        &amp;lt;appium-flutterfinder-java.version&amp;gt;1.0.1&amp;lt;/appium-flutterfinder-java.version&amp;gt;
        &amp;lt;lombok-version&amp;gt;1.18.30&amp;lt;/lombok-version&amp;gt;
        &amp;lt;maven.compiler.version&amp;gt;3.11.0&amp;lt;/maven.compiler.version&amp;gt;
        &amp;lt;java.release.version&amp;gt;17&amp;lt;/java.release.version&amp;gt;
        &amp;lt;maven.surefire.version&amp;gt;3.2.2&amp;lt;/maven.surefire.version&amp;gt;
        &amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
        &amp;lt;suite-xml&amp;gt;testng.xml&amp;lt;/suite-xml&amp;gt;
        &amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;
    &amp;lt;/properties&amp;gt;

    &amp;lt;dependencies&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/io.appium/java-client --&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;io.appium&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;java-client&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${appium-java-client-version}&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;${testng.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;io.github.ashwithpoojary98&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;appium_flutterfinder_java&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${appium-flutterfinder-java.version}&amp;lt;/version&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.projectlombok&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;lombok&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${lombok-version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;

    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
                    &amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
                    &amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
                &amp;lt;/configuration&amp;gt;
            &amp;lt;/plugin&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${maven.surefire.version}&amp;lt;/version&amp;gt;
                &amp;lt;executions&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                    &amp;lt;/execution&amp;gt;
                &amp;lt;/executions&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
                    &amp;lt;properties&amp;gt;
                        &amp;lt;property&amp;gt;
                            &amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
                            &amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
                        &amp;lt;/property&amp;gt;
                    &amp;lt;/properties&amp;gt;
                    &amp;lt;suiteXmlFiles&amp;gt;
                        &amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
                    &amp;lt;/suiteXmlFiles&amp;gt;
                    &amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
                &amp;lt;/configuration&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;


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

&lt;/div&gt;



&lt;p&gt;Once the dependencies are updated in the pom.xml it is the time now to start with the configuration of Android Driver and its respective capabilities so we could run the tests on the Android device successfully. For setting the Android Driver and its capabilities, &lt;a href="https://github.com/mfaisalkhatri/flutter-lambdatest-demo/blob/main/src/main/java/io/github/mfaisalkhatri/drivers/AndroidDriverManager.java" rel="noopener noreferrer"&gt;&lt;em&gt;AndroidDriverManager&lt;/em&gt;&lt;/a&gt; class is created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Builder
public class AndroidDriverManager {

    private static final ThreadLocal&amp;lt;AndroidDriver&amp;gt; DRIVER = new ThreadLocal&amp;lt;&amp;gt;();

    private String buildName;
    private String testName;
    private Platform platform;
    private String platformVersion;
    private String deviceName;
    private String app;
    private static final String LT_USERNAME = System.getProperty("LT_USERNAME");
    private static final String LT_ACCESS_KEY = System.getProperty("LT_ACCESS_KEY");
    private static final String GRID_URL = "@mobile-hub.lambdatest.com/wd/hub";


    public AndroidDriverManager createAndroidDriver() {
        try {
            setDriver(new AndroidDriver(new URL(format("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)), setCapabilities()));
            setupBrowserTimeouts();

        } catch (MalformedURLException e) {
            throw new Error("Error while creating Android Driver Session");
        }
        return this;
    }

    public AndroidDriver getAndroidDriver() {
        return AndroidDriverManager.DRIVER.get();
    }

    public void quitDriver() {
        if (null != DRIVER.get()) {
            getAndroidDriver().quit();
            DRIVER.remove();
        }
    }

    private HashMap&amp;lt;String, Object&amp;gt; ltOptions() {
        final var ltOptions = new HashMap&amp;lt;String, Object&amp;gt;();
        ltOptions.put("username", LT_USERNAME);
        ltOptions.put("accessKey", LT_ACCESS_KEY);
        ltOptions.put("platformName", platform);
        ltOptions.put("deviceName", deviceName);
        ltOptions.put("platformVersion", platformVersion);
        ltOptions.put("app", app);
        ltOptions.put("automationName", "Flutter");
        ltOptions.put("build", buildName);
        ltOptions.put("name", testName);
        ltOptions.put("w3c", true);
        ltOptions.put("isRealMobile", true);
        ltOptions.put("autoGrantPermissions", true);
        ltOptions.put("plugin", "java-testNG");
        ltOptions.put ("visual", true);
        ltOptions.put ("console", true);
        ltOptions.put ("devicelog", true);
        return ltOptions;
    }

    private DesiredCapabilities setCapabilities() {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("lt:options", ltOptions());
        return capabilities;
    }
    private void setDriver(final AndroidDriver driver) {
        AndroidDriverManager.DRIVER.set(driver);
    }

    private void setupBrowserTimeouts() {
        getAndroidDriver().manage()
                .timeouts()
                .implicitlyWait(Duration.ofSeconds(20));
    }
}
&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ADYAEvYjyeVQCme6x.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%2F1200%2F0%2ADYAEvYjyeVQCme6x.png" alt="image" width="382" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;em&gt;AndroidDriverManager&lt;/em&gt; class, the first method that we will be discussing is the &lt;em&gt;createAndroidDriver()&lt;/em&gt; that will set the Android Driver and its capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need to convert&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/convert-hex-color-to-rgb?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Hex to RGB&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;values? Use our Hex color to RGB Converter tool to convert Hex colors to RGB values — it’s fast, free, and accurate. Try it now for hassle-free conversions.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AKlwBxcISqGBofyrc.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%2F1200%2F0%2AKlwBxcISqGBofyrc.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;ThreadLocal&lt;/em&gt; class is used to instantiate the &lt;em&gt;Android Driver&lt;/em&gt; instance. This ensures that each thread has its isolated instance of the &lt;em&gt;Android Driver&lt;/em&gt;. This will help us run the tests in parallel smoothly. Next, the &lt;em&gt;setDriver()&lt;/em&gt; method will set the Android Driver.&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%2F1200%2F0%2AARPW0T8fgZ97NS6N.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%2F1200%2F0%2AARPW0T8fgZ97NS6N.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For running the tests on the LambdaTest cloud grid, we need to provide the LambdaTest &lt;em&gt;Username, Access Key,&lt;/em&gt; and Grid URL along with the desired capabilities. The LambdaTest &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;Access Key&lt;/em&gt; will be supplied while running the tests as the respective values are taken using the &lt;em&gt;System.getProperty&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AwEyNiEObBWveIcWz.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%2F1200%2F0%2AwEyNiEObBWveIcWz.png" alt="image" width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The LambdaTest &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;Access Key&lt;/em&gt; can be fetched from the Account Settings &amp;gt;&amp;gt; Password &amp;amp; Security screen after logging in to the LambdaTest website.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;setCapabilities()&lt;/em&gt; method sets the desired capabilities for running the test on the LambdaTest cloud 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AsUGc4nZpwHv4v2fF.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%2F1200%2F0%2AsUGc4nZpwHv4v2fF.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A separate &lt;em&gt;ltOptions()&lt;/em&gt; method has been created to allow us to set all the LambdaTest capabilities for running the test on real Android devices. We need to provide the capabilities for &lt;em&gt;automationName&lt;/em&gt; with the value “Flutter”. This particular capability setting needs to be provided for Flutter apps only.&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%2F1200%2F0%2ANO2I5Uls-9LUlyrM.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%2F1200%2F0%2ANO2I5Uls-9LUlyrM.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These capabilities can easily be found on the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator&lt;/a&gt;, which generates the code while you set the desired capabilities from the UI.&lt;/p&gt;

&lt;p&gt;You may notice that there are variables set for the following values in the &lt;em&gt;ltOptions()&lt;/em&gt; method:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LT_USERNAME&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LT_ACCESS_KEY&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Platform&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Platform Version&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Device Name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;App URL&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these values will be set using the &lt;em&gt;testng.xml&lt;/em&gt; file hence the respective variables have been set here. This allows us to keep the platform and device details dynamic in the code and manage it using the &lt;em&gt;testng.xml&lt;/em&gt; to run the test on different platform and device combinations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a class="mentioned-user" href="https://dev.to/builder"&gt;@builder&lt;/a&gt;&lt;/em&gt; annotation has been placed over the &lt;em&gt;AndroidDriverManager&lt;/em&gt; class. It is an annotation from the Lombok library, and it will help set the platform, version, device, etc. details in builder pattern format.&lt;/p&gt;

&lt;p&gt;Once the Android Driver and the desired capabilities are set. Next, we must find the mobile elements to interact with them and run the automation test.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model (POM)&lt;/a&gt; is used in this project as it helps the code maintainability, readability, and reusability. Page Object Model implementation will create separate classes to maintain the Login and Catalog pages.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;LoginPage&lt;/em&gt; class will handle all the Page Objects of the Login page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class LoginPage {

    private final AppiumDriver driver;
    private final FlutterFinder finder;

    public LoginPage(final AppiumDriver driver) {
        this.driver = driver;
        this.finder = new FlutterFinder(driver);
    }

    private WebElement userNameField() {
        return this.finder.byValueKey("username");
    }

    private WebElement passwordField() {
        return this.finder.byValueKey("password");
    }

    private WebElement enterBtn() {
        return this.finder.byText("ENTER");
    }

    public CatalogPage performLogin(final String userName, final String password) {
        this.userNameField().sendKeys(userName);
        this.passwordField().sendKeys(password);
        this.enterBtn().click();
        return new CatalogPage(this.driver);

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

&lt;/div&gt;



&lt;p&gt;The mobile elements for the Username and Password fields are returned by the &lt;em&gt;userNameField()&lt;/em&gt; and &lt;em&gt;passwordField()&lt;/em&gt; methods using the &lt;em&gt;byValuKey()&lt;/em&gt; method of Appium Flutter Finder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need to decode an encoded URL? Our free online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/url-decode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;URL Decode tool&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;can help to decode any encoded URL. Fast, simple, and reliable, Try it now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Likewise, the mobile element for the &lt;strong&gt;ENTER&lt;/strong&gt; button is returned by the &lt;em&gt;enterBtn()&lt;/em&gt; method. The &lt;em&gt;performLogin()&lt;/em&gt; method will help interact with the &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;Password&lt;/em&gt; fields by entering the respective values in the field and clicking the &lt;strong&gt;ENTER&lt;/strong&gt; button to perform the login action.&lt;/p&gt;

&lt;p&gt;An instance of the &lt;em&gt;CatalogPage&lt;/em&gt; class is returned by the &lt;em&gt;performLogin()&lt;/em&gt; method, as the app will move to the Catalog page after login.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;CatalogPage&lt;/em&gt; class will take care of all the Page Objects of the Catalog page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class CatalogPage {

    private final FlutterFinder finder;

    public CatalogPage(final AppiumDriver driver) {
        this.finder = new FlutterFinder(driver);
    }

    public String pageTitle() {
        return this.finder.byText("Catalog").getText();
    }

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

&lt;/div&gt;



&lt;p&gt;The title of the Catalog page will be located by the &lt;em&gt;pageTitle()&lt;/em&gt; method using the &lt;em&gt;byText()&lt;/em&gt; method of Appium Flutter Finder and will return its text in String format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up the Base Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, verify the scenario discussed in the earlier section by writing the test. The first step is to create a &lt;a href="https://github.com/mfaisalkhatri/flutter-lambdatest-demo/blob/main/src/test/java/io/github/mfaisalkhatri/tests/BaseAndroidTest.java" rel="noopener noreferrer"&gt;&lt;em&gt;BaseAndroidTest&lt;/em&gt;&lt;/a&gt; class that will initialize the Android Driver and set the respective desired capabilities to run the tests on real Android Device; finally, it will gracefully quit the driver after the tests 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;public class BaseAndroidTest {

    protected AndroidDriverManager androidDriverManager;

    @Parameters({"buildName", "testName", "app", "platformName", "version", "device"})
    @BeforeClass(alwaysRun = true)
    public void setupTest(final String buildName, final String testName, @Optional("app") final String app, final Platform platform, final String platformVersion,
                          final String deviceName) {
            this.androidDriverManager = AndroidDriverManager.builder()
                    .buildName(buildName)
                    .testName(testName)
                    .app(app)
                    .platform(platform)
                    .platformVersion(platformVersion)
                    .deviceName(deviceName)
                    .build()
                    .createAndroidDriver();
    }

    @AfterClass(alwaysRun = true)
    public void tearDown() {
        this.androidDriverManager.quitDriver();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;setupTest()&lt;/em&gt; method in the &lt;em&gt;BaseAndroidTest&lt;/em&gt; class will run before any test is invoked. It will instantiate the &lt;em&gt;AndroidDriverManager&lt;/em&gt; class and supply the build name, test name, application URL, platform name, platform version, and device name capabilities using the &lt;em&gt;@Parameters&lt;/em&gt; &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=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;annotation in TestNG&lt;/a&gt; from the &lt;em&gt;testng.xml&lt;/em&gt; file and finally will create a new instance of the Android Driver using the &lt;em&gt;createAndroidDriver()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;Once all the tests are run, the &lt;em&gt;tearDown()&lt;/em&gt; method will gracefully quit the driver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing the Automation Test&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, in the last section of this blog on using Appium Flutter Driver with Java, we will write the test to verify the working of the Android Flutter application. As discussed in the earlier section of this blog, we need to verify the working of the Android Flutter application by performing login by entering &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;Password&lt;/em&gt; and clicking on the &lt;strong&gt;ENTER&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;Next, we must verify that the Catalog page is titled “&lt;em&gt;Catalog&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;public class FlutterSampleAndroidAppTests extends BaseAndroidTest {


    @Test
    public void testProviderShopperApp() {
        final LoginPage loginPage = new LoginPage(this.androidDriverManager.getAndroidDriver());
        final CatalogPage catalogPage = loginPage.performLogin("faisal.k@user.com", "Pass1234");
        assertEquals(catalogPage.pageTitle(), "Catalog");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;FlutterSampleAndroidAppTests&lt;/em&gt; class that extends the &lt;em&gt;BaseAndroidTests&lt;/em&gt; class, is created to write the Android automation tests. The &lt;em&gt;BaseAndroidTests&lt;/em&gt; class is extended so we can inherit the instance of Android Driver from it.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;testProviderShopperApp()&lt;/em&gt; method performs all the actions to test the app. The &lt;em&gt;LoginPage&lt;/em&gt; class is instantiated first and has the Android Driver instance passed as a Constructor parameter.&lt;/p&gt;

&lt;p&gt;As the &lt;em&gt;performLogin()&lt;/em&gt; method from the &lt;em&gt;LoginPage&lt;/em&gt; class returns a new instance of the &lt;em&gt;CatalogPage&lt;/em&gt; class, hence the following statement makes sense:&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%2F1200%2F0%2Aw7G7efmfTfBSfLTu.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%2F1200%2F0%2Aw7G7efmfTfBSfLTu.png" alt="image" width="800" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the user logs in the app, the title of the Catalog page — &lt;em&gt;“Catalog”&lt;/em&gt; is verified using the &lt;em&gt;assertEquals()&lt;/em&gt; method of TestNG.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution using TestNG&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The testng.xml file must be placed in the project’s root folder. The parameters test name, build name, platform name, platform version, device name, and App URL must be updated in the file.&lt;/p&gt;

&lt;p&gt;This test will run on the LambdaTest cloud grid on &lt;em&gt;Android 13&lt;/em&gt; –&lt;em&gt;Samsung Galaxy S21 5G&lt;/em&gt; real device.&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="Lambda tests Mobile automation test suite"  &amp;gt;
    &amp;lt;test name="Android Flutter app - Provider Shopper Tests " enabled="false"&amp;gt;
        &amp;lt;parameter name="buildName" value="Android Flutter app Build"/&amp;gt;
        &amp;lt;parameter name="testName" value="Provider shopper android app tests"/&amp;gt;
        &amp;lt;parameter name="app" value="lt://APP10160161171700638856308564"/&amp;gt;
        &amp;lt;parameter name="platformName" value="ANDROID"/&amp;gt;
        &amp;lt;parameter name="version" value="13.0"/&amp;gt;
        &amp;lt;parameter name="device" value="Galaxy S21 5G"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="io.github.mfaisalkhatri.tests.FlutterSampleAndroidAppTests"&amp;gt;
                &amp;lt;methods&amp;gt;
                    &amp;lt;include name="testProviderShopperApp"/&amp;gt;
                &amp;lt;/methods&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;We need to add the following values to run the tests on the LambdaTest cloud grid –&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Access Key&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These values can be passed using the Run Configuration window in the IDE as&lt;br&gt;&lt;br&gt;
&lt;em&gt;-DLT_USERNAME = -DLT_ACCESSKEY=&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To run the test using IntelliJ, right-click on the &lt;em&gt;testng.xml&lt;/em&gt; file and select the option Run ‘../testng.xml’.&lt;/p&gt;

&lt;p&gt;Below is the screenshot of the test run using IntelliJ.&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%2F1200%2F0%2ADPFQpbVLekvxUdWV.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%2F1200%2F0%2ADPFQpbVLekvxUdWV.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the test execution can be viewed on the &lt;a href="https://automation.lambdatest.com/build?_gl=1*1il2ucn*_gcl_aw*R0NMLjE2OTAxODUxMzIuQ2owS0NRand3dmlsQmhDRkFSSXNBRHZZaTdKZmhDNjVZNjNkak9UZlJaMHpzcEFFYlZIT2RXZkdJZ09MRkZ2aFlVOVFUemdCQkRRclM1OGFBblFHRUFMd193Y0I.*_gcl_au*MTMwMjk3ODI4LjE2ODczMzE5NzY." rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt;, which provides all the minute details about the test execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest Dashboard&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2Ai6o8jnzwGh0v9LkM.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%2F1200%2F0%2Ai6o8jnzwGh0v9LkM.png" alt="image" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Details like Video recordings, Screenshots, Appium logs, Device logs, OS name, OS version, Duration of test execution, etc., can be viewed in the build details screen by clicking the test session link on the dashboard page.&lt;/p&gt;

&lt;p&gt;If you are a developer or tester looking to elevate your Appium automation skills, you can opt for the Appium 101 certification by LambdaTest! This comprehensive certification program allows you to use your Appium skills, covering essential concepts and best practices to automate real-world scenarios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Convert your URLs into a secure and easy-to-read format with our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/url-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;URL Encode tool&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;. Make sharing links easier and secured. Simply input your URL and let us do the rest.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;There are multiple options of &lt;a href="https://www.lambdatest.com/blog/automation-testing-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=feb_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation frameworks&lt;/a&gt; that can be used to automate the Native applications. Nevertheless, Flutter applications present some limitations in this context. When it comes to identifying mobile elements in Native applications, the Appium Inspector tool proves useful, eliminating the necessity of delving into the source code of the applications. However, the Appium Inspector tool is ineffective for Flutter applications, requiring direct access to the source code. In this scenario, the Flutter Widget Inspector becomes crucial for locating the Flutter mobile elements.&lt;/p&gt;

&lt;p&gt;Comparatively, automating the native application is much easier as we don’t need to know the programming language in which the native application is built. However, for Flutter, the tester needs to have some basic understanding of Dart programming language to configure and set up the Flutter app project for compiling and generating the Android and iOS builds.&lt;/p&gt;

&lt;p&gt;The existing Appium Drivers, like UIAutomator, etc., don’t come in handy for the Flutter application. We need to have the Appium Flutter Driver to automate the Flutter application. Similarly, a separate Appium Flutter Finder library is required to locate the mobile elements, as the existing Appium libraries don’t work with Flutter.&lt;/p&gt;

&lt;p&gt;I hope this blog helps you write automated tests for the Android Flutter application by saving time.&lt;/p&gt;

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

</description>
      <category>automation</category>
      <category>appium</category>
      <category>java</category>
      <category>flutter</category>
    </item>
    <item>
      <title>assertTrue() in Java: A Complete Tutorial</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Tue, 23 Jan 2024 08:23:04 +0000</pubDate>
      <link>https://dev.to/testmuai/asserttrue-in-java-a-complete-tutorial-4ekj</link>
      <guid>https://dev.to/testmuai/asserttrue-in-java-a-complete-tutorial-4ekj</guid>
      <description>&lt;p&gt;Assertions are an important part of the automation testing process, ensuring the software functions as anticipated. If it is not working as desired, the tests have to be marked as failure and need to be halted to make the necessary investigation for the failure.&lt;/p&gt;

&lt;p&gt;An assertion statement helps to test the assumption about the test. When performing &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt;, assertions help us automatically verify the tests’ output. In Selenium automation testing, we come across multiple scenarios where it is necessary to decide on the subsequent execution of the tests.&lt;/p&gt;

&lt;p&gt;This is important in cases where the test result of the previous &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; is a failure. If the tests depend on each other, it is recommended to halt the execution at the exact failure step by using *Hard Assertion*s so the other dependent tests are skipped to save time.&lt;/p&gt;

&lt;p&gt;Consider an example of an &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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt; journey of an eCommerce application where the &lt;em&gt;product checkout from cart&lt;/em&gt; tests depends on the &lt;em&gt;add product to cart&lt;/em&gt; tests. If the &lt;em&gt;add product to cart&lt;/em&gt; tests fail, subsequent tests should not be executed as they will fail.&lt;/p&gt;

&lt;p&gt;The test execution halts when the condition (part of the assertion) is unmet. Hence, when &lt;a href="https://www.lambdatest.com/selenium-automation-testing-with-testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing with TestNG&lt;/a&gt; is performed, assertions can help us understand the expected behavior of the application and allow us to check the quality of the software under test.&lt;/p&gt;

&lt;p&gt;JUnit 5 is one of the popular testing frameworks used by many test automation projects to execute and run automation tests and perform assertions. It is a very good library with different functions to perform &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; seamlessly.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/junit-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;JUnit tutorial&lt;/a&gt;, we will demonstrate performing assertions and check specific conditions. using the &lt;em&gt;assertTrue(&lt;/em&gt;) in Java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Simplify your data export process with our efficient&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/sql-to-csv?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;SQL to CSV&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Converter. Convert SQL queries to CSV format seamlessly and unlock data versatility. Try it now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are Assertions in test automation?
&lt;/h3&gt;

&lt;p&gt;Assertions are the core concept of &lt;a href="https://www.lambdatest.com/learning-hub/functional-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;functional testing&lt;/a&gt;. In automated testing, it forms an integral part of the test and is used to derive the outcome of the test execution. The test passes if the test result confirms the assertion; otherwise, it will fail.&lt;/p&gt;

&lt;p&gt;It brings many benefits to test automation, like providing accurate test results, speeding up the test process by performing the required checks automatically, and confirming the expected behavior of the software under test. It also helps you catch the bugs and errors in the software easily, thus aiding you in getting faster feedback on the builds.&lt;/p&gt;

&lt;p&gt;Assertions are Boolean expressions confirming where the specified condition works and are considered passed per the application’s behavior. If the outcome condition is true, the test will pass; if the outcome is false, the test will fail.&lt;/p&gt;

&lt;p&gt;Consider an example of a Login web page, where the test is to check the login functions properly. Here, we make an assertion condition that if the &lt;strong&gt;Logout&lt;/strong&gt; button is displayed successfully after Login, the test is marked as passed. If the &lt;strong&gt;Logout&lt;/strong&gt; button is not displayed after Login, the assertion will fail, marking the test as a failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Looking for an easy way to convert your HTML files to JADE? Try our free online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/html-to-jade?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;HTML to JADE&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;converter tool to convert your HTML files to JADE format in seconds.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;There are two types of &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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;assertions in automated testing&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hard Assertion&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Soft Assertion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Hard Assertion
&lt;/h3&gt;

&lt;p&gt;Hard assertions ensure that the test execution is stopped when the asserting condition is not met. The next steps or tests, if any, will only proceed if the asserting condition is evaluated to be true.&lt;/p&gt;

&lt;p&gt;This helps in the automated pipeline as it turns red in case of test failures, and test execution is halted until the necessary fixes are made to the build.&lt;/p&gt;

&lt;h3&gt;
  
  
  Soft Assertion
&lt;/h3&gt;

&lt;p&gt;With Soft assertions, the test execution is not stopped if the asserting condition is not met. Even after the assertion fails, the test execution will continue until it reaches the test’s end. After the tests are executed, all the respective failures will be displayed in the logs.&lt;/p&gt;

&lt;p&gt;Soft assertions should be used when the tests are not dependent on each other and passing one test condition does not impact the upcoming tests.&lt;/p&gt;

&lt;p&gt;Having learned about the two types of assertions, Let us quickly move towards learning the &lt;em&gt;assertTrue()&lt;/em&gt; in Java for performing assertions in the automated tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Tired of manually creating JSON data? Generate&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/random-json-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;random JSON data&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;in seconds with our easy-to-use tool. Try it now and make your development process a breeze.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the assertTrue() in Java?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;assertTrue()&lt;/em&gt; method is available in the &lt;em&gt;“org.junit.Assertions”&lt;/em&gt; class in JUnit 5. The Assertions class in JUnit 5 is a collection of utility methods supporting asserting test conditions.&lt;/p&gt;

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

&lt;p&gt;It verifies the supplied condition and checks if it is True. Following are the two overloaded &lt;em&gt;assertTrue()&lt;/em&gt; methods provided by JUnit 5:&lt;/p&gt;

&lt;h3&gt;
  
  
  assertTrue(boolean condition)
&lt;/h3&gt;

&lt;p&gt;In this method, the Boolean condition is supplied as a parameter. If the condition is true, the test passes or is marked as a failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AN4_LRylpRfhHLrsx.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%2F1200%2F0%2AN4_LRylpRfhHLrsx.png" alt="image" width="643" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  assertTrue(boolean condition, String message)
&lt;/h3&gt;

&lt;p&gt;In this method, the Boolean condition is supplied as the first parameter, and the second parameter is the message text displayed in case the condition fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AaYSrdi3YYiGM98wc.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%2F1200%2F0%2AaYSrdi3YYiGM98wc.png" alt="image" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section, let’s learn how to use these methods in the test.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use the assertTrue() method in the test?
&lt;/h3&gt;

&lt;p&gt;There are two ways to use the &lt;em&gt;assertTrue()&lt;/em&gt; method in the test.&lt;/p&gt;

&lt;p&gt;The first is using the &lt;em&gt;Assertions&lt;/em&gt; class and then calling the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&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%2F1200%2F0%2AzmE2fjce-KRcPW-V.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%2F1200%2F0%2AzmE2fjce-KRcPW-V.png" alt="image" width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second way is to directly import the static &lt;em&gt;assertTrue()&lt;/em&gt; method in 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AGiqVPd3173nkiTLq.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%2F1200%2F0%2AGiqVPd3173nkiTLq.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need a quick placeholder image for your project? Use our online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/placeholder-image-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;placeholder image generator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool that helps you generate customizable images for your projects.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the project
&lt;/h3&gt;

&lt;p&gt;Let’s now delve into the test scenarios and check the actual working of the &lt;em&gt;assertTrue()&lt;/em&gt; in Java. We will use the following tech stack to demonstrate and run the tests on the LambdaTest cloud grid.&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-powered test orchestration and execution platform that lets you perform &lt;a href="https://www.lambdatest.com/selenium-java-testinghttps://www.lambdatest.com/selenium-java-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Java testing&lt;/a&gt; at scale on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ real web browsers and operating systems. You even run your automated test suites with &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; in parallel and achieve faster software release cycles.&lt;/p&gt;

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

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?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/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated 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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/java-automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Java automation testing&lt;/a&gt;, and more.&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%2F1200%2F1%2AlopUiII-GM6oAQMKiBwliQ.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%2F1200%2F1%2AlopUiII-GM6oAQMKiBwliQ.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, let’s create a Maven project and add the dependencies for &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; and JUnit 5 in the &lt;em&gt;pom.xml&lt;/em&gt; file to set up the project.&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;project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;junit-examples&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

    &amp;lt;name&amp;gt;junit-examples&amp;lt;/name&amp;gt;
    &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

    &amp;lt;properties&amp;gt;
        &amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
        &amp;lt;maven.compiler.source&amp;gt;17&amp;lt;/maven.compiler.source&amp;gt;
        &amp;lt;maven.compiler.target&amp;gt;17&amp;lt;/maven.compiler.target&amp;gt;
        &amp;lt;junit.version&amp;gt;5.10.0&amp;lt;/junit.version&amp;gt;
        &amp;lt;selenium.version&amp;gt;4.12.1&amp;lt;/selenium.version&amp;gt;
        &amp;lt;junit.platform.launcher.version&amp;gt;1.10.0&amp;lt;/junit.platform.launcher.version&amp;gt;
&amp;lt;maven-surefire-plugin.version&amp;gt;3.1.2&amp;lt;/maven-surefire-plugin.version&amp;gt;
    &amp;lt;/properties&amp;gt;

    &amp;lt;dependencies&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter --&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&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${junit.version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --&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;${selenium.version}&amp;lt;/version&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher --&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-launcher&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${junit.platform.launcher.version}&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;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${maven-surefire-plugin.version}&amp;lt;/version&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;includes&amp;gt;**/*Test*.java&amp;lt;/includes&amp;gt;
                &amp;lt;/configuration&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The project setup is complete, with the dependencies updated in the pom.xml, and we can now proceed to write the automated tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Want to generate random binary numbers? Our free online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/random-binary-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Random Binary Number Generator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;lets you generate random binary numbers quickly and easily. Try it now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Scenarios
&lt;/h3&gt;

&lt;p&gt;We will cover the following test scenarios as a part of the automation test to demo the working of the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&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%2F1200%2F1%2AUzb0_Pcfixp2E9Ke3JJ-nQ.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%2F1200%2F1%2AUzb0_Pcfixp2E9Ke3JJ-nQ.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AAHq4jwaZicODnEVl.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%2F1200%2F0%2AAHq4jwaZicODnEVl.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Checkbox Demo Screen&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AesbzXpOOuEPpvyoF.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%2F1200%2F0%2AesbzXpOOuEPpvyoF.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/redirection?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Redirection&lt;/a&gt; page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Using assertTrue()&lt;/em&gt;, verify that the page header is displayed on successfully loading the Redirection Page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A60u5dBGfAb9tw53V.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%2F1200%2F0%2A60u5dBGfAb9tw53V.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Redirection Page&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A_XEMORvYvyhPMoFa.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%2F1200%2F0%2A_XEMORvYvyhPMoFa.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 3&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/redirection?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Data List Filter&lt;/a&gt; page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for a record by entering the &lt;em&gt;Attendee&lt;/em&gt; name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using &lt;em&gt;assertTrue()&lt;/em&gt;, verify that the data retrieved contains the &lt;em&gt;Attendee&lt;/em&gt; name entered in the search box.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ASJLostgLvQ0cxndk.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%2F1200%2F0%2ASJLostgLvQ0cxndk.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Data List Filter Screen&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2Azr5aeWzF3jb-yZmu.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%2F1200%2F0%2Azr5aeWzF3jb-yZmu.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will run the tests on the Chrome browser on the Windows 10 platform using the LambdaTest Cloud grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need random dates? Our online&lt;/em&gt;&lt;/strong&gt; &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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Random Date Generator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool generates random dates for your projects. Choose a start and end date, and let our tool do the rest.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation [Test Scenario 1]
&lt;/h3&gt;

&lt;p&gt;In test scenario 1, we must open &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website and navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo" rel="noopener noreferrer"&gt;Checkbox Demo&lt;/a&gt; screen. We need to tick the Option 1 checkbox in the &lt;em&gt;Disabled Checkbox Demo&lt;/em&gt; section and use the &lt;em&gt;assertTrue()&lt;/em&gt; in Java to verify that it is ticked successfully. We will also check that the &lt;em&gt;Option 3&lt;/em&gt; checkbox is disabled using the &lt;em&gt;assertTrue()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;The following automated test method named &lt;em&gt;checkboxDemoTest()&lt;/em&gt; is written in the &lt;em&gt;SeleniumPlaygroundTests&lt;/em&gt; class that will help us achieve the automation of the test scenario:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://github.com/mfaisalkhatri/junit-examples/blob/main/src/test/java/io/github/mfaisalkhatri/tests/seleniumautomationtests/SeleniumPlaygroundTests.java" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests.java&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; @Test
    public void checkboxDemoTest() {
        createDriver(Browsers.REMOTE_CHROME);
        final String website = "https://www.lambdatest.com/selenium-playground/";
        getDriver().get(website);

        final HomePage homePage = new HomePage();
        homePage.navigateToLink("Checkbox Demo");

        final var checkboxDemoPage = new CheckboxDemoPage();
        assertTrue(checkboxDemoPage.checkIfCheckboxOneIsTicked(), "Check box one is not ticked");
        assertTrue(checkboxDemoPage.checkIfCheckboxThreeIsDisabled());
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line of the method will create an instance of the Chrome browser in the LambdaTest Cloud grid. &lt;em&gt;createDriver()&lt;/em&gt; method is a static method in the &lt;em&gt;DriverManager&lt;/em&gt; class that will help us instantiate a new instance of WebDriver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://github.com/mfaisalkhatri/junit-examples/blob/main/src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java" rel="noopener noreferrer"&gt;DriverManager.java&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%2F1200%2F0%2AVN3-jmrK1BAhS1Ic.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%2F1200%2F0%2AVN3-jmrK1BAhS1Ic.png" alt="image" width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The browser’s name passed in the &lt;em&gt;createDriver()&lt;/em&gt; method parameter will get started. &lt;em&gt;The REMOTE_CHROME&lt;/em&gt; browser name will call the &lt;em&gt;setupChromeInRemote()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ApRNYUlWImCcKRrYb.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%2F1200%2F0%2ApRNYUlWImCcKRrYb.png" alt="image" width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method will set all the desired capabilities and the configuration required for running the tests on the LambdaTest Cloud grid. These capabilities can be directly copied using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A0NNwbG7EcIcj8j00.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%2F1200%2F0%2A0NNwbG7EcIcj8j00.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the driver session is created and the Chrome browser is started, the next line in the test will navigate the user to the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Selenium Playground&lt;/a&gt; website.&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%2F1200%2F0%2A8lLW_MrWaf3xSeto.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%2F1200%2F0%2A8lLW_MrWaf3xSeto.png" alt="image" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the website’s Homepage, the &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;em&gt;Checkbox Demo&lt;/em&gt;&lt;/a&gt; link will be clicked to navigate the user to the &lt;em&gt;Checkbox Demo&lt;/em&gt; 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%2F1200%2F0%2Ar8otgyUX0vB_iLTN.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%2F1200%2F0%2Ar8otgyUX0vB_iLTN.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model&lt;/a&gt; is used in this project as it helps test readability, reduces code duplication, and acts as an interface for the web page under test. The &lt;em&gt;HomePage&lt;/em&gt; class houses the page objects for the &lt;em&gt;Home Page&lt;/em&gt; of LambdaTest’s Selenium Playground website.&lt;/p&gt;

&lt;p&gt;As the Homepage contains links to different website windows, a generic method has been created to search the links using the respective &lt;em&gt;LinkText&lt;/em&gt; and then click on it to navigate to the required page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/html-minify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;HTML Minify&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;is a perfect tool for anyone looking to optimize website’s speed. Minify your code and optimize website for faster loading times in few seconds.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://github.com/mfaisalkhatri/junit-examples/blob/main/src/test/java/io/github/mfaisalkhatri/seleniumplayground/pages/HomePage.java" rel="noopener noreferrer"&gt;HomePage.java&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;public class HomePage {

    public void navigateToLink (final String linkText) {
        getDriver ().findElement (By.linkText (linkText)).click ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to tick the &lt;em&gt;Option 1&lt;/em&gt; checkbox under the &lt;em&gt;Disabled Checkbox Demo&lt;/em&gt; section and verify that it is ticked successfully using the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&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%2F1200%2F0%2APaChkjAWZkfaOTOl.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%2F1200%2F0%2APaChkjAWZkfaOTOl.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will also provide a message in the &lt;em&gt;assertTrue()&lt;/em&gt; method so that if the test fails, this text will be printed in the console for easy interpretation of the failure.&lt;/p&gt;

&lt;p&gt;The page objects for the &lt;em&gt;Checkbox&lt;/em&gt; page are updated in the &lt;em&gt;CheckboxDemoPage&lt;/em&gt; class. The &lt;em&gt;checkboxOne()&lt;/em&gt; method will return a WebElement for the &lt;em&gt;Option 1&lt;/em&gt; checkbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/css-selectors?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;CSS Selectors&lt;/a&gt; are faster and simpler than &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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;XPath&lt;/a&gt;, allowing for a clearer method to locate web elements. We can use the CSS Selector &lt;em&gt;“div:nth-child(2) &amp;gt; div:nth-child(1) &amp;gt; input[type=”checkbox”]”&lt;/em&gt; to locate the Option 1 checkbox.&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%2F1200%2F0%2AI_tTJwfidYosbDt4.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%2F1200%2F0%2AI_tTJwfidYosbDt4.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;checkIfCheckboxOneIsTicked()&lt;/em&gt; method will tick the &lt;em&gt;Option 1&lt;/em&gt; checkbox and return the boolean value stating if the checkbox is selected.&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%2F1200%2F0%2ARvtbg1Mm294ejVLJ.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%2F1200%2F0%2ARvtbg1Mm294ejVLJ.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://github.com/mfaisalkhatri/junit-examples/blob/main/src/test/java/io/github/mfaisalkhatri/seleniumplayground/pages/CheckboxDemoPage.java" rel="noopener noreferrer"&gt;CheckboxDemoPage.java&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;public class CheckboxDemoPage {

    public WebElement checkboxOne() {
        return getDriver().findElement(By.cssSelector("div:nth-child(2) &amp;gt; div:nth-child(1) &amp;gt; input[type=\"checkbox\"]"));
    }
    public WebElement checkboxThree() {
        return getDriver().findElement(By.cssSelector("div:nth-child(2) &amp;gt; div:nth-child(3) &amp;gt; input[type=\"checkbox\"]"));
    }

    public void tickCheckBoxOne () {
        checkboxOne().click();
    }

    public boolean checkIfCheckboxOneIsTicked() {
       tickCheckBoxOne();
        return this.checkboxOne().isSelected();
    }

    public boolean checkIfCheckboxThreeIsDisabled() {
        return !this.checkboxThree().isEnabled();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next assertion performed using the &lt;em&gt;assertTrue()&lt;/em&gt; in Java is to check that the &lt;em&gt;Option 3&lt;/em&gt; checkbox is disabled.&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%2F1200%2F0%2A2Z0CtCGNTUZKrU-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%2F1200%2F0%2A2Z0CtCGNTUZKrU-m.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;checkIfCheckboxThreeIsDisabled()&lt;/em&gt; method from the &lt;em&gt;CheckboxPage&lt;/em&gt; class is used to check the disabled state of the checkbox.&lt;/p&gt;

&lt;p&gt;The point to note here is that we are using the &lt;em&gt;“!”&lt;/em&gt; while returning the output of the boolean condition from the &lt;em&gt;checkIfCheckboxThreeIsDisabled()&lt;/em&gt; method that uses the &lt;em&gt;isEnabled()&lt;/em&gt; method. So, ideally, it will check that the checkbox is disabled and return the output as true, else it will return &lt;em&gt;false&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need to convert hex to decimal? Our online&lt;/em&gt;&lt;/strong&gt; &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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Hex to Decimal&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Converter tool converts hexadecimal to decimal numbers quickly. Get your conversions done in no time.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The LambdaTest Username and Access Key must be provided for authentication to run tests successfully on the LambdaTest Cloud grid. These values can be updated in the &lt;em&gt;Run Configuration&lt;/em&gt; window, which can be opened using the &lt;em&gt;Modify Run Configuration&lt;/em&gt; option by clicking the Green Play button beside the test method name.&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%2F1200%2F0%2AvLMQ7IIj90sUMGES.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%2F1200%2F0%2AvLMQ7IIj90sUMGES.png" alt="image" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The LambdaTest Username and Access Key values can be copied from the &lt;em&gt;Profile &amp;gt;&amp;gt; Account Settings &amp;gt;&amp;gt; Password and Security window&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A5t-ysz6zsOSS-iKJ.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%2F1200%2F0%2A5t-ysz6zsOSS-iKJ.png" alt="image" width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Run Configuration window, update the values for the Username and Access Key as follows :&lt;/p&gt;

&lt;p&gt;&lt;em&gt;-DLT_USERNAME= &amp;lt; LambdaTest Username &amp;gt; -DLT_ACCESS_KEY=&amp;lt; LambdaTest_Access_Key &amp;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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AWOmIzGYpGm-LXEhL.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%2F1200%2F0%2AWOmIzGYpGm-LXEhL.png" alt="image" width="800" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the credentials are successfully updated in the configuration window, the tests can be executed by selecting Run Configuration from the dropdown in the top menu bar and clicking on the green 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AamlBWAzorm-8XFQg.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%2F1200%2F0%2AamlBWAzorm-8XFQg.png" alt="image" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test execution&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AJKj4F1fxDDTPr6Yu.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%2F1200%2F0%2AJKj4F1fxDDTPr6Yu.png" alt="image" width="800" height="233"&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%2F1200%2F0%2Aat6jYXkHVNnkb5Hb.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%2F1200%2F0%2Aat6jYXkHVNnkb5Hb.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the test details can be viewed on the LambdaTest dashboard, including platform name, browser name, resolution, test execution logs, time taken to execute the tests, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Struggling with messy Lua scripts? Our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/lua-beautifier?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Lua Beautifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool provides clean and structured formatting. Beautify your code and Improve readability today.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation [Test Scenario 2]
&lt;/h3&gt;

&lt;p&gt;In test scenario 2, we will navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/redirection?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Redirection&lt;/a&gt; page on &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website and verify that the page title is displayed using the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&lt;/p&gt;

&lt;p&gt;The steps for test scenario 2 will be automated using the &lt;em&gt;redirectionPageTest()&lt;/em&gt; method created inside the &lt;em&gt;SeleniumPlaygroundTests.java&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://github.com/mfaisalkhatri/junit-examples/blob/main/src/test/java/io/github/mfaisalkhatri/tests/seleniumautomationtests/SeleniumPlaygroundTests.java" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests.java&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; @Test
    public void redirectionPageTest() {
        createDriver(Browsers.REMOTE_CHROME);
        final String website = "https://www.lambdatest.com/selenium-playground/";
        getDriver().get(website);

        final HomePage homePage = new HomePage();
        homePage.navigateToLink("Redirection");

        final var redirectionPage = new RedirectionPage();
        assertTrue(redirectionPage.isPageTitleDisplayed());
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The initial 3 lines in the test are the same as we discussed in the test scenario 1 implementation. We will not discuss the configuration and setup for creating a WebDriver session and launching the Chrome browser.&lt;/p&gt;

&lt;p&gt;Once the website is loaded on the browser, the &lt;em&gt;Redirection&lt;/em&gt; page is navigated, and further interaction is taken to check that the title is displayed on the page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class RedirectionPage {

    public boolean isPageTitleDisplayed() {
        return getDriver().findElement(By.tagName("h1")).isDisplayed();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;RedirectionPage&lt;/em&gt; class is created to update all the page objects related to the &lt;em&gt;Redirection&lt;/em&gt; page. The &lt;em&gt;isPageTitleDisplayed()&lt;/em&gt; method returns a boolean value using the Selenium WebDriver’s &lt;em&gt;isDisplayed()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;First, the Page title will be located, and then, using the &lt;em&gt;isDisplayed()&lt;/em&gt; method, the verification will be done to check that it is displayed on the page. The &lt;em&gt;assertTrue()&lt;/em&gt; method is finally used in the test to check the result of the boolean condition returned by the &lt;em&gt;isPageTitleDisplayed()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Struggling with messy&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/python-beautifier?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Python Formatter &amp;amp; Beautifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Online scripts? Our Python Formatter &amp;amp; Beautifier Online tool provides clean and structured formatting. Beautify your code and Improve readability today.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

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

&lt;p&gt;The steps followed while executing Test Scenario 1 for setting the LambdaTest &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;AccessKey&lt;/em&gt; to execute the tests on the LambdaTest Cloud grid. The same steps need to be followed while executing this test.&lt;/p&gt;

&lt;p&gt;As we have already set the &lt;em&gt;LambdaTest Username&lt;/em&gt; and &lt;em&gt;AccessKey&lt;/em&gt; in the Configuration window, we can re-use the same window and just change the test method name to run this test.&lt;/p&gt;

&lt;p&gt;Click the Run/Debug Configuration dropdown and select the &lt;em&gt;Edit Configuration&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A1hP4etd-glsG7Z4x.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%2F1200%2F0%2A1hP4etd-glsG7Z4x.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the &lt;em&gt;redirectionPageTest()&lt;/em&gt; method name in the configuration window by clicking on the &lt;em&gt;three dots&lt;/em&gt; next to the &lt;em&gt;Method name&lt;/em&gt; field. Leave the other settings/configurations as they are and click “Apply” and then the “OK” button to close the configuration window.&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%2F1200%2F0%2AYUjjgzaO7ecwYS_N.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%2F1200%2F0%2AYUjjgzaO7ecwYS_N.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tests can now be executed by clicking on the green button next to the Run/Debug configuration field.&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%2F1200%2F0%2AEetKGE7UV9kWSGVx.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%2F1200%2F0%2AEetKGE7UV9kWSGVx.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test execution&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2Axak0JPeg04kbqE3V.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%2F1200%2F0%2Axak0JPeg04kbqE3V.png" alt="image" width="800" height="400"&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%2F1200%2F0%2AfnzBxPYgxFEshITF.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%2F1200%2F0%2AfnzBxPYgxFEshITF.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The test execution can be checked in the LambdaTest Build details windows after logging in to the LambdaTest website. This window provides granular details of the test execution that help know the test analytics and execution status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Don’t let encoding IDNs slow you down. Save time and hassle with our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/idn-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;IDN Encode&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;free online tool to quickly and easily converts internationalized domain names. Try it now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation [Test Scenario 3]
&lt;/h3&gt;

&lt;p&gt;In test scenario 3, we will navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/data-list-filter-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Data Filter List&lt;/a&gt; page on &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium playground&lt;/a&gt; website to search for an attendee record by entering a name. Once the records are retrieved based on the filter according to the name provided, the record will be verified using the &lt;em&gt;assertTrue()&lt;/em&gt; method by checking if the Attendee name in the record contains the name searched for.&lt;/p&gt;

&lt;p&gt;The steps for test scenario 3 will be automated using the &lt;em&gt;dataFilterPageTest()&lt;/em&gt; method that is updated inside the &lt;em&gt;SeleniumPlaygroundTests.java&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://github.com/mfaisalkhatri/junit-examples/blob/main/src/test/java/io/github/mfaisalkhatri/tests/seleniumautomationtests/SeleniumPlaygroundTests.java" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests.java&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; @Test
    public void dataFilterPageTest() {
        createDriver(Browsers.REMOTE_CHROME);
        final String website = "https://www.lambdatest.com/selenium-playground/";
        getDriver().get(website);

        final HomePage homePage = new HomePage();
        homePage.navigateToLink("Data List Filter");

        final var dataListFilterPage = new DataListFilterPage();
        final String attendeeName = "Dwayne";
        dataListFilterPage.searchAttendees(attendeeName);
        assertTrue(dataListFilterPage.getAttendeeName().contains(attendeeName));
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this test, we will first open the Chrome browser in the LambdaTest Cloud grid and navigate to the &lt;em&gt;Data List Filter&lt;/em&gt; Page on &lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt; website.&lt;br&gt;&lt;br&gt;
Next, it will search for the data with the attendee name “&lt;em&gt;Dwayne&lt;/em&gt;”. Once the data is loaded on the page, the &lt;em&gt;assertTrue()&lt;/em&gt; method will check the condition that the attendee name in the results contains the text — “&lt;em&gt;Dwayne&lt;/em&gt;”. The test will be marked as pass if the text is found in the Attendee’s name in the data results.&lt;/p&gt;

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

&lt;p&gt;The test for scenario 3 can be easily run by just changing the method name from the Run Configuration window, as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2Ay2_brq6iboHlzO8V.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%2F1200%2F0%2Ay2_brq6iboHlzO8V.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the method is selected, click the Apply button and then the OK button to close the config window. To run the test, click the Green Play button on the toolbar on the top,&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%2F1200%2F0%2AeBQ_MVH1K2keBzq8.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%2F1200%2F0%2AeBQ_MVH1K2keBzq8.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test execution&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A_mJbbmbthC_mr8h-.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%2F1200%2F0%2A_mJbbmbthC_mr8h-.png" alt="image" width="800" height="400"&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%2F1200%2F0%2Awm-m6dt9nLKCHpvO.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%2F1200%2F0%2Awm-m6dt9nLKCHpvO.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Simplify the process of converting&lt;/em&gt;&lt;/strong&gt; &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=jan_22&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JSON to YAML&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;with our online JSON to YAML converter tool to convert JSON files to YAML. No sign-up required. Get started now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Without assertions, an automated test is incomplete. Assertions help us to derive the results of the automated tests. This can help in providing faster feedback on the software builds.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;assertTrue()&lt;/em&gt; in Java is used to perform assertions in automated tests. We can verify a boolean condition using this method. This web automation method can ideally be used to check if a particular web element, like a checkbox or a radio button is enabled. It can also help in checking if a particular text is displayed. Further, it can be used for checking boolean conditions like text on a web page containing a particular string or text.&lt;/p&gt;

&lt;p&gt;I hope this helps you in writing better assertions for the automated tests.&lt;/p&gt;

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

</description>
      <category>asserttrue</category>
      <category>javascript</category>
      <category>automationtesting</category>
    </item>
    <item>
      <title>assertTrue() in Java: A Complete Tutorial</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Tue, 16 Jan 2024 07:53:47 +0000</pubDate>
      <link>https://dev.to/testmuai/asserttrue-in-java-a-complete-tutorial-4m1m</link>
      <guid>https://dev.to/testmuai/asserttrue-in-java-a-complete-tutorial-4m1m</guid>
      <description>&lt;p&gt;Assertions are an important part of the automation testing process, ensuring the software functions as anticipated. If it is not working as desired, the tests have to be marked as failure and need to be halted to make the necessary investigation for the failure.&lt;/p&gt;

&lt;p&gt;An assertion statement helps to test the assumption about the test. When performing &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt;, assertions help us automatically verify the tests’ output. In Selenium automation testing, we come across multiple scenarios where it is necessary to decide on the subsequent execution of the tests.&lt;/p&gt;

&lt;p&gt;This is important in cases where the test result of the previous &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; is a failure. If the tests depend on each other, it is recommended to halt the execution at the exact failure step by using *Hard Assertion*s so the other dependent tests are skipped to save time.&lt;/p&gt;

&lt;p&gt;Consider an example of an &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=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;end-to-end testing&lt;/a&gt; journey of an eCommerce application where the &lt;em&gt;product checkout from cart&lt;/em&gt; tests depends on the &lt;em&gt;add product to cart&lt;/em&gt; tests. If the &lt;em&gt;add product to cart&lt;/em&gt; tests fail, subsequent tests should not be executed as they will fail.&lt;/p&gt;

&lt;p&gt;The test execution halts when the condition (part of the assertion) is unmet. Hence, when &lt;a href="https://www.lambdatest.com/selenium-automation-testing-with-testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation testing with TestNG&lt;/a&gt; is performed, assertions can help us understand the expected behavior of the application and allow us to check the quality of the software under test.&lt;/p&gt;

&lt;p&gt;JUnit 5 is one of the popular testing frameworks used by many test automation projects to execute and run automation tests and perform assertions. It is a very good library with different functions to perform &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; seamlessly.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/junit-tutorial?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;JUnit tutorial&lt;/a&gt;, we will demonstrate performing assertions and check specific conditions. using the &lt;em&gt;assertTrue(&lt;/em&gt;) in Java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get your CSS validated by our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/css-validator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;CSS Validator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and eliminate syntax errors and other issues that could affect your website’s performance. Ensure your CSS code is error-free today.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  What are Assertions in test automation?
&lt;/h3&gt;

&lt;p&gt;Assertions are the core concept of &lt;a href="https://www.lambdatest.com/learning-hub/functional-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;functional testing&lt;/a&gt;. In automated testing, it forms an integral part of the test and is used to derive the outcome of the test execution. The test passes if the test result confirms the assertion; otherwise, it will fail.&lt;/p&gt;

&lt;p&gt;It brings many benefits to test automation, like providing accurate test results, speeding up the test process by performing the required checks automatically, and confirming the expected behavior of the software under test. It also helps you catch the bugs and errors in the software easily, thus aiding you in getting faster feedback on the builds.&lt;/p&gt;

&lt;p&gt;Assertions are Boolean expressions confirming where the specified condition works and are considered passed per the application’s behavior. If the outcome condition is true, the test will pass; if the outcome is false, the test will fail.&lt;/p&gt;

&lt;p&gt;Consider an example of a Login web page, where the test is to check the login functions properly. Here, we make an assertion condition that if the &lt;strong&gt;Logout&lt;/strong&gt; button is displayed successfully after Login, the test is marked as passed. If the &lt;strong&gt;Logout&lt;/strong&gt; button is not displayed after Login, the assertion will fail, marking the test as a failure.&lt;/p&gt;

&lt;p&gt;There are two types of &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=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;assertions in automated testing&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hard Assertion&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Soft Assertion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Hard Assertion
&lt;/h3&gt;

&lt;p&gt;Hard assertions ensure that the test execution is stopped when the asserting condition is not met. The next steps or tests, if any, will only proceed if the asserting condition is evaluated to be true.&lt;/p&gt;

&lt;p&gt;This helps in the automated pipeline as it turns red in case of test failures, and test execution is halted until the necessary fixes are made to the build.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Don’t let CSV errors slow you down. Validate and lint your CSV data with ease using our free online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/csv-validator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;CSV Validator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool. Get accurate and error-free results in seconds.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Soft Assertion
&lt;/h3&gt;

&lt;p&gt;With Soft assertions, the test execution is not stopped if the asserting condition is not met. Even after the assertion fails, the test execution will continue until it reaches the test’s end. After the tests are executed, all the respective failures will be displayed in the logs.&lt;/p&gt;

&lt;p&gt;Soft assertions should be used when the tests are not dependent on each other and passing one test condition does not impact the upcoming tests.&lt;/p&gt;

&lt;p&gt;Having learned about the two types of assertions, Let us quickly move towards learning the &lt;em&gt;assertTrue()&lt;/em&gt; in Java for performing assertions in the automated tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the assertTrue() in Java?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;assertTrue()&lt;/em&gt; method is available in the &lt;em&gt;“org.junit.Assertions”&lt;/em&gt; class in JUnit 5. The Assertions class in JUnit 5 is a collection of utility methods supporting asserting test conditions.&lt;/p&gt;

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

&lt;p&gt;It verifies the supplied condition and checks if it is True. Following are the two overloaded &lt;em&gt;assertTrue()&lt;/em&gt; methods provided by JUnit 5:&lt;/p&gt;

&lt;h3&gt;
  
  
  assertTrue(boolean condition)
&lt;/h3&gt;

&lt;p&gt;In this method, the Boolean condition is supplied as a parameter. If the condition is true, the test passes or is marked as a failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2Ah5TGPWKvtp1VL7BB.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%2F1200%2F0%2Ah5TGPWKvtp1VL7BB.png" alt="image" width="643" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  assertTrue(boolean condition, String message)
&lt;/h3&gt;

&lt;p&gt;In this method, the Boolean condition is supplied as the first parameter, and the second parameter is the message text displayed in case the condition fails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AjlDU_8UvcVHbKaer.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%2F1200%2F0%2AjlDU_8UvcVHbKaer.png" alt="image" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the next section, let’s learn how to use these methods in the test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Minify your JS code without changing its functionality with our easy-to-use&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/js-minify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JavaScript Minifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that reduces the size of your scripts and improve website speed.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use the assertTrue() method in the test?
&lt;/h3&gt;

&lt;p&gt;There are two ways to use the &lt;em&gt;assertTrue()&lt;/em&gt; method in the test.&lt;/p&gt;

&lt;p&gt;The first is using the &lt;em&gt;Assertions&lt;/em&gt; class and then calling the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&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%2F1ycbcdnpgk9ku8i4l3fw.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%2F1ycbcdnpgk9ku8i4l3fw.png" alt="Image " width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second way is to directly import the static &lt;em&gt;assertTrue()&lt;/em&gt; method in 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%2F72dmxgako9rhs38heldy.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%2F72dmxgako9rhs38heldy.png" alt="Image" width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the project
&lt;/h3&gt;

&lt;p&gt;Let’s now delve into the test scenarios and check the actual working of the &lt;em&gt;assertTrue()&lt;/em&gt; in Java. We will use the following tech stack to demonstrate and run the tests on the LambdaTest cloud grid.&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-powered test orchestration and execution platform that lets you perform &lt;a href="https://www.lambdatest.com/selenium-java-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Java testing&lt;/a&gt; at scale on an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ real web browsers and operating systems. You even run your automated test suites with &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; in parallel and achieve faster software release cycles.&lt;/p&gt;

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

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?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/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automated 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=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/java-automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Java automation testing&lt;/a&gt;, and more.&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%2F1200%2F1%2AEuTtyKyqSjXryd84zfOAAQ.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%2F1200%2F1%2AEuTtyKyqSjXryd84zfOAAQ.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, let’s create a Maven project and add the dependencies for &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; and JUnit 5 in the &lt;em&gt;pom.xml&lt;/em&gt; file to set up the project.&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;project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;junit-examples&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

    &amp;lt;name&amp;gt;junit-examples&amp;lt;/name&amp;gt;
    &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

    &amp;lt;properties&amp;gt;
        &amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
        &amp;lt;maven.compiler.source&amp;gt;17&amp;lt;/maven.compiler.source&amp;gt;
        &amp;lt;maven.compiler.target&amp;gt;17&amp;lt;/maven.compiler.target&amp;gt;
        &amp;lt;junit.version&amp;gt;5.10.0&amp;lt;/junit.version&amp;gt;
        &amp;lt;selenium.version&amp;gt;4.12.1&amp;lt;/selenium.version&amp;gt;
        &amp;lt;junit.platform.launcher.version&amp;gt;1.10.0&amp;lt;/junit.platform.launcher.version&amp;gt;
&amp;lt;maven-surefire-plugin.version&amp;gt;3.1.2&amp;lt;/maven-surefire-plugin.version&amp;gt;
    &amp;lt;/properties&amp;gt;

    &amp;lt;dependencies&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter --&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&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${junit.version}&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --&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;${selenium.version}&amp;lt;/version&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher --&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-launcher&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;${junit.platform.launcher.version}&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;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${maven-surefire-plugin.version}&amp;lt;/version&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;includes&amp;gt;**/*Test*.java&amp;lt;/includes&amp;gt;
                &amp;lt;/configuration&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The project setup is complete, with the dependencies updated in the pom.xml, and we can now proceed to write the automated tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Scenarios
&lt;/h3&gt;

&lt;p&gt;We will cover the following test scenarios as a part of the automation test to demo the working of the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 1&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;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=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Checkbox Demo&lt;/a&gt; screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the &lt;em&gt;Disabled Checkbox Demo&lt;/em&gt; section, tick &lt;em&gt;Option 1&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using &lt;em&gt;assertTrue()&lt;/em&gt;, verify that the &lt;em&gt;Option 1&lt;/em&gt; checkbox is ticked successfully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, using &lt;em&gt;assertTrue()&lt;/em&gt;, verify that the &lt;em&gt;Option 3&lt;/em&gt; checkbox is disabled.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AeE9ll_Y1tBe9yBlk.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%2F1200%2F0%2AeE9ll_Y1tBe9yBlk.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Checkbox Demo Screen&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AWHWOXaBrawWTD828.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%2F1200%2F0%2AWHWOXaBrawWTD828.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/redirection?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Redirection&lt;/a&gt; page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Using assertTrue()&lt;/em&gt;, verify that the page header is displayed on successfully loading the Redirection Page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2Ap1luALFRAvmRfuE7.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%2F1200%2F0%2Ap1luALFRAvmRfuE7.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Redirection Page&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2A9RL7lvDTD6Iv3rxX.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%2F1200%2F0%2A9RL7lvDTD6Iv3rxX.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 3&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/redirection?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Data List Filter&lt;/a&gt; page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for a record by entering the &lt;em&gt;Attendee&lt;/em&gt; name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using &lt;em&gt;assertTrue()&lt;/em&gt;, verify that the data retrieved contains the &lt;em&gt;Attendee&lt;/em&gt; name entered in the search box.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2ARAWo-C-bxAy6lRUD.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%2F1200%2F0%2ARAWo-C-bxAy6lRUD.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Data List Filter Screen&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AfYb33CS-zD5VwcEX.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%2F1200%2F0%2AfYb33CS-zD5VwcEX.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will run the tests on the Chrome browser on the Windows 10 platform using the LambdaTest Cloud grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Transform your messy CSS code into beautiful and organized code with our user-friendly and efficient online free&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/css-prettify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;CSS Prettifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool with just a few clicks.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation [Test Scenario 1]
&lt;/h3&gt;

&lt;p&gt;In test scenario 1, we must open &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website and 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=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Checkbox Demo&lt;/a&gt; screen. We need to tick the Option 1 checkbox in the &lt;em&gt;Disabled Checkbox Demo&lt;/em&gt; section and use the &lt;em&gt;assertTrue()&lt;/em&gt; in Java to verify that it is ticked successfully. We will also check that the &lt;em&gt;Option 3&lt;/em&gt; checkbox is disabled using the &lt;em&gt;assertTrue()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;The following automated test method named &lt;em&gt;checkboxDemoTest()&lt;/em&gt; is written in the &lt;em&gt;SeleniumPlaygroundTests&lt;/em&gt; class that will help us achieve the automation of the test scenario:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests.java&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; @Test
    public void checkboxDemoTest() {
        createDriver(Browsers.REMOTE_CHROME);
        final String website = "https://www.lambdatest.com/selenium-playground/";
        getDriver().get(website);

        final HomePage homePage = new HomePage();
        homePage.navigateToLink("Checkbox Demo");

        final var checkboxDemoPage = new CheckboxDemoPage();
        assertTrue(checkboxDemoPage.checkIfCheckboxOneIsTicked(), "Check box one is not ticked");
        assertTrue(checkboxDemoPage.checkIfCheckboxThreeIsDisabled());
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line of the method will create an instance of the Chrome browser in the LambdaTest Cloud grid. &lt;em&gt;createDriver()&lt;/em&gt; method is a static method in the &lt;em&gt;DriverManager&lt;/em&gt; class that will help us instantiate a new instance of WebDriver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;DriverManager.java&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%2Fqhv0hwe54nys1dfasb65.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%2Fqhv0hwe54nys1dfasb65.png" alt="Image " width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The browser’s name passed in the &lt;em&gt;createDriver()&lt;/em&gt; method parameter will get started. &lt;em&gt;The REMOTE_CHROME&lt;/em&gt; browser name will call the &lt;em&gt;setupChromeInRemote()&lt;/em&gt; 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%2Ffod14mb0rumpe5ch08lm.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%2Ffod14mb0rumpe5ch08lm.png" alt="Image " width="800" height="557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method will set all the desired capabilities and the configuration required for running the tests on the LambdaTest Cloud grid. These capabilities can be directly copied using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest 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%2Fcwn3iu5llr0hcider9sg.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%2Fcwn3iu5llr0hcider9sg.png" alt="Image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the driver session is created and the Chrome browser is started, the next line in the test will navigate the user to the &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Selenium Playground&lt;/a&gt; website.&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%2Fun5olb17ylvlx3dn03zh.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%2Fun5olb17ylvlx3dn03zh.png" alt="Image " width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the website’s Homepage, the &lt;a href="https://www.lambdatest.com/selenium-playground/checkbox-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;em&gt;Checkbox Demo&lt;/em&gt;&lt;/a&gt; link will be clicked to navigate the user to the &lt;em&gt;Checkbox Demo&lt;/em&gt; 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%2Foiogknkcjkd6okawi3bd.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%2Foiogknkcjkd6okawi3bd.png" alt="Image " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model&lt;/a&gt; is used in this project as it helps test readability, reduces code duplication, and acts as an interface for the web page under test. The &lt;em&gt;HomePage&lt;/em&gt; class houses the page objects for the &lt;em&gt;Home Page&lt;/em&gt; of LambdaTest’s Selenium Playground website.&lt;/p&gt;

&lt;p&gt;As the Homepage contains links to different website windows, a generic method has been created to search the links using the respective &lt;em&gt;LinkText&lt;/em&gt; and then click on it to navigate to the required page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;HomePage.java&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;public class HomePage {

    public void navigateToLink (final String linkText) {
        getDriver ().findElement (By.linkText (linkText)).click ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to tick the &lt;em&gt;Option 1&lt;/em&gt; checkbox under the &lt;em&gt;Disabled Checkbox Demo&lt;/em&gt; section and verify that it is ticked successfully using the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&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%2F1200%2F0%2ATDSG07PhHUc_42Ag.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%2F1200%2F0%2ATDSG07PhHUc_42Ag.png" alt="image" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will also provide a message in the &lt;em&gt;assertTrue()&lt;/em&gt; method so that if the test fails, this text will be printed in the console for easy interpretation of the failure.&lt;/p&gt;

&lt;p&gt;The page objects for the &lt;em&gt;Checkbox&lt;/em&gt; page are updated in the &lt;em&gt;CheckboxDemoPage&lt;/em&gt; class. The &lt;em&gt;checkboxOne()&lt;/em&gt; method will return a WebElement for the &lt;em&gt;Option 1&lt;/em&gt; checkbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/css-selectors?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;CSS Selectors&lt;/a&gt; are faster and simpler than &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=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;XPath&lt;/a&gt;, allowing for a clearer method to locate web elements. We can use the CSS Selector &lt;em&gt;“div:nth-child(2) &amp;gt; div:nth-child(1) &amp;gt; input[type=”checkbox”]”&lt;/em&gt; to locate the Option 1 checkbox.&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%2F1200%2F0%2AdtGd7zVvkqFQzblG.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%2F1200%2F0%2AdtGd7zVvkqFQzblG.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;checkIfCheckboxOneIsTicked()&lt;/em&gt; method will tick the &lt;em&gt;Option 1&lt;/em&gt; checkbox and return the boolean value stating if the checkbox is selected.&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%2F1200%2F0%2AfzJgVjn1gnwRq54v.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%2F1200%2F0%2AfzJgVjn1gnwRq54v.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;CheckboxDemoPage.java&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;public class CheckboxDemoPage {

    public WebElement checkboxOne() {
        return getDriver().findElement(By.cssSelector("div:nth-child(2) &amp;gt; div:nth-child(1) &amp;gt; input[type=\"checkbox\"]"));
    }
    public WebElement checkboxThree() {
        return getDriver().findElement(By.cssSelector("div:nth-child(2) &amp;gt; div:nth-child(3) &amp;gt; input[type=\"checkbox\"]"));
    }

    public void tickCheckBoxOne () {
        checkboxOne().click();
    }

    public boolean checkIfCheckboxOneIsTicked() {
       tickCheckBoxOne();
        return this.checkboxOne().isSelected();
    }

    public boolean checkIfCheckboxThreeIsDisabled() {
        return !this.checkboxThree().isEnabled();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next assertion performed using the &lt;em&gt;assertTrue()&lt;/em&gt; in Java is to check that the &lt;em&gt;Option 3&lt;/em&gt; checkbox is disabled.&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%2F1200%2F0%2Awrgxk3-0oy2HMAJm.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%2F1200%2F0%2Awrgxk3-0oy2HMAJm.png" alt="image" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;checkIfCheckboxThreeIsDisabled()&lt;/em&gt; method from the &lt;em&gt;CheckboxPage&lt;/em&gt; class is used to check the disabled state of the checkbox.&lt;/p&gt;

&lt;p&gt;The point to note here is that we are using the &lt;em&gt;“!”&lt;/em&gt; while returning the output of the boolean condition from the &lt;em&gt;checkIfCheckboxThreeIsDisabled()&lt;/em&gt; method that uses the &lt;em&gt;isEnabled()&lt;/em&gt; method. So, ideally, it will check that the checkbox is disabled and return the output as true, else it will return &lt;em&gt;false&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get faster loading times and better user experience with our efficient&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/json-minify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JSON minify&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool. Quickly compress your JSON data with ease and optimize your website now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The LambdaTest Username and Access Key must be provided for authentication to run tests successfully on the LambdaTest Cloud grid. These values can be updated in the &lt;em&gt;Run Configuration&lt;/em&gt; window, which can be opened using the &lt;em&gt;Modify Run Configuration&lt;/em&gt; option by clicking the Green Play button beside the test method name.&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%2F1200%2F0%2A9bHtsXf0hvI9fRpO.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%2F1200%2F0%2A9bHtsXf0hvI9fRpO.png" alt="image" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The LambdaTest Username and Access Key values can be copied from the &lt;em&gt;Profile &amp;gt;&amp;gt; Account Settings &amp;gt;&amp;gt; Password and Security window&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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2AOZ6EqQbpJYGHHVT8.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%2F1200%2F0%2AOZ6EqQbpJYGHHVT8.png" alt="image" width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Run Configuration window, update the values for the Username and Access Key as follows :&lt;/p&gt;

&lt;p&gt;&lt;em&gt;-DLT_USERNAME= &amp;lt; LambdaTest Username &amp;gt; -DLT_ACCESS_KEY=&amp;lt; LambdaTest_Access_Key &amp;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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2APYxcQ8j7GGeHFwGh.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%2F1200%2F0%2APYxcQ8j7GGeHFwGh.png" alt="image" width="800" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the credentials are successfully updated in the configuration window, the tests can be executed by selecting Run Configuration from the dropdown in the top menu bar and clicking on the green 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%2F1q27urwopvwvpa0auz4e.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%2F1q27urwopvwvpa0auz4e.png" alt="Image" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test execution&lt;/em&gt;&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%2Fnoby5mpaj3z8r5wxmalh.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%2Fnoby5mpaj3z8r5wxmalh.png" alt="Image " width="800" height="233"&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%2F1200%2F0%2AOuFAW1cgKAqN_RPf.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%2F1200%2F0%2AOuFAW1cgKAqN_RPf.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the test details can be viewed on the LambdaTest dashboard, including platform name, browser name, resolution, test execution logs, time taken to execute the tests, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Don’t waste time debugging your YAML files. Use our free&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/yaml-validator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;YAML validator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool to validate your YAML code quickly and identify syntax errors and fix them.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation [Test Scenario 2]
&lt;/h3&gt;

&lt;p&gt;In test scenario 2, we will navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/redirection?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Redirection&lt;/a&gt; page on &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s Selenium Playground&lt;/a&gt; website and verify that the page title is displayed using the &lt;em&gt;assertTrue()&lt;/em&gt; in Java.&lt;/p&gt;

&lt;p&gt;The steps for test scenario 2 will be automated using the &lt;em&gt;redirectionPageTest()&lt;/em&gt; method created inside the &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;em&gt;SeleniumPlaygroundTests.java&lt;/em&gt;&lt;/a&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests.java&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; @Test
    public void redirectionPageTest() {
        createDriver(Browsers.REMOTE_CHROME);
        final String website = "https://www.lambdatest.com/selenium-playground/";
        getDriver().get(website);

        final HomePage homePage = new HomePage();
        homePage.navigateToLink("Redirection");

        final var redirectionPage = new RedirectionPage();
        assertTrue(redirectionPage.isPageTitleDisplayed());
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The initial 3 lines in the test are the same as we discussed in the test scenario 1 implementation. We will not discuss the configuration and setup for creating a WebDriver session and launching the Chrome browser.&lt;/p&gt;

&lt;p&gt;Once the website is loaded on the browser, the &lt;em&gt;Redirection&lt;/em&gt; page is navigated, and further interaction is taken to check that the title is displayed on the page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class RedirectionPage {

    public boolean isPageTitleDisplayed() {
        return getDriver().findElement(By.tagName("h1")).isDisplayed();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;RedirectionPage&lt;/em&gt; class is created to update all the page objects related to the &lt;em&gt;Redirection&lt;/em&gt; page. The &lt;em&gt;isPageTitleDisplayed()&lt;/em&gt; method returns a boolean value using the Selenium WebDriver’s &lt;em&gt;isDisplayed()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;First, the Page title will be located, and then, using the &lt;em&gt;isDisplayed()&lt;/em&gt; method, the verification will be done to check that it is displayed on the page. The &lt;em&gt;assertTrue()&lt;/em&gt; method is finally used in the test to check the result of the boolean condition returned by the &lt;em&gt;isPageTitleDisplayed()&lt;/em&gt; method.&lt;/p&gt;

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

&lt;p&gt;The steps followed while executing Test Scenario 1 for setting the LambdaTest &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;AccessKey&lt;/em&gt; to execute the tests on the LambdaTest Cloud grid. The same steps need to be followed while executing this test.&lt;/p&gt;

&lt;p&gt;As we have already set the &lt;em&gt;LambdaTest Username&lt;/em&gt; and &lt;em&gt;AccessKey&lt;/em&gt; in the Configuration window, we can re-use the same window and just change the test method name to run this test.&lt;/p&gt;

&lt;p&gt;Click the Run/Debug Configuration dropdown and select the &lt;em&gt;Edit Configuration&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F0%2APjjwl-Ek3ahemGqo.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%2F1200%2F0%2APjjwl-Ek3ahemGqo.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the &lt;em&gt;redirectionPageTest()&lt;/em&gt; method name in the configuration window by clicking on the &lt;em&gt;three dots&lt;/em&gt; next to the &lt;em&gt;Method name&lt;/em&gt; field. Leave the other settings/configurations as they are and click “Apply” and then the “OK” button to close the configuration window.&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%2F9lcuoe0c817a456smme5.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%2F9lcuoe0c817a456smme5.png" alt="Image" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tests can now be executed by clicking on the green button next to the Run/Debug configuration field.&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%2Fwigei2f0sc0krlcy3znc.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%2Fwigei2f0sc0krlcy3znc.png" alt="Image" width="732" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test execution&lt;/em&gt;&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%2Fasywvftp8vdi5d8076yt.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%2Fasywvftp8vdi5d8076yt.png" alt="Image" width="800" height="248"&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%2Fho5whd260ccvqlrym11t.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%2Fho5whd260ccvqlrym11t.png" alt="Image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The test execution can be checked in the LambdaTest Build details windows after logging in to the LambdaTest website. This window provides granular details of the test execution that help know the test analytics and execution status.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation [Test Scenario 3]
&lt;/h3&gt;

&lt;p&gt;In test scenario 3, we will navigate to the &lt;a href="https://www.lambdatest.com/selenium-playground/data-list-filter-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Data Filter List&lt;/a&gt; page on &lt;a href="https://www.lambdatest.com/selenium-playground/" rel="noopener noreferrer"&gt;LambdaTest’s Selenium playground&lt;/a&gt; website to search for an attendee record by entering a name. Once the records are retrieved based on the filter according to the name provided, the record will be verified using the &lt;em&gt;assertTrue()&lt;/em&gt; method by checking if the Attendee name in the record contains the name searched for.&lt;/p&gt;

&lt;p&gt;The steps for test scenario 3 will be automated using the &lt;em&gt;dataFilterPageTest()&lt;/em&gt; method that is updated inside the &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;em&gt;SeleniumPlaygroundTests.java&lt;/em&gt;&lt;/a&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filename:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jan_12&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests.java&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; @Test
    public void dataFilterPageTest() {
        createDriver(Browsers.REMOTE_CHROME);
        final String website = "https://www.lambdatest.com/selenium-playground/";
        getDriver().get(website);

        final HomePage homePage = new HomePage();
        homePage.navigateToLink("Data List Filter");

        final var dataListFilterPage = new DataListFilterPage();
        final String attendeeName = "Dwayne";
        dataListFilterPage.searchAttendees(attendeeName);
        assertTrue(dataListFilterPage.getAttendeeName().contains(attendeeName));
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this test, we will first open the Chrome browser in the LambdaTest Cloud grid and navigate to the &lt;em&gt;Data List Filter&lt;/em&gt; Page on &lt;em&gt;LambdaTest’s Selenium Playground&lt;/em&gt; website.&lt;br&gt;&lt;br&gt;
Next, it will search for the data with the attendee name “&lt;em&gt;Dwayne&lt;/em&gt;”. Once the data is loaded on the page, the &lt;em&gt;assertTrue()&lt;/em&gt; method will check the condition that the attendee name in the results contains the text — “&lt;em&gt;Dwayne&lt;/em&gt;”. The test will be marked as pass if the text is found in the Attendee’s name in the data results.&lt;/p&gt;

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

&lt;p&gt;The test for scenario 3 can be easily run by just changing the method name from the Run Configuration window, as shown in 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%2Fio1m388246loq9z5ns6j.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%2Fio1m388246loq9z5ns6j.png" alt="Image" width="800" height="521"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the method is selected, click the Apply button and then the OK button to close the config window. To run the test, click the Green Play button on the toolbar on the top,&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%2Ff3mayx5gtoau9tvpc7uu.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%2Ff3mayx5gtoau9tvpc7uu.png" alt="Image" width="754" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test execution&lt;/em&gt;&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%2Fh0r34ahnv4ljzf4r9he8.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%2Fh0r34ahnv4ljzf4r9he8.png" alt="Image " width="800" height="244"&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%2F4t7dwee5yxtzfyuxgtrh.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%2F4t7dwee5yxtzfyuxgtrh.png" alt="Image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Without assertions, an automated test is incomplete. Assertions help us to derive the results of the automated tests. This can help in providing faster feedback on the software builds.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;assertTrue()&lt;/em&gt; in Java is used to perform assertions in automated tests. We can verify a boolean condition using this method. This web automation method can ideally be used to check if a particular web element, like a checkbox or a radio button is enabled. It can also help in checking if a particular text is displayed. Further, it can be used for checking boolean conditions like text on a web page containing a particular string or text.&lt;/p&gt;

&lt;p&gt;I hope this helps you in writing better assertions for the automated tests.&lt;/p&gt;

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

</description>
      <category>asserttrue</category>
      <category>javascript</category>
      <category>automationtesting</category>
      <category>softwaretesting</category>
    </item>
    <item>
      <title>How To Perform Visual Regression Testing With Selenium And Smart UI</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Tue, 21 Nov 2023 06:12:14 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-perform-visual-regression-testing-with-selenium-and-smart-ui-29a9</link>
      <guid>https://dev.to/testmuai/how-to-perform-visual-regression-testing-with-selenium-and-smart-ui-29a9</guid>
      <description>&lt;p&gt;User Interface or UI is the most critical front-facing part of an application. If it is not good enough to capture the users’ attention, they may stop using the application. Currently, all businesses are operated online, and the basic need for operating an online business is to have a website or a mobile application that supports all the browsers, operating systems, and mobile devices that are popular in the region where the business is operated.&lt;/p&gt;

&lt;p&gt;If the website or mobile application fails to captivate users, they may exit the site immediately after landing on the homepage. This phenomenon is often called the website’s bounce rate, indicating instances where visitors neither interact with content nor proceed to the second page.&lt;/p&gt;

&lt;p&gt;As per the report, the average bounce rate is somewhere between 26% to 70%, with the optimal range between 26% to 40%. If the bounce rate is too high, it may affect the businesses, and the websites might not lead to conversion in sales.&lt;/p&gt;

&lt;p&gt;Another report by Contentsquare says that users, after landing on the website, spent around 45 seconds to 54 seconds. This is less than a minute, and if the website behavior, responsiveness, and uniformity between the website pages are not good, users might leave the website without navigating to other pages.&lt;/p&gt;

&lt;p&gt;Hence, monitoring the application’s User Interface(UI) and the User Experience(UX) is important. User experience(UX) refers to how easy the application is for the end user to learn and use.&lt;/p&gt;

&lt;p&gt;Social Media websites such as Facebook, Instagram, Twitter, etc, do not come with an operating manual or a user guide. The UI and UX are so easy to understand that it appeals to the user to register themselves, login, and start using the application. Similarly, the same goes for shopping applications like Amazon. The UI makes it clear to the user that they can register, login, buy a product, or even cancel an order at their fingertips.&lt;/p&gt;

&lt;p&gt;Though some applications have user guides, most are made in such a self-understanding fashion that users can learn to use them independently because the User Interface(UI) and User Experience(UX) make it so simple.&lt;/p&gt;

&lt;p&gt;With every release of the applications, minor or major changes may be applied to existing User Interfaces, or new screens may also be added. With this, there is a need to check the application’s visuals after the recent changes have been applied by performing a round of regression tests on the User Interface(UI). It refers to checking the background color, text color, font, images, logo, etc are displayed correctly. The actual screen of the application can also be compared with the mock screens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your native, hybrid, and web apps across all legacy and latest mobile operating systems on the most powerful&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/android-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Android emulator online&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AflN7WylQzV1qtr_3.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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AflN7WylQzV1qtr_3.jpg" alt="image" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a screenshot of an image showing how the visual regression is performed as the product evolves.&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%2F800%2F0%2ADA2k_uLaYZx6Psq-.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%2F800%2F0%2ADA2k_uLaYZx6Psq-.png" alt="image" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the baseline image, which is the initial version of the application, we can see that only the logo was displayed. In the next version, the logo and the text were designed to be displayed in the app. In the visual regression test, the difference was highlighted by comparing the latest image of the application with the baseline image.&lt;/p&gt;

&lt;p&gt;In this blog on Selenium visual regression testing, we will discuss visual regression testing in detail and how to perform it with Selenium and LambdaTest’s SmartUI.&lt;/p&gt;

&lt;p&gt;New to Selenium? Check our getting started guide — &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;What is Selenium&lt;/a&gt;?&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Visual Regression Testing?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/visual-regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Visual regression testing&lt;/a&gt; is a method to verify that the changes made to the User Interface(UI) of the application are correct so the users don’t face any difficulty interacting with it. It is a kind of &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;regression testing&lt;/a&gt;. However, in this testing type, the User Interface of the application is closely tested and compared with the previous version.&lt;/p&gt;

&lt;p&gt;Visual Validations such as location of the web elements, brightness, contrast, and color of the buttons, menus, components, text, and their respective alignments are verified in visual regression tests.&lt;/p&gt;

&lt;p&gt;The target is to find visual bugs, such as misaligned buttons, overlapping images, texts, or buttons, partially visible elements, rendering issues, etc.&lt;/p&gt;

&lt;p&gt;To make it understand better, let’s take a hypothetical example of a login screen of a demo application. &lt;em&gt;Version 1&lt;/em&gt; of the application had a simple login screen where the user could enter the &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;Password&lt;/em&gt; and click the &lt;strong&gt;Log In&lt;/strong&gt; button to enter the website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &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=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;end-to-end Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what E2E Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AVCTbSqjVhzD4dO2P.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%2F800%2F0%2AVCTbSqjVhzD4dO2P.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Login Page version 1&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In &lt;em&gt;Version 2&lt;/em&gt; of the application, a new feature is introduced to allow users to sign in using their &lt;em&gt;Google&lt;/em&gt; and &lt;em&gt;Apple&lt;/em&gt; accounts. To accommodate this change, two new buttons were introduced on the Login page with &lt;em&gt;Google&lt;/em&gt; and &lt;em&gt;Apple&lt;/em&gt; account logos, allowing users to log in with the respective accounts.&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%2F800%2F0%2ARwCyI7V4JyVVVqG_.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%2F800%2F0%2ARwCyI7V4JyVVVqG_.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Login Page version 2 [candidate for visual regression testing]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After the changes were implemented on &lt;em&gt;Version 2&lt;/em&gt; of the website, it can be seen that for accommodating the &lt;em&gt;Google&lt;/em&gt; and &lt;em&gt;Apple&lt;/em&gt; logos for allowing Login with the respective accounts, the &lt;strong&gt;Log In&lt;/strong&gt; button was misaligned and started to overlap with the &lt;em&gt;Password&lt;/em&gt; field.&lt;/p&gt;

&lt;p&gt;This is a visual bug that can be caught using visual regression testing. This issue could occur across browsers, operating systems, and devices. It can be a huge turn-off and might irk the visitors to the website, and they may even stop using the website due to it.&lt;/p&gt;

&lt;p&gt;As this is a simple example, &lt;strong&gt;Log In&lt;/strong&gt; button overlapping with the &lt;em&gt;Password&lt;/em&gt; field can be seen easily. However, imagine a &lt;em&gt;Home Page&lt;/em&gt; screen of an eCommerce website. If changes happen on such a congested page with many web elements, texts, images, etc., it is hard to notice the issue manually.&lt;/p&gt;

&lt;p&gt;Another example of the visual bug is the following screenshot from the Netflix website, where the visual bug surfaced that showed the placeholder instead of the phone number.&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%2F800%2F0%2AebON5wCRtW0Vlt5p.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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AebON5wCRtW0Vlt5p.jpg" alt="image" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In such a situation, automated visual regression testing can come to the rescue and save our time as well as upkeep the quality of the application. Visual regression testing should be done for websites and mobile applications across different platforms, browsers, and mobile devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &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=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;end-to-end Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what E2E Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Visual Regression Testing work?
&lt;/h3&gt;

&lt;p&gt;Visual regression testing is performed by pixel-by-pixel comparison of two application screenshots. The first one is taken with the stable version of the application.&lt;/p&gt;

&lt;p&gt;For example, &lt;em&gt;Version 1&lt;/em&gt;, which is the stable version of the application, this image is termed a “&lt;em&gt;Baseline image.&lt;/em&gt;” The second screenshot is taken after the required changes are applied to the application. For example, &lt;em&gt;Version 2&lt;/em&gt;, which is the current version under development, this image is called “&lt;em&gt;Current Image.&lt;/em&gt;”&lt;/p&gt;

&lt;p&gt;Both screenshots are compared by verifying that the web elements on the page are aligned correctly, not overlapping, and displayed in proper size and color. The text and fonts are also compared in visual regression tests.&lt;/p&gt;

&lt;p&gt;The test is marked as successful if both of the comparisons of the screenshots show that there is no difference between them and the UI of the new version of the application is the same as it was in the previous version.&lt;/p&gt;

&lt;p&gt;However, the test will fail if there is a difference in comparison between the images. The visual regression tool highlights the difference in Baseline v/s Current Image and shows the mismatch percentage.&lt;/p&gt;

&lt;p&gt;Apart from showing the mismatch between the Baseline and Current image, visual regression testing also has many other important points to uncover. Let’s find out all of them in the next section of this blog on Selenium visual regression testing, where we discuss the importance of visual regression testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is Visual Regression Testing important?
&lt;/h3&gt;

&lt;p&gt;An application can be useless if the UI and UX are not good and don’t support the application’s working. As per the Leadpages UX statistics, a good UI can raise a website’s conversion rate by 200%, whereas a 1-second delay in page response results in a 7% reduction in conversions.&lt;/p&gt;

&lt;p&gt;Let’s take an example of an eCommerce web application, where the user can search for a product from the Home page and click the &lt;strong&gt;Add to Cart&lt;/strong&gt; button to add the product to the cart. However, if the &lt;strong&gt;Add to Cart&lt;/strong&gt; button overlaps and is misaligned with the &lt;strong&gt;Buy Now&lt;/strong&gt; button and is not clickable, it would block the user from adding the product to the cart and eventually purchasing it.&lt;/p&gt;

&lt;p&gt;Here, it has nothing to do with the functionality, as it will work once the user can add the product to the cart using the &lt;strong&gt;Add to Cart&lt;/strong&gt; button. The problem is with the UI; the Add to Cart button is not displayed correctly.&lt;/p&gt;

&lt;p&gt;The following screenshot shows the visual bug where the &lt;strong&gt;Add to Cart&lt;/strong&gt; button is misaligned, and the user cannot interact. Also, it can be seen that the size of the Buttons is not as per the standard and needs to be fixed.&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%2F800%2F0%2Aa0v1-H0_WwDAiwCN.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%2F800%2F0%2Aa0v1-H0_WwDAiwCN.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Screenshot of the web page after the visual bug was fixed&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A0PNJGrTC04T3NEO4.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%2F800%2F0%2A0PNJGrTC04T3NEO4.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/functional-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Functional testing&lt;/a&gt; mostly covers the verification and validation of data input and output. However, it doesn’t cover the visual issues like alignment of the buttons, text, background color contrast, etc. So, visual regression testing can help us uncover the UI issues here.&lt;/p&gt;

&lt;p&gt;Visual regression testing is important in the following ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It helps provide a better User Interface and User Experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A good User Interface and User Experience builds trust and credibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It helps in identifying Cross-platform, Cross-browser, and Cross-devices issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A better UI and UX can serve as a guide to the user towards actions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It helps verify what aspects of UI are being worked upon for the betterment of the business through websites/applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Considering the importance of visual regression testing, it is recommended to spend some effort on &lt;a href="https://www.lambdatest.com/learning-hub/visual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;visual testing&lt;/a&gt; that might help in user retention.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;Visual Testing captures and verifies the visual appearance of an application or webpage to identify deviations from the expected design. On the other hand, Visual Regression Testing detects unintended visual changes between different versions of an application or webpage to prevent design regressions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s now move ahead and check out how to perform visual regression testing using &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; and LambdaTest’s Smart UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Appium Automation&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, learn about Appium and its benefits for mobile automation testing. Take a look at how Appium works and see how to perform Appium testing of your mobile applications.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to run Visual Regression Tests with Selenium and LambdaTest’s Smart UI?
&lt;/h3&gt;

&lt;p&gt;In visual regression testing, we compare screenshots and identify pixel variations. It is integrated with &lt;a href="https://www.lambdatest.com/hyperexecute?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;HyperExecute&lt;/a&gt; from LambdaTest, allowing you to execute &lt;a href="https://www.lambdatest.com/smart-visual-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Smart UI tests&lt;/a&gt; on the platform. We will use the following test scenario to demonstrate Selenium visual regression testing using Smart UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 1&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce playground&lt;/a&gt; website’s &lt;em&gt;Laptop&lt;/em&gt; product page&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the &lt;em&gt;Laptop&lt;/em&gt; product page image as the Baseline image using the automation code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the LambdaTest’s eCommerce website’s &lt;em&gt;Desktop&lt;/em&gt; product page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare the &lt;em&gt;Desktop&lt;/em&gt; product page with the &lt;em&gt;Laptop&lt;/em&gt; product page using visual regression on Smart UI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the differences in LambdaTest’s Smart UI.&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%2F800%2F0%2AZ9ts3NRdY8V_KZMs.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%2F800%2F0%2AZ9ts3NRdY8V_KZMs.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Laptop product page — LambdaTest eCommerce website&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AKQBZrugFYPCdY_E9.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%2F800%2F0%2AKQBZrugFYPCdY_E9.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Desktop product page — LambdaTest eCommerce website&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce playground&lt;/a&gt; website’s &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=57" rel="noopener noreferrer"&gt;&lt;em&gt;Tablets&lt;/em&gt; product page&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the &lt;em&gt;Laptop&lt;/em&gt; product page image as the Baseline image in LambdaTest’s Smart UI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to LambdaTest’s eCommerce website’s &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;Home Page&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Compare the Homepage with the &lt;em&gt;Tablets&lt;/em&gt; product page using LambdaTest’s Smart UI.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the differences in the LambdaTest’s Smart UI.&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%2F800%2F0%2AexEA1VQ6dEF_QWhE.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%2F800%2F0%2AexEA1VQ6dEF_QWhE.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tablets product page — LambdaTest eCommerce website&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AMKg5zuHtU3ES3Ph3.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%2F800%2F0%2AMKg5zuHtU3ES3Ph3.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Home Page — LambdaTest eCommerce website&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before implementing the test scenarios, let’s learn about setting up Selenium visual regression testing with Smart UI on the LambdaTest cloud grid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Through this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/usability-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;usability testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, you will learn how usability testing is a great way to discover unexpected bugs, find what is unnecessary or unused before going any further, and have unbiased opinions from an outsider.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started with Selenium Visual Regression Testing on Smart UI
&lt;/h3&gt;

&lt;p&gt;To use Selenium visual regression testing on Smart UI, we first need to register with LambdaTest and access LambdaTest’s Smart UI.&lt;/p&gt;

&lt;p&gt;Once we have access, log into the LambdaTest account, navigate to the Dashboard screen, and perform the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On the left-hand menu section, click the &lt;strong&gt;Smart UI&lt;/strong&gt; menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the Smart UI window, click the &lt;strong&gt;New Project&lt;/strong&gt; button on the right-hand top corner of the screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the project details, as we will be performing the Selenium visual regression testing for the website, we need to select the platform as “Web”.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visual regression testing can also be performed for mobile applications using &lt;a href="https://www.lambdatest.com/learning-hub/appium-visual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;real mobile devices and the Appium framework&lt;/a&gt;. Next, provide the project name.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select your name in the &lt;em&gt;Approver Name&lt;/em&gt; field, or if it’s your organization account and you need another person to be an approver, select the respective person’s account name in this box. Once all the details are updated, click the &lt;strong&gt;Create Project&lt;/strong&gt; button to create the project successfully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, select the framework you want to run your automation tests with. We will be selecting Selenium, Java, and TestNG here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On selecting the framework, we will be taken to the next screen, where we will be provided with the screen to set the configurations. Ensure to provide the Smart UI Project Name capability in this screen, which is mandatory for Selenium visual regression testing. Once the capabilities are updated, we can copy it and use it in our automation test configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the project is created successfully, it will be shown in the Smart UI project screen as shown in the screenshot below:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Setting the Baseline Image
&lt;/h3&gt;

&lt;p&gt;After the Smart UI project is created successfully, we need to set the Baseline image, the visual regression will be performed by comparing the Baseline image with the current image of the application.&lt;/p&gt;

&lt;p&gt;There are two ways to capture the Baseline image:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Uploading the Baseline image using Smart UI API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Running the &lt;a href="https://www.lambdatest.com/learning-hub/web-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web automation&lt;/a&gt; test and setting the screenshot image captured in the first test as the Baseline image.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Uploading the Baseline image using Smart UI API
&lt;/h4&gt;

&lt;p&gt;The following steps need to be performed to upload the Baseline image using API:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to the Smart UI Project screen and click on the project for which the Baseline image needs to be uploaded. Here, we will select the project we created in the previous section — “Visual_regression_web”.&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%2F800%2F0%2Axm8k2N-ehurXQ1Ww.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%2F800%2F0%2Axm8k2N-ehurXQ1Ww.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On the next screen, click the &lt;strong&gt;Upload API&lt;/strong&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Acashjc5bGUEA3uhy.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%2F800%2F0%2Acashjc5bGUEA3uhy.png" alt="image" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the next screen, Swagger will be displayed with the API details.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;Smart UI Automation&lt;/strong&gt; tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Checkout for the Upload Screenshots API endpoint. This endpoint will be used to upload the Baseline image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy the value provided in the after the words “PROJECT_TOKEN=” text. This will be required to upload the Baseline image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click the &lt;strong&gt;Try it out&lt;/strong&gt; button to upload the image.&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%2F800%2F0%2A0SdbTTBks2zcZSm9.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%2F800%2F0%2A0SdbTTBks2zcZSm9.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After clicking the &lt;strong&gt;Try it out&lt;/strong&gt; button, the following details must be provided in the API request to upload the Baseline image successfully.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;FIELD NAME&lt;/th&gt;
&lt;th&gt;DESCRIPTION&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Files&lt;/td&gt;
&lt;td&gt;We need to select the image file that needs to be set as a Baseline image in this field. Multiple files can also be selected here.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;projectToken&lt;/td&gt;
&lt;td&gt;This value is provided in the previous screen where we clicked on the Upload API button; we already copied this value previously that can be pasted in this field.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;buildName&lt;/td&gt;
&lt;td&gt;The name of the build for which you are running the tests. Any value can be provided here. It can be left as it is since it is an optional field.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Baseline&lt;/td&gt;
&lt;td&gt;Select true in this field.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ScreenshotNames&lt;/td&gt;
&lt;td&gt;Provide a name for the screenshot image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;githubURL&lt;/td&gt;
&lt;td&gt;This is an optional field; it can be left blank. If needed, the GitHub URL for the project can be provided here.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/black-box-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Black Box testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;? Don’t worry; we will be covering what is Black box testing, merits, demerits, types &amp;amp; techniques.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AJ_L8vslp31fgkK5y.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%2F800%2F0%2AJ_L8vslp31fgkK5y.png" alt="image" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter the Authorization details by clicking the &lt;strong&gt;Authorize&lt;/strong&gt; button on the top right corner of the screen.&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%2F800%2F0%2AZP8beUd0cA75V17b.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%2F800%2F0%2AZP8beUd0cA75V17b.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter the LambdaTest credentials in the authorization details. The LambdaTest credentials are in the &lt;em&gt;Profile &amp;gt;&amp;gt; Account Settings&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AOzODoT9JoqXcOxsb.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%2F800%2F0%2AOzODoT9JoqXcOxsb.png" alt="image" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Account Settings window, navigate to the Password and Security Tab and copy and paste the &lt;em&gt;Username&lt;/em&gt; and &lt;em&gt;Access Key&lt;/em&gt; values.&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%2F800%2F0%2AdB1L5JRRRa7kF1i_.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%2F800%2F0%2AdB1L5JRRRa7kF1i_.png" alt="image" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These values can be copied and pasted in the Authorization window. Click on the &lt;strong&gt;Authorize&lt;/strong&gt; button and close the Authorization window.&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%2F800%2F0%2AW8JsOGDIbg8kK3jT.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%2F800%2F0%2AW8JsOGDIbg8kK3jT.png" alt="image" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;strong&gt;Execute&lt;/strong&gt; button to upload the Baseline image.&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%2F800%2F0%2AUjSNSAxmN-4fYG4h.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%2F800%2F0%2AUjSNSAxmN-4fYG4h.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On successful execution of the API request, we should get a response with status code 200 and status — “success” along with other details.&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%2F800%2F0%2AtJ-pPjIqnUrLKgvR.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%2F800%2F0%2AtJ-pPjIqnUrLKgvR.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On successfully uploading the image through API, it should be reflected in the Smart UI project and marked as an Approved Baseline image.&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%2F800%2F0%2A2ybL6yGhe408bZKj.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%2F800%2F0%2A2ybL6yGhe408bZKj.png" alt="image" width="800" height="429"&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%2F800%2F0%2ARpRJw1bK7EZoizIA.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%2F800%2F0%2ARpRJw1bK7EZoizIA.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have successfully uploaded the Baseline image using the Smart UI API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this blog on the&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/best-mobile-automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;mobile app automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tools, we list the best 11 mobile automation testing tools with their advantages and business-friendly features.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Uploading Baseline Image using the Web Automation Tests
&lt;/h4&gt;

&lt;p&gt;The other option to upload the Baseline image is to upload the image using the web automation tests; we will check out in the next section of this blog on Selenium visual regression testing after setting up the automation project with Selenium WebDriver.&lt;/p&gt;

&lt;p&gt;Let’s first create and set up the web automation project. The following tech stack will be used to demo Selenium visual regression testing with Smart UI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language — Java 17&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Automation tool — Selenium WebDriver — &lt;em&gt;version — 4.11.0&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visual Regression Testing tool — LambdaTest’s Smart UI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Application under test — &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest eCommerce Playground&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool — &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=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner — &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud Platform to run web automation tests — LambdaTest&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Project Setup&lt;/p&gt;

&lt;p&gt;Let’s create a Maven project and update the dependencies for the Selenium WebDriver and TestNG in the pom.xml file. &lt;em&gt;Maven-compiler-plugin&lt;/em&gt; is updated in the build section of pom.xml to compile the sources of the project. The &lt;em&gt;Maven-surefire-plugin&lt;/em&gt; is provided as it allows executing the tests in the project during the build lifecycle.&lt;/p&gt;

&lt;p&gt;Following is the pom.xml file used in the project.&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;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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;selenium-visual-regression-example&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
&amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

&amp;lt;name&amp;gt;selenium-visual-regression-example&amp;lt;/name&amp;gt;
&amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

&amp;lt;properties&amp;gt;
&amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
&amp;lt;selenium.java.version&amp;gt;4.11.0&amp;lt;/selenium.java.version&amp;gt;
&amp;lt;testng.version&amp;gt;7.8.0&amp;lt;/testng.version&amp;gt;
&amp;lt;maven.compiler.version&amp;gt;3.11.0&amp;lt;/maven.compiler.version&amp;gt;
&amp;lt;surefire-version&amp;gt;3.1.2&amp;lt;/surefire-version&amp;gt;
&amp;lt;java.release.version&amp;gt;17&amp;lt;/java.release.version&amp;gt;
&amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
&amp;lt;suite-xml&amp;gt;testng.xml&amp;lt;/suite-xml&amp;gt;
&amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;
&amp;lt;/properties&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;${selenium.java.version}&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;${testng.version}&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;build&amp;gt;
&amp;lt;plugins&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
&amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
&amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
&amp;lt;executions&amp;gt;
&amp;lt;execution&amp;gt;
&amp;lt;goals&amp;gt;
&amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
&amp;lt;/goals&amp;gt;
&amp;lt;/execution&amp;gt;
&amp;lt;/executions&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
&amp;lt;properties&amp;gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&amp;lt;/properties&amp;gt;
&amp;lt;suiteXmlFiles&amp;gt;
&amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
&amp;lt;/suiteXmlFiles&amp;gt;
&amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;/plugins&amp;gt;
&amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3DgMLH5EcIdFQ8V6.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%2F800%2F0%2A3DgMLH5EcIdFQ8V6.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the dependencies and plugins addition in the pom.xml file, the project setup is complete. Let’s now move ahead and learn how to perform Selenium visual regression testing with a practical scenario in the next section of this blog on Selenium visual regression testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation [Test Scenario 1]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, we will perform the visual regression for the LambdaTest eCommerce playground website’s &lt;em&gt;Laptop&lt;/em&gt; product page by comparing it with the &lt;em&gt;Desktop&lt;/em&gt; product page.&lt;/p&gt;

&lt;p&gt;Before writing the tests and performing the image comparison using the visual regression Smart UI, we must configure the LambdaTest capabilities to run the test.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator&lt;/a&gt; helps us get all the required capabilities to run the test on the LambdaTest cloud 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AcnPgkgnQnqkU7MOk.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%2F800%2F0%2AcnPgkgnQnqkU7MOk.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-powered test orchestration and execution platform that lets you perform visual regression testing at scale using visual testing tools like &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;. With the LambdaTest AI-driven Smart UI platform, you can run automated visual tests on an &lt;a href="https://www.lambdatest.com/selenium-grid-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online Selenium grid&lt;/a&gt; across 3000+ browser environments.&lt;/p&gt;

&lt;p&gt;If you wish to perform Selenium visual regression testing using LambdaTest SmartUI, visit the documentation — &lt;a href="https://www.lambdatest.com/support/docs/selenium-visual-regression/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=support_doc" rel="noopener noreferrer"&gt;Selenium visual regression testing with Smart UI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We also have a dedicated tutorial on visual regression testing with Smart UI. Watch it below!&lt;/p&gt;

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

&lt;p&gt;Subscribe to our &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; for the latest updates on tutorials around Selenium, &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Elevate the app testing process from these 12 best&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/mobile-app-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;mobile app testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;. Our comprehensive list includes top-performing tools for achieving excellence. Learn more here.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For running the visual regression tests using Smart UI, the following capabilities are required:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Smart UI Project Name&lt;/em&gt; — the values can be supplied using the key “&lt;em&gt;smartUI.project&lt;/em&gt;” in the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, the following Smart UI options can be provided in the configuration to help perform Selenium visual regression testing using pixel-to-pixel comparison.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
 &lt;tr&gt;
 &lt;td&gt;OPTION NAME&lt;/td&gt;
 &lt;td&gt;DESCRIPTION &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;largeImageThreshold&lt;/td&gt;
 &lt;td&gt;It will set the pixel granularity at the rate at which the pixel blocks are created. &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;errorType&lt;/td&gt;
 &lt;td&gt;It will show the differences in the output screen by identifying the pixel change type and capturing the intended view. &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;ignore&lt;/td&gt;
 &lt;td&gt;It removes the pixel-to-pixel false-positive rate in identifying the screenshot. &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Transparency&lt;/td&gt;
 &lt;td&gt;It helps in adjusting test transparency settings and strikes a balance between highlighting and visual screening. &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;boundingBoxes: [box1, box2]&lt;/td&gt;
 &lt;td&gt;By specifying a bounding box measured in pixels from the top left, the comparison area can be narrowed down. &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;ignoredBoxes: [box1, box2]&lt;/td&gt;
 &lt;td&gt;By specifying a bounding box measured in pixels from the top left, a part of the image can be excluded from comparison &lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For more details about the options below, checkout the &lt;a href="https://www.lambdatest.com/support/docs/test-settings-options/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=support_doc" rel="noopener noreferrer"&gt;Advanced Test Settings&lt;/a&gt; options page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This article on the Best&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/top-ui-automated-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;UI Automated Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Tools cover what is UI automated testing, challenges while performing UI testing, and top tools that can help you perform UI testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Setting the Baseline image&lt;/p&gt;

&lt;p&gt;The Baseline image must be set first to perform the Selenium visual regression testing. We saw one way to update the Baseline image using the Smart UI API in the earlier section of this blog on Selenium visual regression testing. Let’s now learn about updating the Baseline image using the automation code.&lt;/p&gt;

&lt;p&gt;Baseline image can be updated from the code using the following desired capability:&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%2F800%2F0%2AForYujNq7zWFdL_O.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%2F800%2F0%2AForYujNq7zWFdL_O.png" alt="image" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The values for the key “smartUI.project” is the name of the project we created in the Smart UI on the LambdaTest cloud grid.&lt;/p&gt;

&lt;p&gt;The above capability is provided in the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method in the &lt;em&gt;DriverManager&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public class DriverManager {

protected WebDriver driver;
private static final String LT_USERNAME = System.getProperty("LT_USERNAME");
private static final String LT_ACCESS_KEY = System.getProperty("LT_ACCESS_KEY");
private static final String GRID_URL = "@hub.lambdatest.com/wd/hub";

public void createChromeDriverInCloud() {
final ChromeOptions browserOptions = new ChromeOptions();
browserOptions.setPlatformName("Windows 10");
final HashMap&amp;lt;String, Object&amp;gt; ltOptions = new HashMap&amp;lt;&amp;gt;();
ltOptions.put("username", LT_USERNAME);
ltOptions.put("accessKey", LT_ACCESS_KEY);
ltOptions.put("resolution", "2560x1440");
ltOptions.put("video", true);
ltOptions.put("smartUI.project", "Visual Regression Selenium");
ltOptions.put("smartUI.baseline", true);
ltOptions.put("w3c", true);
ltOptions.put("plugin", "java-testNG");
final var smartOptions = new HashMap&amp;lt;String, Object&amp;gt; ();
smartOptions.put ("largeImageThreshold", 1200);
smartOptions.put ("transparency", 0.3);
smartOptions.put ("errorType", "movement");
ltOptions.put ("smartUI.options", smartOptions);
browserOptions.setCapability("LT:Options", ltOptions);
try {
this.driver = new RemoteWebDriver(new URL(format("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)), browserOptions);
} catch (final MalformedURLException e) {
throw new Error("RemoteDriver's URL not set correctly!");
}
this.driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
}

public WebDriver getDriver() {
return this.driver;
}

public void quitDriver() {
this.driver.quit();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; sets the desired capabilities and options to run the web automation tests on the LambdaTest cloud grid.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; also has the Smart UI options “&lt;em&gt;largeImageThreshold&lt;/em&gt;”, “&lt;em&gt;transparency&lt;/em&gt;”, and “&lt;em&gt;errorType&lt;/em&gt;.” It is updated as follows:&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%2F800%2F0%2AdQnb1xGOPoK2gLiC.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%2F800%2F0%2AdQnb1xGOPoK2gLiC.png" alt="image" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the full &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method for your ready reference:&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%2F800%2F0%2AvbXcpvFDpnpKjsQC.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%2F800%2F0%2AvbXcpvFDpnpKjsQC.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, we have completed the configuration and setup of the project. Next, let’s discuss writing the tests.&lt;/p&gt;

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

&lt;p&gt;The &lt;a href="https://github.com/mfaisalkhatri/selenium-visual-regression-example/blob/main/src/test/java/io/github/mfaisalkhatri/pages/ProductPage.java" rel="noopener noreferrer"&gt;&lt;em&gt;ProductPage&lt;/em&gt;&lt;/a&gt; class has the &lt;em&gt;checkVisual()&lt;/em&gt; method to help us perform the Selenium visual regression testing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ProductPage {
private WebDriver driver;
public ProductPage(final WebDriver driver) {
this.driver= driver;
}
private static final String SCREEN_NAME = "Product-Page";

public void checkVisual() {
((JavascriptExecutor) this.driver).executeScript (MessageFormat.format ("smartui.takeScreenshot={0}", SCREEN_NAME));
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;checkVisual()&lt;/em&gt; method will take a screenshot and update its name to “&lt;em&gt;Product-Page&lt;/em&gt;”. This screenshot will be compared against the Baseline image.&lt;/p&gt;

&lt;p&gt;Next, let’s write an automated test for Selenium visual regression testing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class VisualRegressionTests extends BaseTest {
@Test
public void testECommerceVisualRegression() {
this.driverManager.getDriver().get("https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=20");
final var productPage = new ProductPage(this.driverManager.getDriver());
productPage.checkVisual();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://github.com/mfaisalkhatri/selenium-visual-regression-example/blob/main/src/test/java/io/github/mfaisalkhatri/tests/VisualRegressionTests.java" rel="noopener noreferrer"&gt;&lt;em&gt;VisualRegressionTests&lt;/em&gt;&lt;/a&gt; class is created for housing all the visual regression tests. For testing Test Scenario 1, the &lt;em&gt;testECommerceVisualRegressionScenarioOne()&lt;/em&gt; method is created.&lt;/p&gt;

&lt;p&gt;The following line of code will navigate to the &lt;em&gt;Laptop&lt;/em&gt; Product page screen.&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%2F800%2F0%2ACZntJU1U4FU_uSi_.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%2F800%2F0%2ACZntJU1U4FU_uSi_.png" alt="image" width="800" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, the &lt;em&gt;ProductPage&lt;/em&gt; class is instantiated, and its &lt;em&gt;checkvisual()&lt;/em&gt; method is called, which will capture the screenshot of the &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=18" rel="noopener noreferrer"&gt;&lt;em&gt;Laptop&lt;/em&gt; product page&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%2F800%2F0%2AZPnOk7C7ZEs8Cudg.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%2F800%2F0%2AZPnOk7C7ZEs8Cudg.png" alt="image" width="800" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshot captured from this test will be uploaded in the LambdaTests’s Smart UI and marked as a Baseline image.&lt;/p&gt;

&lt;p&gt;Next, we will rerun the test by changing the navigation URL and pointing it to the &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=20" rel="noopener noreferrer"&gt;&lt;em&gt;Desktop&lt;/em&gt; product page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To summarize, the following is the current screenshot of the &lt;em&gt;Laptop&lt;/em&gt; product 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%2F800%2F0%2A4CuNQqjWAiNqGPmV.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%2F800%2F0%2A4CuNQqjWAiNqGPmV.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Deep dive to learn about&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Software automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its uasage, types and also gain insights on how to get started with automated testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The following testng.xml file is created in the project’s root folder. We will be executing this file to run 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;&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="LambdaTest ecommerce playground website test suite "&amp;gt;
&amp;lt;test name="Visual Regression Tests"&amp;gt;
&amp;lt;classes&amp;gt;
&amp;lt;class name="io.github.mfaisalkhatri.tests.VisualRegressionTests"&amp;gt;
&amp;lt;methods&amp;gt;
&amp;lt;include name="testECommerceVisualRegressionScenarioOne"/&amp;gt;
&amp;lt;/methods&amp;gt;
&amp;lt;/class
&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;Run the test to upload the Baseline image by right-clicking on the testng.xml file and selecting the option ‘&lt;em&gt;../Run ../testng.xml&lt;/em&gt;’&lt;/p&gt;

&lt;p&gt;Screenshot of the test execution using IntelliJ:&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%2F800%2F0%2An9a8mtC0YSwsvM3A.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%2F800%2F0%2An9a8mtC0YSwsvM3A.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Baseline image is set in the Smart UI testing platform on LambdaTest cloud grid after the test execution is complete.&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%2F800%2F0%2AuwXpJ3yVEfP8-tet.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%2F800%2F0%2AuwXpJ3yVEfP8-tet.png" alt="image" width="800" height="400"&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%2F800%2F0%2A8HqSo3yvQuMoF9ax.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%2F800%2F0%2A8HqSo3yvQuMoF9ax.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Baseline image is set, next, to run the comparison, we need to change the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method in the &lt;a href="https://github.com/mfaisalkhatri/selenium-visual-regression-example/blob/main/src/main/java/io/github/mfaisalkhatri/drivers/DriverManager.java" rel="noopener noreferrer"&gt;&lt;em&gt;DriverManager&lt;/em&gt;&lt;/a&gt; class by setting the “&lt;em&gt;smartUI.baseline&lt;/em&gt;” capability to &lt;em&gt;false&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AVDLFBDuEmKS6ss_C.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%2F800%2F0%2AVDLFBDuEmKS6ss_C.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second change we require is to update the website URL so it navigates to the &lt;em&gt;Desktop&lt;/em&gt; product page before it takes the 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A6uHV-Z1hUbj2UwUr.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%2F800%2F0%2A6uHV-Z1hUbj2UwUr.png" alt="image" width="800" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run the test again by right-clicking on the testng.xml file. Once this test is executed successfully, LambdaTests’s Smart UI will perform the visual regression and provide us with the results.&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%2F800%2F0%2AeaiLKECtalcHaH1D.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%2F800%2F0%2AeaiLKECtalcHaH1D.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following screenshot shows us the results of Selenium visual regression 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ADAe8al635b3JKt3w.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%2F800%2F0%2ADAe8al635b3JKt3w.png" alt="image" width="800" height="400"&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%2F800%2F0%2AHuEDAe9I880eabmc.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%2F800%2F0%2AHuEDAe9I880eabmc.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above screen, we can see the detailed view of the visual regression where the screenshots of the current image, Baseline image, and their respective difference is shown. We can also see that LambdaTest’s Smart UI provides us with the Mismatch percentage, i.e. 5.22%, by performing the pixel-to-pixel comparison.&lt;/p&gt;

&lt;p&gt;The differences between the screenshots are highlighted in pink in the third image. We can Approve the build by clicking on the &lt;strong&gt;Approve Build&lt;/strong&gt; button or Reject it using the &lt;strong&gt;Reject&lt;/strong&gt; button displayed above the Mismatch %.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learn why Python is the top choice for automation testing. This comprehensive tutorial provides a step-by-step guide to&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/python-automation-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;automation testing using python&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to help you streamline your testing process.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation [Test Scenario 2]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, we will perform the visual regression by changing the Baseline image to the &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=57" rel="noopener noreferrer"&gt;&lt;em&gt;Tablets&lt;/em&gt; product page&lt;/a&gt; and comparing it with the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;Home page&lt;/a&gt; of LambdaTest’s eCommerce playground Website. In this scenario, we will manually set the Baseline image using LambdaTest’s Smart UI.&lt;/p&gt;

&lt;p&gt;The following is the screenshot of the &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=57" rel="noopener noreferrer"&gt;&lt;em&gt;Tablets&lt;/em&gt; product page&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%2F800%2F0%2AAEDFGe4BI1TY9zVA.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%2F800%2F0%2AAEDFGe4BI1TY9zVA.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following is the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;Home page&lt;/a&gt; of the LambdaTest eCommerce website against which the &lt;em&gt;Tablets&lt;/em&gt; product page will be compared in visual regression.&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%2F800%2F0%2AoTS4CxrQPbjMHLDd.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%2F800%2F0%2AoTS4CxrQPbjMHLDd.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing the Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The test method &lt;em&gt;testECommerceVisualRegressionScenarioTwo()&lt;/em&gt; is created in the &lt;em&gt;VisualRegressionTests&lt;/em&gt; class&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 testECommerceVisualRegressionScenarioTwo() {
this.driverManager.getDriver().get("https://ecommerce-playground.lambdatest.io/index.php?route=product/category&amp;amp;path=57");
final var productPage = new ProductPage(this.driverManager.getDriver());
productPage.checkVisual();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following line of code will navigate to the &lt;em&gt;Tablets&lt;/em&gt; Product page screen.&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%2F800%2F0%2APyf0seXqP_iw-2Vl.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%2F800%2F0%2APyf0seXqP_iw-2Vl.png" alt="image" width="800" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, the &lt;em&gt;ProductPage&lt;/em&gt; class is instantiated, and its &lt;em&gt;checkvisual()&lt;/em&gt; method is called, which will capture the screenshot of the &lt;em&gt;Tablet&lt;/em&gt; product 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%2F800%2F0%2ApJLw2QMM9qDzU0k_.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%2F800%2F0%2ApJLw2QMM9qDzU0k_.png" alt="image" width="800" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We will be executing this test twice. After the first execution of the test, we will set the Baseline image from the LambdaTest’s Smart UI. The visual regression comparison will be done on the second execution of the test.&lt;/p&gt;

&lt;p&gt;The following testng.xml is created to execute 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="LambdaTest ecommerce playground website test suite "&amp;gt;
&amp;lt;test name="Visual Regression Tests"&amp;gt;
&amp;lt;classes&amp;gt;
&amp;lt;class name="io.github.mfaisalkhatri.tests.VisualRegressionTests"&amp;gt;
&amp;lt;methods&amp;gt;
&amp;lt;include name="testECommerceVisualRegressionScenarioTwo"/&amp;gt;
&amp;lt;/methods&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;Here is the screenshot of the test execution from IntelliJ:&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%2F800%2F0%2Aa2FMX_QxVI-GQT8k.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%2F800%2F0%2Aa2FMX_QxVI-GQT8k.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; is complete, we should be able to see the screenshot uploaded to the Smart UI testing tool.&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%2F800%2F0%2A7kjfAJ4kSpc14zLp.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%2F800%2F0%2A7kjfAJ4kSpc14zLp.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;strong&gt;Make a Baseline&lt;/strong&gt; button to update the current screenshot of the &lt;em&gt;Tablets product page&lt;/em&gt; as a Baseline image for further visual regression 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AABuYAxWSK_D-NR3Q.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%2F800%2F0%2AABuYAxWSK_D-NR3Q.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s return to the &lt;em&gt;testECommerceVisualRegressionScenarioTwo()&lt;/em&gt; and update the URL to navigate the website’s Homepage.&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%2F800%2F0%2AHbQqJtoGIQHaV_mg.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%2F800%2F0%2AHbQqJtoGIQHaV_mg.png" alt="image" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s execute the test using the same &lt;em&gt;testng.xml&lt;/em&gt; file again and check the visual regression testing on the Smart UI.&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%2F800%2F0%2A4nkipjYFsHIslIYd.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%2F800%2F0%2A4nkipjYFsHIslIYd.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the test execution is complete, we should be able to see the screenshot uploaded to the LambdaTest’s Smart UI.&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%2F800%2F0%2AfQF5Bqn9H1rH648m.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%2F800%2F0%2AfQF5Bqn9H1rH648m.png" alt="image" width="800" height="428"&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%2F800%2F0%2AZJnWNmcmN04yQ47S.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%2F800%2F0%2AZJnWNmcmN04yQ47S.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be seen in the image above the visual regression comparison shows a major difference of 67.06% between the Baseline image and the current image screenshots.&lt;/p&gt;

&lt;p&gt;By running the above tests, it can be confirmed that visual regressions can help us catch the User Interface level bugs and correct them before it gets leaked into the production. It can also help in improving the overall User Experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this Selenium JavaScript tutorial, as we deep dive into the basic concepts, explained the best practices and executed&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-with-selenium-javascript/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;javascript for automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;on cloud-based Selenium Grid.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Visual regression is the key to improving the overall User Experience and helps identify the UI-level issues. As we saw in the demonstration, it can highlight the granular differences by performing pixel-to-pixel comparisons. Thus making Software Developer’s and Software Tester’s lives easier.&lt;/p&gt;

&lt;p&gt;In my experience, Selenium visual regression testing should be made a part of the &lt;a href="https://www.lambdatest.com/learning-hub/unit-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Unit Test&lt;/a&gt; stage in the automated pipeline to get faster feedback on the User Interface, as it is the first thing that is seen by the end users. Faster feedback on the UI will help fix the issues early and help build the product’s quality.&lt;/p&gt;

</description>
      <category>visualregressiontesting</category>
      <category>visualtesting</category>
      <category>selenium</category>
      <category>automationtesting</category>
    </item>
    <item>
      <title>How to Use @FindBy Annotation in Selenium Java</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Thu, 16 Nov 2023 06:36:38 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-use-findby-annotation-in-selenium-java-jf4</link>
      <guid>https://dev.to/testmuai/how-to-use-findby-annotation-in-selenium-java-jf4</guid>
      <description>&lt;p&gt;Code maintenance and duplication are two common challenges that software teams often face, resulting in reduced performance and reliability. It also makes the code more complex, tightly coupled, and less flexible for refactoring. With all these problems, adding new lines of code to the software becomes quite tricky as we need to think of a logic to fit those lines within the code.&lt;/p&gt;

&lt;p&gt;In automation &lt;a href="https://www.lambdatest.com/learning-hub/test-suite?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test suites&lt;/a&gt; as well, we all face the same problem. The code becomes too complex and bulky. Even for adding a simple test for new functionality, we need to think twice and find a solution for checking which part of the code needs to be updated so it doesn’t hamper the existing working of the test suite. Sometimes, we have to repeat the same line of code multiple times because it is how the automation framework was designed to work.&lt;/p&gt;

&lt;p&gt;Today, there are multiple &lt;a href="https://www.lambdatest.com/blog/automation-testing-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation test frameworks&lt;/a&gt; that help teams to automate tests and help in delivering quality software. &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; is a popular web automation framework that helps automate the tests for popular modern browsers like Google Chrome, Mozilla Firefox, Microsoft Edge, Safari, etc. To learn more about Selenium WebDriver, check out this guide on &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;What is Selenium?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Writing automated tests using Selenium WebDriver is easy and simple. However, software testing teams face a bigger challenge: keeping the test implementation separate from the web page elements used in the tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model&lt;/a&gt;, also called POM, is a popular design pattern in Selenium WebDriver that creates a page object repository to store WebElements separately in different classes to keep the tests clean and more readable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get your CSS validated by our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/css-validator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;CSS Validator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;and eliminate syntax errors and other issues that could affect your website’s performance. Ensure your CSS code is error-free today.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Design patterns help us overcome industry-standard approaches to solving a recurring problem and help us save time once we sensibly use the design pattern. Design patterns speed up development and are known to fix the problems before they are known in the implementation process. It also facilitates code maintenance, helps us avoid code duplication, and facilitates code readability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/page-factory-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Factory Model&lt;/a&gt; is another popular design pattern in Selenium. It is considered an Optimized Page Object Model that uses the &lt;em&gt;PageFactory&lt;/em&gt; class in Selenium.&lt;/p&gt;

&lt;p&gt;In this blog on using &lt;em&gt;@FindBy&lt;/em&gt; annotation in Selenium, which is part of the Page Factory Model in Selenium WebDriver, we will also learn how to use &lt;em&gt;@FindBys, @FindAll,&lt;/em&gt; and &lt;em&gt;@CacheLookup&lt;/em&gt; annotations in &lt;a href="https://www.lambdatest.com/learning-hub/selenium-java?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium Java&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Page Factory in Selenium WebDriver?
&lt;/h3&gt;

&lt;p&gt;Page Factory is a way of implementing the Page Object Model that uses the &lt;em&gt;PageFactory&lt;/em&gt; class. By using the &lt;em&gt;PageFactory&lt;/em&gt; class in Selenium, testers can interact with web elements, making it robust with enhanced efficiency and simplicity in using Page Objects.&lt;/p&gt;

&lt;p&gt;The following image shows the difference between the Page Object and Page Factory Model:&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%2F800%2F0%2A8eCrNSmTPRsumoM8.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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A8eCrNSmTPRsumoM8.jpg" alt="image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use the Page Factory Model, we need annotations like &lt;em&gt;@FindBy, @FindBys,&lt;/em&gt; and &lt;em&gt;@FindAll&lt;/em&gt; for locating WebElement in the Page Object class. Next, we need to initialize the Page Object class using the &lt;em&gt;initElements()&lt;/em&gt; method from the &lt;em&gt;PageFactory&lt;/em&gt; class.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Protect your XML data with our online free&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/xml-escape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;XML Escape&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool. Quickly escape your code and be assured from vulnerabilities with just a few clicks.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s learn how to use the &lt;em&gt;@FindBy, @FindBys,&lt;/em&gt; and &lt;em&gt;@FindAll&lt;/em&gt; annotations to use the Page Factory Model efficiently.&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%2F800%2F0%2A-yd1r7G7x9L5vkJ0.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%2F800%2F0%2A-yd1r7G7x9L5vkJ0.png" alt="image" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using @FindBy annotation in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;@FindBy&lt;/em&gt; annotation marks a field on the Page Object for locating the &lt;em&gt;WebElement&lt;/em&gt; or a list of &lt;em&gt;WebElements&lt;/em&gt;. It is used in coordination with the &lt;em&gt;PageFactory&lt;/em&gt; class that allows users to easily and quickly create Page Objects.&lt;/p&gt;

&lt;p&gt;There are two different implementation ways for using &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Using “How” and “Using” Strings&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Passing Locator Strategy&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using “How” and “Using” Strings
&lt;/h3&gt;

&lt;p&gt;The first way to implement &lt;em&gt;@FindBy&lt;/em&gt; annotation is by using the “how” and “using” strings as parameters to the annotation by declaring a WebElement variable. The values in the parameter can be supplied as follows –&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;“how” — With the “how” enum in this parameter, you have the flexibility to utilize any of the following &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;locator strategies&lt;/a&gt;:&lt;/p&gt;&lt;/li&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;LinkText&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PartialLinkTex&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TagName&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;XPath&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ID or Name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;“using” — In this parameter, the actual selector needs to be supplied as per the locator strategy selected in the “how” parameter.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The syntax for using &lt;em&gt;@FindBy&lt;/em&gt; annotation [Passing How enum]:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A9ubk_72pwEi3gNko.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%2F800%2F0%2A9ubk_72pwEi3gNko.png" alt="image" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Demo: @FindBy using How enum
&lt;/h4&gt;

&lt;p&gt;Let’s take an example of the &lt;a href="https://www.lambdatest.com/selenium-playground/simple-form-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Simple Form Demo screen&lt;/a&gt; on LambdaTest’s &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Playground&lt;/a&gt; website and locate the “&lt;em&gt;Enter Message&lt;/em&gt;” field.&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%2F800%2F0%2A4swMLsIYhA80DDsf.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%2F800%2F0%2A4swMLsIYhA80DDsf.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this screen for the &lt;em&gt;Enter Message&lt;/em&gt; field, we can use the ID locator — “&lt;em&gt;user-message&lt;/em&gt;” as a selector to locate the field. So, to use it in the code with &lt;em&gt;@FindBy&lt;/em&gt; annotation, we can write it as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(how = How.ID, using="user-message")
private WebElement enterMessageField;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Catch errors before they impact your&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/js-validator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JavaScript validator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;code. Our validator and linter enforces coding standards and helps you catch errors. Validate your code today.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once we have defined the WebElement, we can directly use it in the methods to act on the element. The following lines of code show how to interact with the WebElement defined using &lt;em&gt;@FindBy&lt;/em&gt; annotation:&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 enterMessage() {
this.enterMessageField.sendKeys("This is a test message");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, to make this work, we need to initialize the &lt;em&gt;initElements()&lt;/em&gt; method of the PageFactory class. &lt;em&gt;intiElements()&lt;/em&gt; is a static method in the Page Factory class of Selenium that is used to initialize all web elements located by &lt;em&gt;@FindBy&lt;/em&gt; annotation. It can be done in every Page Object class where we want to use the &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public SimpleFormPage(final WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will be initializing the &lt;em&gt;initElements()&lt;/em&gt; method in the constructor of the &lt;em&gt;SimpleFormPage&lt;/em&gt; class that holds all the page objects for the Simple Form page. Similarly, the &lt;em&gt;initElements()&lt;/em&gt; method will have to be initialized in other Page Object classes as well.&lt;/p&gt;

&lt;p&gt;Let’s now learn the other way of implementing &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Passing Locator Strategy
&lt;/h3&gt;

&lt;p&gt;The second way to implement &lt;em&gt;@FindBy&lt;/em&gt; annotation is to directly pass on the locator strategy and its respective selector as a parameter to the annotation by declaring a WebElement variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The syntax for using &lt;em&gt;@FindBy&lt;/em&gt; annotation [passing locator strategy]:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ABuO65lAjVFK9YfKU.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%2F800%2F0%2ABuO65lAjVFK9YfKU.png" alt="image" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any locator strategy values can be passed in the parameter:&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;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;li&gt;&lt;p&gt;CSS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;XPath&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above-mentioned locator strategy values are case-sensitive and must be used in small letters only.&lt;/p&gt;

&lt;h4&gt;
  
  
  Demo: @FindBy by directly passing the locator strategy
&lt;/h4&gt;

&lt;p&gt;Let’s take an example of the &lt;a href="https://www.lambdatest.com/selenium-playground/simple-form-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Simple Form Demo screen&lt;/a&gt; on LambdaTest’s &lt;a href="https://www.lambdatest.com/selenium-playground/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Playground&lt;/a&gt; website and locate the “&lt;em&gt;Get Checked Value&lt;/em&gt;” 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AvVRZJyRvYLdBTY1r.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%2F800%2F0%2AvVRZJyRvYLdBTY1r.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As per the DOM of the page, we can use the &lt;em&gt;id&lt;/em&gt; — “&lt;em&gt;showInput&lt;/em&gt;” as a selector for locating the Get &lt;em&gt;Checked Value&lt;/em&gt; button. Let’s do this by using the &lt;em&gt;@FindBy&lt;/em&gt; annotation and writing the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(id = "showInput")
private WebElement getCheckedValueBtn;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Similarly, we can use other locator strategies like name, CSS, XPath, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Keep your JavaScript code safe from syntax errors with our free online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/js-escape?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JavaScript Escape&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool by quickly and easily converting special characters in your JavaScript.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once we have defined the WebElement variable for locating the WebElement using &lt;em&gt;@FindBy&lt;/em&gt;, we can directly use it to perform interaction with the button.&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 clickButton() {
this.getCheckedValueBtn.click();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don’t forget to initialize the &lt;em&gt;intiElements()&lt;/em&gt; method from the &lt;em&gt;PageFactory&lt;/em&gt; class to make the annotation work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using &lt;em&gt;@FindBy&lt;/em&gt; annotation for finding multiple WebElements:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;@FindBy&lt;/em&gt; annotation can also be used to return a list of WebElements if we want a list of elements to be returned using a single selector. We must define the variable that returns List&amp;lt;&lt;em&gt;WebElement&lt;/em&gt;&amp;amp;gt; using &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;/p&gt;

&lt;p&gt;We can use either of the implementations as we discussed above for returning a list of WebElements using &lt;em&gt;@FindBy&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The syntax for returning a list of WebElements using Implementation 1:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AulFu-vbbOK5HmRcy.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%2F800%2F0%2AulFu-vbbOK5HmRcy.png" alt="image" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The syntax for returning a list of WebElements using locator strategy in &lt;em&gt;@FindBy&lt;/em&gt; annotation:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A8DDF_wdzauwjSbxj.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%2F800%2F0%2A8DDF_wdzauwjSbxj.png" alt="image" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For better understanding, let’s check out a practical implementation example for returning a list of WebElements.&lt;/p&gt;

&lt;h4&gt;
  
  
  Demo: @FindBy by directly passing locator strategy for finding multiple WebElements
&lt;/h4&gt;

&lt;p&gt;Let’s take an example of the LambdaTest Selenium Playground website and check the total number of menu options on the main 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%2F800%2F0%2ATryQ6iBapzLpHQp3.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%2F800%2F0%2ATryQ6iBapzLpHQp3.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a total of 37 menus displayed on this page. Let’s locate all these menus and return their list using a &lt;em&gt;@FindBy&lt;/em&gt; annotation with the &lt;em&gt;CSS&lt;/em&gt; &lt;a href="https://www.lambdatest.com/learning-hub/css-selectors?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;em&gt;Selector&lt;/em&gt; locator strategy&lt;/a&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A97DzwRwJjgSueqcJ.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%2F800%2F0%2A97DzwRwJjgSueqcJ.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CSS Selector “&lt;em&gt;.container__selenium ul li a&lt;/em&gt;” can be used to return a list of WebElements for the menus. Let’s use this selector with &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(css = ".container__selenium ul li a")
private List&amp;lt;WebElement&amp;gt; menus;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List of menus can also be returned using the How enum in &lt;em&gt;@FindBy&lt;/em&gt; annotation as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(how = How.CSS, using =".container__selenium ul li a")
private List&amp;lt;WebElement&amp;gt; menus;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following method will return the size of the list that can be used in the test to verify that the list has 37 items in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public int menuListSize () {
return this.menus.size();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following is the Test to check the total number of menus in the &lt;em&gt;menus&lt;/em&gt; list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SeleniumPlaygroundTests extends BaseTest {

@Test
public void testMenus() {
this.driverManager.getDriver().get("https://www.lambdatest.com/selenium-playground/");
final var mainPage = new MainPage(this.driverManager.getDriver());
assertEquals(mainPage.menuListSize(), 37);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following screenshot of the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; from IntelliJ shows that the tests executed successfully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Convert your JSON files to CSV format in seconds with our easy-to-use&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/json-to-csv?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JSON to CSV&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Converter. It’s fast, reliable, and user-friendly, making data conversion simple.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A07S9zKWnUzS7fRSB.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%2F800%2F0%2A07S9zKWnUzS7fRSB.png" alt="image" width="800" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This confirms that the list of menus has 37 items in it, and the &lt;em&gt;@FindBy&lt;/em&gt; annotation we used to return a list of &lt;em&gt;menu&lt;/em&gt; WebElements works perfectly fine.&lt;/p&gt;

&lt;p&gt;This confirms that the list of menus has 37 items in it, and the &lt;em&gt;@FindBy&lt;/em&gt; annotation we used to return a list of menu WebElements works perfectly fine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using @CacheLookup annotation in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;@CacheLookup&lt;/em&gt; annotation helps to cache the WebElement. When this annotation is applied over a WebElement, Selenium WebDriver keeps the cache of the WebElement instead of searching for it every time from the WebPage when the test is run. This helps in saving &lt;a href="https://www.lambdatest.com/blog/test-execution-time/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test execution time&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use @CacheLookup?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is beneficial to use &lt;em&gt;@CacheLookup&lt;/em&gt; annotation on the WebElements, which does not change when on the web page once it is loaded. The test speed and performance can be improved by using this annotation on the static elements on the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When not to use @CacheLookup?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is not recommended to use the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation for the WebElements that are dynamic and keep changing every time the page loads. Dynamic elements refer to the WebElement like Timer text that keeps changing every second. Another example would be a capital market website that shows the price of the stocks that keeps on changing every second or minute as per the stock trading. For such WebElements, if &lt;em&gt;@CacheLookup&lt;/em&gt; annotation is used, we may get a &lt;a href="https://www.lambdatest.com/blog/handling-stale-element-exceptions-in-selenium-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;Stale Element Exception&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The syntax for using @CacheLookup annotation:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AfdgniFjqQuCKg8Tp.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%2F800%2F0%2AfdgniFjqQuCKg8Tp.png" alt="image" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;From&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/sql-to-json?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;SQL to JSON&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;in a snap! Convert SQL queries to JSON effortlessly with our SQL to JSON converter, enhancing compatibility and data interchange. Try it now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo: @CacheLookup annotation
&lt;/h3&gt;

&lt;p&gt;The following test scenario will be used to check out the working of the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation. We will run the test using the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation and run the same test by removing the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation. Next, we will check the performance by comparing the test execution time.&lt;/p&gt;

&lt;p&gt;The following test scenario will be used to demo the working of &lt;em&gt;@CacheLookup&lt;/em&gt; annotation, where the performance will be checked by running the tests after using &lt;em&gt;@CacheLookup&lt;/em&gt; annotation over WebElements and removing them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the Table Search Filter window on the LambdaTest’s Selenium Playground website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get the page header text and cache it using &lt;em&gt;@CacheLookup&lt;/em&gt; annotation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Perform assertion on the page’s header by getting its text.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Filter button and enter filter values for first name, username, and last name fields.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On retrieving the records, print the values of the first record on the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Perform the Test Execution and record the time after using &lt;em&gt;@CacheLookup&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remove the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation, rerun the tests, and check the time for test 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ARg8Q30ee0mG-ob50.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%2F800%2F0%2ARg8Q30ee0mG-ob50.png" alt="image" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be using the &lt;em&gt;@FindBy&lt;/em&gt; annotation, as we discussed in the earlier section, to locate the button and the fields.&lt;/p&gt;

&lt;p&gt;The following class is created for housing all the WebElements on the Table Search page.&lt;/p&gt;

&lt;p&gt;Filename: &lt;a href="https://github.com/mfaisalkhatri/selenium-pagefactory-demo/blob/main/src/test/java/io/github/mfaisalkhatri/pages/seleniumplayground/TableSearchPage.java" rel="noopener noreferrer"&gt;TableSearchPage&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%2F800%2F0%2ADk50OTIvc5euE-oL.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%2F800%2F0%2ADk50OTIvc5euE-oL.png" alt="image" width="800" height="951"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be caching every WebElement that we need to interact on this page. The following table shows the variable names used for the respective fields using the &lt;em&gt;@FindBy&lt;/em&gt; annotation and &lt;em&gt;@CacheLookup&lt;/em&gt; annotation to cache the WebElement.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;FIELD NAME ON THE WEB PAGE&lt;/td&gt;
        &lt;td&gt;VARIABLE NAME IN THE TABLESEARCH CLASS FOR THE WEBELEMENT &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Page Header&lt;/td&gt;
        &lt;td&gt;pageHeader &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;First Name field&lt;/td&gt;
        &lt;td&gt;firstNameField &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Last Name field&lt;/td&gt;
        &lt;td&gt;lastNameField &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;User Name field&lt;/td&gt;
        &lt;td&gt;userNameField &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Table Row retrieved after applying filter&lt;/td&gt;
        &lt;td&gt;tableRecord&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Don’t let encoding IDNs slow you down. Save time and hassle with our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/idn-encode?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;IDN Encode&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;free online tool to quickly and easily converts internationalized domain names. Try it now.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AhGSO7uO-g2OVedAo.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%2F800%2F0%2AhGSO7uO-g2OVedAo.png" alt="image" width="778" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;pageHeaderText()&lt;/em&gt; method will return the text value of the page header that will be used in the test for assertion.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;searchForRecord()&lt;/em&gt; method will click on the &lt;em&gt;Filter&lt;/em&gt; button and allow entering values in the &lt;em&gt;Username, First Name,&lt;/em&gt; and &lt;em&gt;Last Name&lt;/em&gt; fields.&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%2F800%2F0%2AqRx54KfoLfen8BeB.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%2F800%2F0%2AqRx54KfoLfen8BeB.png" alt="image" width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we need to get the text of the record that is fetched after applying the filter. The &lt;em&gt;tableRecordValues()&lt;/em&gt; method will fetch the text of the record that will be retrieved after applying the filter values.&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%2F800%2F0%2AaSGKVXOoAkhd-jpo.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%2F800%2F0%2AaSGKVXOoAkhd-jpo.png" alt="image" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s now move ahead and write the test where we will navigate to the &lt;em&gt;Table Search&lt;/em&gt; page, perform the assertion for the page header text, retrieve the table record after applying a filter, and print the record fetched.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;testTableSearch()&lt;/em&gt; method is created for verifying the test scenario.&lt;/p&gt;

&lt;p&gt;Filename: &lt;a href="https://github.com/mfaisalkhatri/selenium-pagefactory-demo/blob/main/src/test/java/io/github/mfaisalkhatri/tests/SeleniumPlaygroundTests.java" rel="noopener noreferrer"&gt;SeleniumPlaygroundTests&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%2F800%2F0%2A-GZbIgrhMoalwpAY.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%2F800%2F0%2A-GZbIgrhMoalwpAY.png" alt="image" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;I have declared two variables, startTime and endTime, to demo the test execution time in milliseconds.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need to make your JSON code more readable? Our online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/json-prettify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JSON Prettifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool makes your JSON data more human-readable. Copy, paste, and prettify in seconds.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;We will be running the test twice and record the time taken to run the test. The first run will be using the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation, and the second will be without using the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation. This will help us compare the test execution time with and without cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution with @CacheLookup annotation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is the screenshot of the test execution using the testng.xml file with &lt;em&gt;@CacheLookup&lt;/em&gt; annotation.&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%2F800%2F0%2Af1tWJ8WfcSEWrl5x.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%2F800%2F0%2Af1tWJ8WfcSEWrl5x.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that it took 481 milliseconds to run the tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution without @CacheLookup annotation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we execute the tests, let’s comment out all the &lt;em&gt;@CacheLookup&lt;/em&gt; annotations in the &lt;em&gt;TableSearchPage&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AgD_b-9Q_ls9wYLWo.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%2F800%2F0%2AgD_b-9Q_ls9wYLWo.png" alt="image" width="800" height="951"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s execute the test again and check the time taken to execute 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AnJFML13Rjn2DjgMI.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%2F800%2F0%2AnJFML13Rjn2DjgMI.png" alt="image" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be seen that it took 534 milliseconds to run the test. So, if we compare the time taken to run the test with and without using &lt;em&gt;@CacheLookup&lt;/em&gt; annotation, it appears to be a difference of 53 milliseconds. As the test scenario was pretty straightforward, hence it is a steep difference here. However, if we take a complex scenario, it can be a major difference in seconds or minutes as well.&lt;/p&gt;

&lt;p&gt;From this, we can conclude that using &lt;em&gt;@CacheLookup&lt;/em&gt; annotation can save the test execution time, eventually helping us in quicker builds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Minify your JS code without changing its functionality with our easy-to-use&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/js-minify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JavaScript Minifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that reduces the size of your scripts and improve website speed.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using @FindBys annotation in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;@FindBys&lt;/em&gt; annotation is used to locate a WebElement or list of WebElements with more than one selector. The condition in using &lt;em&gt;@FindBys&lt;/em&gt; is that all of the selectors given in the &lt;em&gt;@FindBys&lt;/em&gt; should match the respective WebElement(s) criteria.&lt;/p&gt;

&lt;p&gt;It is an “AND” condition between all the selectors given in the annotation. This is helpful in cases where we don’t have a unique locator for the WebElement that we need to interact with on the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The syntax for using &lt;em&gt;@FindBys&lt;/em&gt; annotation:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Ao8_eM-Hy9qu7XCBU.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%2F800%2F0%2Ao8_eM-Hy9qu7XCBU.png" alt="image" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To implement &lt;em&gt;@FindBys&lt;/em&gt;, we must pass on the multiple &lt;em&gt;@FindBy&lt;/em&gt; statements as parameters and declare the WebElement or List&amp;lt; WebElement &amp;gt; variable.&lt;/p&gt;

&lt;p&gt;It should be noted that &lt;em&gt;@FindBy&lt;/em&gt; annotation can be used either by providing the How enum or by supplying the locator strategy directly. In the screenshot above, both ways have been shown to use the &lt;em&gt;@FindBy&lt;/em&gt; while using the &lt;em&gt;@FindBys&lt;/em&gt; annotation.&lt;/p&gt;

&lt;p&gt;However, one more thing to note while using &lt;em&gt;@FindBys&lt;/em&gt; annotations is that we need to provide the locators considering the parent-child relationship, using the attributes within the HTML tag won’t work with &lt;em&gt;@FindBys&lt;/em&gt; annotation. The following example implementation will help in understanding in detail.&lt;/p&gt;

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

&lt;p&gt;Let’s take an example of the &lt;a href="https://www.lambdatest.com/selenium-playground/radiobutton-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Radio button demo&lt;/a&gt; page on LambdaTest’s Selenium Playground website.&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%2F800%2F0%2AVg_WdVPmq015ovrQ.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%2F800%2F0%2AVg_WdVPmq015ovrQ.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On this page, we will be locating the “&lt;em&gt;Male&lt;/em&gt;” radio button by using the &lt;em&gt;@FindBys&lt;/em&gt; annotation.&lt;/p&gt;

&lt;p&gt;As we can see in the DOM, the class name “&lt;em&gt;container&lt;/em&gt;” is the parent of the input tag with &lt;em&gt;type, value&lt;/em&gt;, and &lt;em&gt;name&lt;/em&gt; attributes for the &lt;em&gt;Male&lt;/em&gt; radio button field. Similarly, if we check out the “&lt;em&gt;Female&lt;/em&gt;” radio button, it also has the same hierarchy.&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%2F800%2F0%2Adyip6X1jcw77JsSk.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%2F800%2F0%2Adyip6X1jcw77JsSk.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even the &lt;em&gt;name&lt;/em&gt; attribute is the same for both the radio buttons. The only difference in selector between &lt;em&gt;Male&lt;/em&gt; and &lt;em&gt;Female&lt;/em&gt; radio buttons is the value attribute, i.e., &lt;em&gt;value=”Male”&lt;/em&gt; for Male radio button and &lt;em&gt;value = “Female”&lt;/em&gt; for &lt;em&gt;Female&lt;/em&gt; radio button.&lt;/p&gt;

&lt;p&gt;As the locator is not unique here, we can follow the parent-child relation approach to locate the element by locating the parent first and then approaching to find the child element using the respective locators.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Transform your messy CSS code into beautiful and organized code with our user-friendly and efficient online free&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/css-prettify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;CSS Prettifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool with just a few clicks.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Atv_0mBSIkW1A4BrB.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%2F800%2F0%2Atv_0mBSIkW1A4BrB.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following lines of code will help us locate the &lt;em&gt;Male&lt;/em&gt; radio button using the &lt;em&gt;@FindBys&lt;/em&gt; annotation 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;@FindBys({
@FindBy(how = How.CLASS_NAME, using = "container"),
@FindBy(css = "input[value=\"Male\"]")
})
private WebElement maleRadioBtn;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the &lt;em&gt;@FindBys&lt;/em&gt; annotation, first the parent WebElement with class name i.e. “&lt;em&gt;container&lt;/em&gt;” is located and then the child element using the input tag with &lt;em&gt;value&lt;/em&gt; attribute “&lt;em&gt;Male&lt;/em&gt;” is used to finally locate the WebElement for &lt;em&gt;Male&lt;/em&gt; radio button.&lt;/p&gt;

&lt;p&gt;Similarly, &lt;em&gt;@FindBys&lt;/em&gt; can locate multiple WebElements on the web page. The only change required is instead of WebElement we need to pass List&amp;lt;&lt;em&gt;WebElement&lt;/em&gt;&amp;amp;gt; as show in the image 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AnX46fUhcddlKewva.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%2F800%2F0%2AnX46fUhcddlKewva.png" alt="image" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo: @FindBys annotation
&lt;/h3&gt;

&lt;p&gt;Let’s take an example of the &lt;a href="https://www.lambdatest.com/selenium-playground/table-pagination-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Table Pagination demo&lt;/a&gt; page on LambdaTest’s Selenium Playground website. On this page, let’s locate the total number of columns in the table using the &lt;em&gt;@FindBys&lt;/em&gt; annotation.&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%2F800%2F0%2ASkfPnHd7FOp4Q3Ku.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%2F800%2F0%2ASkfPnHd7FOp4Q3Ku.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see in the DOM, the parent WebElement for the table is its id — “&lt;em&gt;table-id&lt;/em&gt;”. We can use it for locating the complete table. Now, to find the number of columns, it can be easily done by finding the column headers and returning their size.&lt;/p&gt;

&lt;p&gt;The column headers of the table can be located using the CSS Selector — “&lt;em&gt;thead &amp;gt; tr &amp;gt; th&lt;/em&gt;” Using &lt;em&gt;@FindBys&lt;/em&gt; annotation, we can return list of WebElements for the column headers as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(how = How.ID, using = "table-id"),
@FindBy(css = "thead &amp;gt; tr &amp;gt; th")
})
private List&amp;lt;WebElement&amp;gt; tableColumns;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will return a list of WebElements for table columns. We can use the &lt;em&gt;size()&lt;/em&gt; method to get the number of columns and use it in the test to perform assertions.&lt;/p&gt;

&lt;p&gt;Having learned about &lt;em&gt;@FindBys&lt;/em&gt; annotation in detail, let’s check which exception is thrown by &lt;em&gt;@FindBys&lt;/em&gt; annotation if the WebElement is not found.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Make your XML code easy to read and understand with our free online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/xml-prettify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;XML Prettify&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool. Format your code for better readability and save time.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using @FindAll annotation in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;@FindAll&lt;/em&gt; annotation is used to locate a WebElement or list of WebElements with more than one selector. While using &lt;em&gt;@FindAll&lt;/em&gt;, it should be noted that either of the Selectors used should be matching to locate the respective WebElement(s).&lt;/p&gt;

&lt;p&gt;It is an “OR” condition between all the selectors given in the annotation. &lt;em&gt;@FindAll&lt;/em&gt; uses multiple &lt;em&gt;@FindBy&lt;/em&gt; annotation statements in the parameter to locate the WebElements.&lt;/p&gt;

&lt;p&gt;Using &lt;em&gt;@FindAll&lt;/em&gt;, we can provide two or more different selectors for a WebElement, so in case the first locator doesn’t work, it will check the second. So, eventually, the idea is to make the test less flaky by providing more than one locator for a field that doesn’t have a unique locator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The syntax for using &lt;em&gt;@FindAll&lt;/em&gt; annotation:&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AVSmtNKDx8ecrJe0C.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%2F800%2F0%2AVSmtNKDx8ecrJe0C.png" alt="image" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;@FindAll&lt;/em&gt; can be implemented by passing on multiple &lt;em&gt;@FindBy&lt;/em&gt; statements in the annotation parameter and declaring the WebElement or the list of WebElements variables. Note that the &lt;em&gt;@FindBy&lt;/em&gt; statement can be supplied using either of the two implementations, as we discussed in the earlier section of this blog. If you take a look at the syntax image, you will find that both of the implementation ways are shown with two &lt;em&gt;@FindBy&lt;/em&gt; statements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demo: @FindAll annotation
&lt;/h3&gt;

&lt;p&gt;Let’s take an example of the &lt;a href="https://www.lambdatest.com/selenium-playground/ajax-form-submit-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Ajax Form Submit Demo&lt;/a&gt; page on LambdaTest’s Selenium Playground website.&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%2F800%2F0%2AziXvkA-woHFQHD0a.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%2F800%2F0%2AziXvkA-woHFQHD0a.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On this page, we will locate the Name field using two different locator strategies with &lt;em&gt;@FindAll&lt;/em&gt; annotation.&lt;/p&gt;

&lt;p&gt;In the DOM, we can see that two attributes can be used to locate the &lt;em&gt;Name&lt;/em&gt; field, the first is using &lt;em&gt;id&lt;/em&gt; — “&lt;em&gt;title&lt;/em&gt;” and the second is using &lt;em&gt;name&lt;/em&gt; — “&lt;em&gt;title&lt;/em&gt;”.&lt;/p&gt;

&lt;p&gt;The following lines of code will help us locate the Name field using the &lt;em&gt;@FindAll&lt;/em&gt; annotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@FindAll({
@FindBy(id = "title"),
@FindBy(name = "title")
})
private WebElement nameField;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the &lt;em&gt;@FindAll&lt;/em&gt; annotation id as well as name locator strategies are passed as a parameter with the &lt;em&gt;@FindBy&lt;/em&gt; annotation. When the code is executed, it will first try to locate the &lt;em&gt;nameField&lt;/em&gt; WebElement using the ID. If it is not found, it will try locating it using the Name strategy. The point to note here is that at least one criteria provided to locate the element should match.&lt;/p&gt;

&lt;p&gt;Similarly, we can locate a list of WebElements using &lt;em&gt;@FindAll&lt;/em&gt; annotation. The only change required will be the declaration. Instead of the WebElement, we must define it as &lt;em&gt;List&amp;lt; WebElement &amp;gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here is the example code for returning a list of WebElements using &lt;em&gt;@FindAll&lt;/em&gt; annotation from the &lt;a href="https://www.lambdatest.com/selenium-playground/status-code?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Status Codes page&lt;/a&gt; of LambdaTest’s Selenium Playground Website.&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%2F800%2F0%2A00PSNwsgF3nvW7QO.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%2F800%2F0%2A00PSNwsgF3nvW7QO.png" alt="image" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following code will help in returning the list of WebElements using &lt;em&gt;@FindAll&lt;/em&gt; annotation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindAll({
@FindBy(how = How.CSS, using = "#__next &amp;gt; section.mt-50 &amp;gt; div &amp;gt; div &amp;gt; div &amp;gt; p"),
@FindBy(css = ".container .w-full &amp;gt; p")

})
private List&amp;lt;WebElement&amp;gt; statusCodeDetails;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can make use of the &lt;em&gt;size()&lt;/em&gt; method from the &lt;em&gt;List&lt;/em&gt; interface to check for the number of elements present in the &lt;em&gt;statusCodeDetails&lt;/em&gt; list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public int getStatusCodes () {
return this.statusCodeDetails.size();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;getStatusCodes()&lt;/em&gt; method will return the total number of WebElements present in the &lt;em&gt;statusCodeDetails&lt;/em&gt; list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Tired of hard-to-read SQL code? Use our fast and reliable&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/sql-beautifier?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;SQL Beautifier&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool to format and beautify your SQL code, making it more structured and easy to read.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Which Exception is thrown if the WebElement is not found?
&lt;/h3&gt;

&lt;p&gt;Navigating the intricacies of web element identification in &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; is vital for a robust and reliable testing framework. One aspect is understanding the exceptions that may arise when using annotations like &lt;em&gt;@FindAll&lt;/em&gt;, &lt;em&gt;@FindBy&lt;/em&gt;, and &lt;em&gt;@FindBys&lt;/em&gt;. In this section, we delve into a specific question: what happens when the WebElement is not found using these annotations?&lt;/p&gt;

&lt;p&gt;Let’s explore the exceptions that come into play when your &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; script encounters this situation and how you can handle them effectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  WebElement not found using @FindAll annotation
&lt;/h3&gt;

&lt;p&gt;If the WebElement is not found using the &lt;em&gt;@FindAll&lt;/em&gt; annotation, &lt;em&gt;NoSuchElementException&lt;/em&gt; is thrown with appropriate logs.&lt;/p&gt;

&lt;p&gt;Here is the screenshot of the &lt;em&gt;NoSuchElementException&lt;/em&gt; thrown while searching for the incorrect selector for locating the &lt;em&gt;Status Codes&lt;/em&gt; text on the &lt;a href="https://www.lambdatest.com/selenium-playground/status-code?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Status Codes Demo&lt;/a&gt; page on LambdaTest’s Selenium Playground website.&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%2F800%2F0%2AOqGe1QO0PoJ79xmN.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%2F800%2F0%2AOqGe1QO0PoJ79xmN.png" alt="image" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the logs, it can be seen that Selenium WebDriver tried finding the elements by using the &lt;em&gt;@FindAll&lt;/em&gt; annotation.&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%2F800%2F0%2AA-XmzxGJ0A32-aGj.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%2F800%2F0%2AA-XmzxGJ0A32-aGj.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  WebElement not found using @FindBys annotation
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;NoSuchElementException&lt;/em&gt; is thrown with appropriate logs if the WebElement is not found using the &lt;em&gt;@FindBys&lt;/em&gt; annotation.&lt;/p&gt;

&lt;p&gt;Following is the screenshot of the &lt;em&gt;NoSuchElementException&lt;/em&gt; thrown while searching for the incorrect selector for locating the &lt;em&gt;Male&lt;/em&gt; radio button on the &lt;a href="https://www.lambdatest.com/selenium-playground/radiobutton-demo?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Radio button demo page&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%2F800%2F0%2AIyIqOtC9_X_KGlYX.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%2F800%2F0%2AIyIqOtC9_X_KGlYX.png" alt="image" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the logs, it can be seen that Selenium tried finding the elements by chaining the locators provided in the &lt;em&gt;@FindBys&lt;/em&gt; annotation.&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%2F800%2F0%2AFMclUd7ibqzjiGAp.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%2F800%2F0%2AFMclUd7ibqzjiGAp.png" alt="image" width="800" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need realistic sample data? Use our free online easy-to-use&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/random-xml-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Random XML&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Generator to create custom XML data for testing and prototyping. No sign-up required.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  WebElement not found using @FindBy annotation
&lt;/h3&gt;

&lt;p&gt;If Selenium WebDriver cannot locate a WebElement using the &lt;em&gt;@FindBy&lt;/em&gt; annotation, it throws &lt;em&gt;NoSuchElementException&lt;/em&gt;. It details the selector for locating the element in the log that can help us investigate the failure.&lt;/p&gt;

&lt;p&gt;Following is the screenshot of the &lt;em&gt;NoSuchElementException&lt;/em&gt; that was thrown while searching for an incorrect selector 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AQKGj1tHcO0AQispn.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%2F800%2F0%2AQKGj1tHcO0AQispn.png" alt="image" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s move towards demonstration by automating a test scenario from LambdaTest’s eCommerce website using the &lt;em&gt;@FindBy&lt;/em&gt;, &lt;em&gt;@FindBys&lt;/em&gt;, and &lt;em&gt;@FindAll&lt;/em&gt; annotations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demonstration: Locating elements and writing web automation tests
&lt;/h3&gt;

&lt;p&gt;Before we get into writing the test automation scripts, let me share the details of the tools used to demo the test scenarios for using &lt;em&gt;@FindBy&lt;/em&gt;, &lt;em&gt;@FindBys&lt;/em&gt;, and &lt;em&gt;@FindAll&lt;/em&gt; annotations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language — Java 17&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Automation tool — Selenium WebDriver — &lt;a href="https://www.lambdatest.com/blog/selenium-manager-in-selenium-4-11-0/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;version — 4.11.0&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Application under Test — &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce Playground&lt;/a&gt; website&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool — &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=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner — &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud Platform to run web automation tests — &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Project Setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s create a Maven project and update the dependencies for Selenium WebDriver and TestNG in the pom.xml. Simultaneously, update the &lt;em&gt;maven-surefire&lt;/em&gt; and &lt;em&gt;maven-compiler&lt;/em&gt; plugins in it.&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;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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;selenium-pagefactory-demo&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
&amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

&amp;lt;name&amp;gt;selenium-pagefactory-demo&amp;lt;/name&amp;gt;
&amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

&amp;lt;properties&amp;gt;
&amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
&amp;lt;selenium.java.version&amp;gt;4.11.0&amp;lt;/selenium.java.version&amp;gt;
&amp;lt;testng.version&amp;gt;7.8.0&amp;lt;/testng.version&amp;gt;
&amp;lt;maven.compiler.version&amp;gt;3.11.0&amp;lt;/maven.compiler.version&amp;gt;
&amp;lt;surefire-version&amp;gt;3.1.2&amp;lt;/surefire-version&amp;gt;
&amp;lt;java.release.version&amp;gt;17&amp;lt;/java.release.version&amp;gt;
&amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
&amp;lt;suite-xml&amp;gt;testng.xml&amp;lt;/suite-xml&amp;gt;
&amp;lt;/properties&amp;gt;

&amp;lt;dependencies&amp;gt;

&amp;lt;!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --&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;${selenium.java.version}&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;${testng.version}&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;build&amp;gt;
&amp;lt;plugins&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
&amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
&amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
&amp;lt;executions&amp;gt;
&amp;lt;execution&amp;gt;
&amp;lt;goals&amp;gt;
&amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
&amp;lt;/goals&amp;gt;
&amp;lt;/execution&amp;gt;
&amp;lt;/executions&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
&amp;lt;properties&amp;gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&amp;lt;/properties&amp;gt;
&amp;lt;suiteXmlFiles&amp;gt;
&amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
&amp;lt;/suiteXmlFiles&amp;gt;
&amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;/plugins&amp;gt;
&amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/index.php?route=account/login" rel="noopener noreferrer"&gt;Login Page&lt;/a&gt; of &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Locate the E-Mail Address field using the &lt;em&gt;@FindBys&lt;/em&gt; annotation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Locate the Password field and Login using the &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter a valid email address and password in the respective fields.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Login button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On successful login, verify that the My Account Page is displayed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Locate the Logout link using &lt;em&gt;@FindAll&lt;/em&gt; annotation and click on it to logout.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The login screen of LambdaTest’s eCommerce Website&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AIT5lqfwc0fuVu7eC.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%2F800%2F0%2AIT5lqfwc0fuVu7eC.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Page displayed after successful Login with the Logout link&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ACjHZ0RnTxM_feW88.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%2F800%2F0%2ACjHZ0RnTxM_feW88.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Before we begin writing the code, let’s first find the selectors for the fields on the Login Page. The first field is the E-Mail Address field. Let’s check out the DOM of the web page to find the selectors for this field.&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%2F800%2F0%2Ad0ANuk9egWD4dJdw.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%2F800%2F0%2Ad0ANuk9egWD4dJdw.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the selectors for the Login Page fields will be declared in the &lt;em&gt;LoginPage&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;We can see that the parent locator for this field is className = “card-body” and &lt;em&gt;name&lt;/em&gt; attribute — “email” as well as &lt;em&gt;ID&lt;/em&gt; attribute “input-email” can be used as the target locator. We will be using the &lt;em&gt;@FindBys&lt;/em&gt; annotation to locate this field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need YAML data for testing? No need to stress about YAML data — Try our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/random-yaml-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Random YAML&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Generator for a quick and effortless way to generate YAML data in seconds.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below is the WebElement variable &lt;em&gt;emailAddressField&lt;/em&gt; declared inside the &lt;em&gt;LoginPage&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBys({
@FindBy(how = How.CLASS_NAME, using = "card-body"),
@FindBy(how = How.NAME, using = "email")
})
private WebElement emailAddressField;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let’s locate the Password field.&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%2F800%2F0%2ALCbAq5QF5VTbuUND.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%2F800%2F0%2ALCbAq5QF5VTbuUND.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the DOM, it can be seen that locator strategies like ID — “input-password” and NAME — “password” can be used to locate the Password field.&lt;/p&gt;

&lt;p&gt;Below is the WebElement variable &lt;em&gt;passwordField&lt;/em&gt; declared inside the &lt;em&gt;LoginPage&lt;/em&gt; class that will help locate the Password field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(how = How.NAME, using = "password" )
private WebElement passwordField;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let’s 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ADCv4NufNz2YHw4wg.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%2F800%2F0%2ADCv4NufNz2YHw4wg.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is pretty simple to locate the Login button, we can make use of CSS Selector — “input[type=”submit”].&lt;/p&gt;

&lt;p&gt;Below is the WebElement variable &lt;em&gt;loginBtn&lt;/em&gt; declared inside the &lt;em&gt;LoginPage&lt;/em&gt; class to locate the Login button using the &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy (css = "input[type=\"submit\"]")
private WebElement loginBtn;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s now create a new method named &lt;em&gt;performLogin()&lt;/em&gt; inside the &lt;em&gt;LoginPage&lt;/em&gt; class, that will perform the interaction with the E-Mail Address, Password fields, and Login button by entering the respective credentials in the fields to login in the website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public MyAccountPage performLogin(final String emailAddress, final String password) {
this.emailAddressField.sendKeys(emailAddress);
this.passwordField.sendKeys(password);
this.loginBtn.click();

return new MyAccountPage(this.driver);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;performLogin()&lt;/em&gt; method consumes two parameters called &lt;em&gt;emailAddress&lt;/em&gt; and &lt;em&gt;Password&lt;/em&gt; that will be supplied from the test to perform login, and it will return a new instance of the &lt;em&gt;MyAccountPage&lt;/em&gt; class. The new instance of the &lt;em&gt;MyAccountPage&lt;/em&gt; class is returned from this method as, after success, the website will take us to the My Account Page.&lt;/p&gt;

&lt;p&gt;We have declared the WebElement variables and a method to perform login. Now, it is time to use the &lt;em&gt;initElements()&lt;/em&gt; method from the &lt;em&gt;PageFactory&lt;/em&gt; class of Selenium so the annotations work seamlessly. We will call the &lt;em&gt;initElement()&lt;/em&gt; method in the &lt;em&gt;Constructor&lt;/em&gt; of the &lt;em&gt;LoginPage&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private final WebDriver driver;
public LoginPage(final WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the final version of the &lt;em&gt;LoginPage&lt;/em&gt; class after all the variables, methods, and constructors are added to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class LoginPage {
private final WebDriver driver;
public LoginPage(final WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}

@FindBys({
@FindBy(how = How.CLASS_NAME, using = "card-body"),
@FindBy(how = How.NAME, using = "email")
})
private WebElement emailAddressField;
@FindBy(how = How.NAME, using = "password" )
private WebElement passwordField;

@FindBy (css = "input[type=\"submit\"]")
private WebElement loginBtn;

public MyAccountPage performLogin(final String emailAddress, final String password) {
this.emailAddressField.sendKeys(emailAddress);
this.passwordField.sendKeys(password);
this.loginBtn.click();

return new MyAccountPage(this.driver);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the login step is complete, the My Account page will be displayed. To verify this step, let’s locate the title of the page that is “My Account”.&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%2F800%2F0%2AphpeJE8VYTvEKuTv.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%2F800%2F0%2AphpeJE8VYTvEKuTv.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can make use of the CSS Selector — “#content &amp;gt; div:nth-child(1) h2” to locate the title — “My Account”.&lt;/p&gt;

&lt;p&gt;The following &lt;em&gt;myAccountTitle&lt;/em&gt; variable declared inside the &lt;em&gt;MyAccountPage&lt;/em&gt; class will locate the title using the &lt;em&gt;@FindBy&lt;/em&gt; annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindBy(css = "#content &amp;gt; div:nth-child(1) h2")
@CacheLookup
private WebElement myAccountTitle;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;@CacheLookup&lt;/em&gt; annotation is used for this variable to store this WebElement in the cache so when we run the test next time, it will take the WebElement from the cache instead of searching for it on the web page. This will help in saving the execution time.&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 getMyAccountPageTitle() {
return this.myAccountTitle.getText();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;getMyAccountPageTitle()&lt;/em&gt; will return the text from the WebElement &lt;em&gt;myAccountTitle&lt;/em&gt; in String format that will help us in performing assertion for the title in the test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Need a quick placeholder image for your project? Use our online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/placeholder-image-generator?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;placeholder image&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;generator tool that helps you generate customizable images for your projects.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next step that we need to take care of is to locate the Logout link that will be displayed after the successful login on the My Account 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%2F800%2F0%2Aaz04qx1cO1u5NwGt.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%2F800%2F0%2Aaz04qx1cO1u5NwGt.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two ways to locate this Logout link, one is using the LinkText locator strategy, and the second is using the CSS Selector locator strategy where we use the Selector — “&lt;em&gt;#column-right &amp;gt; div &amp;gt; a:nth-child(14)&lt;/em&gt;”. Let’s use the &lt;em&gt;@FindAll&lt;/em&gt; annotation and add these locator strategies to locate the link.&lt;/p&gt;

&lt;p&gt;Below is the WebElement variable &lt;em&gt;logoutLink&lt;/em&gt; declared to locate the link using &lt;em&gt;@FindAll&lt;/em&gt; annotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@FindAll({
@FindBy(how = How.LINK_TEXT, using = "Logout"),
@FindBy(how = How.CSS, using = "#column-right &amp;gt; div &amp;gt; a:nth-child(14)")
})
private WebElement logoutLink;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new method name &lt;em&gt;logoutFromECommercePlayground()&lt;/em&gt; is created in the MyAccount Page that will interact with the logout link by performing a click on it.&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 logoutFromEcommercePlayground() {
this.logoutLink.click();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will be calling the &lt;em&gt;initElements()&lt;/em&gt; method from the &lt;em&gt;PageFactory&lt;/em&gt; class in the constructor of the &lt;em&gt;MyAccountPage&lt;/em&gt; class like we did in the &lt;em&gt;LoginPage&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MyAccountPage {

public MyAccountPage(final WebDriver driver) {
PageFactory.initElements(driver, this);
}

@FindBy(css = "#content &amp;gt; div:nth-child(1) h2")
@CacheLookup
private WebElement myAccountTitle;

public String getMyAccountPageTitle() {
return this.myAccountTitle.getText();
}

@FindAll({
@FindBy(how = How.LINK_TEXT, using = "Logout"),
@FindBy(how = How.CSS, using = "#column-right &amp;gt; div &amp;gt; a:nth-child(14)")
})
private WebElement logoutLink;

public void logoutFromEcommercePlayground() {
this.logoutLink.click();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the implementation of the Logout step, we have completed the part of writing the Page objects. Now, let’s write 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;public class LambdaTestEcommercePlaygroundTests extends BaseTest {

@Test
public void testLogin() {
this.driverManager.getDriver().get("https://ecommerce-playground.lambdatest.io/index.php?route=account/login");
final LoginPage loginPage = new LoginPage(this.driverManager.getDriver());
final MyAccountPage myAccountPage = loginPage.performLogin("john+2@gmail.com", "Pass@1234");

assertEquals(myAccountPage.getMyAccountPageTitle(), "My Account");
myAccountPage.logoutFromEcommercePlayground();

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

&lt;/div&gt;



&lt;p&gt;The first statement in the &lt;em&gt;testLogin()&lt;/em&gt; method navigates to the LambdaTest eCommerce website. Next, the &lt;em&gt;LoginPage&lt;/em&gt; class is instantiated, where we pass on the WebDriver instance using the &lt;em&gt;drivermanager&lt;/em&gt; class’ &lt;em&gt;getDriver()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;LambdaTestPlayGroundTests&lt;/em&gt; class is extended by the &lt;em&gt;BaseTest&lt;/em&gt; class that takes care of the &lt;em&gt;WebDriver&lt;/em&gt; initialization and teardown using the &lt;em&gt;DriverManager&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class BaseTest {

protected DriverManager driverManager;

@BeforeMethod(alwaysRun = true)
public void testSetup() {
this.driverManager = new DriverManager();
this.driverManager.createChromeDriverInCloud();
}

@AfterMethod(alwaysRun = true)
public void tearDown() {
this.driverManager.quitDriver();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;DriverManager&lt;/em&gt; class takes care of all the setup and configuration of the WebDriver interface. As we must run the tests in the LambdaTest cloud grid, the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method from the &lt;em&gt;DriverManager&lt;/em&gt; class will help us start a session.&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-powered test orchestration and execution platform for &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt; with Java that offers &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated testing&lt;/a&gt; on many browsers and operating systems. It enables parallel testing, local testing, and integration with popular &lt;a href="https://www.lambdatest.com/blog/best-java-testing-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Java testing frameworks&lt;/a&gt; like TestNG, JUnit, etc.&lt;/p&gt;

&lt;p&gt;It supports &lt;a href="https://www.lambdatest.com/selenium-grid-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online Selenium Grid&lt;/a&gt; for scalable testing and provides features such as automated screenshot capture, video recording, network simulation, and seamless integration with CI/CD pipelines, making it a comprehensive platform for developers to ensure their web applications function reliably across diverse environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Tired of messy, unorganized XML code? Our&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/xml-stringify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;XML Stringify&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool makes formatting a breeze, allowing you to quickly and easily convert your code into a readable string&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also have a detailed look at this tutorial to start automation testing on LambdaTest.&lt;/p&gt;

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

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=video" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; for software testing tutorials around &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/playwright-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright testing&lt;/a&gt;, and more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class DriverManager {

protected WebDriver driver;
private static final String LT_USERNAME = System.getProperty("LT_USERNAME");
private static final String LT_ACCESS_KEY = System.getProperty("LT_ACCESS_KEY");
private static final String GRID_URL = "@hub.lambdatest.com/wd/hub";

public void createChromeDriverInCloud() {
final ChromeOptions browserOptions = new ChromeOptions();
browserOptions.setPlatformName("Windows 10");
browserOptions.setBrowserVersion("114.0");
final HashMap&amp;lt;String, Object&amp;gt; ltOptions = new HashMap&amp;lt;&amp;gt;();
ltOptions.put("username", LT_USERNAME);
ltOptions.put("accessKey", LT_ACCESS_KEY);
ltOptions.put("resolution", "2560x1440");
ltOptions.put("selenium_version", "4.0.0");
ltOptions.put("build", "LambdaTest ECommerce Playground Build");
ltOptions.put("name", "LambdaTest ECommerce Playground Tests");
ltOptions.put("w3c", true);
ltOptions.put("plugin", "java-testNG");
browserOptions.setCapability("LT:Options", ltOptions);
try {
this.driver = new RemoteWebDriver(new URL(format("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)), browserOptions);
} catch (final MalformedURLException e) {
throw new Error("RemoteDriver's URL not set correctly!", e);
}
this.driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
}

public WebDriver getDriver() {
return this.driver;
}

public void quitDriver() {
this.driver.quit();
}
}
&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AdnrgRCmtSLSPYWDF.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%2F800%2F0%2AdnrgRCmtSLSPYWDF.png" alt="image" width="382" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These desired capabilities in the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method can be easily copied using &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AExt8f2J2heSaJIN9.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%2F800%2F0%2AExt8f2J2heSaJIN9.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Coming back to the tests, next, we need to perform the login by calling the &lt;em&gt;performLogin()&lt;/em&gt; method from the &lt;a href="https://github.com/mfaisalkhatri/selenium-pagefactory-demo/blob/main/src/test/java/io/github/mfaisalkhatri/pages/lambdatestecommerce/LoginPage.java" rel="noopener noreferrer"&gt;&lt;em&gt;LoginPage&lt;/em&gt;&lt;/a&gt; class and passing on the email address and password in the respective fields.&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%2F800%2F0%2Ay-VGzBgAPeZbZlEV.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%2F800%2F0%2Ay-VGzBgAPeZbZlEV.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;performLogin()&lt;/em&gt; method already returns a new instance of the &lt;em&gt;MyAccountPage&lt;/em&gt; class; we don’t need to instantiate the &lt;em&gt;MyAccountPage&lt;/em&gt; class in the test method explicitly.&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%2F800%2F0%2ATXdI8SxuDzPxKRsx.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%2F800%2F0%2ATXdI8SxuDzPxKRsx.png" alt="image" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After successful login, the next statement of code will perform the assertion to check that the My Account page title is “My Account”. Finally, it will locate the Logout link and click on it. With this, the test scenario is marked complete.&lt;/p&gt;

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

&lt;p&gt;The following testng.xml file is created that will help us in executing the test using TestNG.&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="LambdaTest ecommerce playground website test suite "&amp;gt;
&amp;lt;test name="Page Factory demo tests using LambdaTest ECommerce Playground"&amp;gt;
&amp;lt;classes&amp;gt;
&amp;lt;class name="io.github.mfaisalkhatri.tests.LambdaTestEcommercePlaygroundTests"&amp;gt;
&amp;lt;methods&amp;gt;
&amp;lt;include name="testLogin"/&amp;gt;
&amp;lt;/methods&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;As we need to execute the tests on LambdaTest Cloud grid we need to provide the following secret values in the &lt;em&gt;Edit Configuration&lt;/em&gt; window in the IDE as follows. These values can be found in the &lt;em&gt;Password &amp;amp; Security&lt;/em&gt; section after logging in to the LambdaTest website.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;-DLT_USERNAME=&amp;lt; LambdaTest Username &amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-DLT_ACCESS_KEY=&amp;lt; LambdaTest Access Key &amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To execute the tests, right click on the testng.xml file and select the option “&lt;em&gt;Run ‘…/testng.xml&lt;/em&gt;’”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Simplify your data export process with our efficient&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/sql-to-csv?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;SQL to CSV&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Converter. Convert SQL queries to CSV format seamlessly and unlock data versatility. Try it now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below is the screenshot of the tests run from IntelliJ.&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%2F800%2F0%2AlaAh1RRpXAyAkY0O.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%2F800%2F0%2AlaAh1RRpXAyAkY0O.png" alt="image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can check the test execution details in the &lt;a href="https://accounts.lambdatest.com/dashboard" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt;, which shows the granular details of the test, like OS, browser name, version, and logs.&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%2F800%2F0%2AYInoog8LZKNejUra.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%2F800%2F0%2AYInoog8LZKNejUra.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Food for Thought 💡
&lt;/h3&gt;

&lt;p&gt;As per my experience, the Page Object Model offers more leverage than the Page Factory Model. In Page Factory, we can only define a WebElement or List &amp;lt; WebElements &amp;gt;; hence, it restricts the usage of the &lt;em&gt;By&lt;/em&gt; class of Selenium WebDriver. This can restrict us from using different Expected Conditions while using Explicit Wait.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get faster loading times and better user experience with our efficient&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/free-online-tools/json-stringify?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=nov_16&amp;amp;utm_term=ap&amp;amp;utm_content=free_online_tools" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;JSON Stringify&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tool. Quickly compress your JSON data with ease and optimize your website now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;@FindBy&lt;/em&gt;, &lt;em&gt;@FindBys&lt;/em&gt;, and &lt;em&gt;@FindAll&lt;/em&gt; annotations can be used to implement Page Factory Model in Selenium WebDriver. These are quite neat and clear annotations as we don’t have to use the findElement/findElements method to search for a webelement. Also, we can use the &lt;em&gt;@CacheLookup&lt;/em&gt; annotation, which allows us to save the WebElement in the cache so that when the tests run next time, the WebElement is fetched from the cache, thus saving time. However, we need to call the &lt;em&gt;intiElements()&lt;/em&gt; method from the &lt;em&gt;PageFactory&lt;/em&gt; class in every page object class; otherwise, these annotations won’t work.&lt;/p&gt;

&lt;p&gt;The Page Factory Model has advantages and disadvantages; we can check out what suits us the best and move forward to use the model in the automation suite.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>selenium</category>
      <category>findbyannotation</category>
    </item>
    <item>
      <title>How to Handle ElementClickInterceptedException in Selenium Java</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Thu, 21 Sep 2023 08:18:19 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-handle-elementclickinterceptedexception-in-selenium-java-5bac</link>
      <guid>https://dev.to/testmuai/how-to-handle-elementclickinterceptedexception-in-selenium-java-5bac</guid>
      <description>&lt;p&gt;Selenium is one of the most popular automation testing frameworks organizations use to automate their websites. With &lt;a href="https://www.lambdatest.com/blog/what-is-deprecated-in-selenium4/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium’s 4.0.0&lt;/a&gt; release, multiple breaking changes have been introduced, like WC standardization, Selenium Manager, Chrome DevTools, etc.&lt;/p&gt;

&lt;p&gt;With all these features, it has made the test automation engineer’s life easy by removing the complexities like adding executable driver’s path for browser drivers, &lt;a href="https://www.lambdatest.com/blog/css-browser-compatibility-issues/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;browser compatibility issues&lt;/a&gt;, etc., and helping them to write the automated tests faster and more comfortably.&lt;/p&gt;

&lt;p&gt;When it comes to test automation, automation engineers (count me in too :)) often struggle through a common problem, i.e., getting exceptions when running the tests. There are different &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=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;exceptions in Selenium&lt;/a&gt; that test (or automation) engineers come across when performing test automation. Some common exceptions are &lt;a href="https://www.lambdatest.com/automation-testing-advisor/selenium/classes/org.openqa.selenium.NoSuchElementException" rel="noopener noreferrer"&gt;NoSuchElementException&lt;/a&gt;, &lt;em&gt;TimeoutException, SessionNotCreatedException, StaleElementReferenceException, ElementClickInterceptedException, etc&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/selenium-java?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium Java tutorial&lt;/a&gt;, we will discuss the nitty-gritty of &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium and ways to mitigate the exception.&lt;/p&gt;

&lt;p&gt;So, let’s get started.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/flutter-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;flutter automation testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, we will discuss how to test flutter apps manually and automation on real device cloud&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an ElementClickInterceptedException?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;ElementClickInterceptedException&lt;/em&gt; occurs when the click command cannot be executed on the WebElement as it is not clickable. This exception typically occurs when another WebElement overlaps the WebElement that somehow receives the click.&lt;/p&gt;

&lt;p&gt;As we use the Java programming language in this blog, the exception name &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; is used here. It might change in the case of other programming languages as below –&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;PROGRAMMING LANGUAGE&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;EXCEPTION NAME&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Java&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;ElementClickInterceptedException&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;C#&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;OpenQA.Selenium.ElementClickInterceptedException&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Ruby&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;ERROR: element click intercepted&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Python&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;selenium.common.exceptions.ElementClickInterceptedException&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;JavaScript&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;WebDriverError: element click intercepted:&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The following exception log is printed in the console when ElementClickInterceptedException is thrown using &lt;a href="https://www.lambdatest.com/blog/selenium-with-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium with Java&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%2F800%2F0%2AkXHt9o2m65Dggkj-.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%2F800%2F0%2AkXHt9o2m65Dggkj-.png" alt="image" width="800" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The logs show that instead of the actual element on which the &lt;a href="https://www.lambdatest.com/blog/perform-mouse-actions-in-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;click command&lt;/a&gt; was called, it was not clickable as some other element covered it; hence, the exception was thrown.&lt;/p&gt;

&lt;p&gt;Different reasons can cause the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;. Let’s learn about them in the next section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Mobile&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;emulators online&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;from LambdaTest allows you to seamlessly test your mobile applications, websites,and web apps on mobile browsers and mobile devices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the causes of ElementClickInterceptedException?
&lt;/h3&gt;

&lt;p&gt;The following are the major causes that can lead to &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; thrown by &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;WebElements overlap each other&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebElement is disabled&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebElement is not visible or not available in the &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DOM&lt;/a&gt; currently at the time when the click command was executed. This can happen due to a slow Internet connection, and the automation scripts are executed while the web page is not loaded.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s discuss these causes in detail one by one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cause 1: WebElements overlapping with each other
&lt;/h3&gt;

&lt;p&gt;Overlapping elements on the webpage can cause problems in running test automation scripts. When interactions are done with such elements, we often receive different exceptions based on the interactions performed. However, if we try to click on the element, an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; will be thrown.&lt;/p&gt;

&lt;p&gt;Here is an example of the web page from the UITestingPlayground website that has the name field overlapped with some other WebElement.&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%2F800%2F0%2AloZwbGcob7hsKXnv.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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AloZwbGcob7hsKXnv.jpg" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, ideally, to interact with the name field, we will have to scroll to get the name field into view and then perform the interaction on it to handle the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cause 2: WebElement is disabled
&lt;/h3&gt;

&lt;p&gt;Another reason for getting the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is that the WebElement might be disabled, and Selenium may not be able to perform clicks as desired through the automation script.&lt;/p&gt;

&lt;p&gt;This may happen in scenarios like filling up the user registration form on the website, where the Submit button remains disabled unless all the mandatory fields are filled up correctly. So, in case the Submit button is clicked while it is still disabled, Selenium WebDriver might throw an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cause 3: WebElement was not visible when the click command was executed
&lt;/h3&gt;

&lt;p&gt;When the tests are executed using test automation scripts, web page load time should also be considered. As the automation scripts continue to execute line by line, once the first line is executed, the program moves to the next line.&lt;/p&gt;

&lt;p&gt;Consider an example of an eCommerce website with multiple JavaScript codes running on the web page.&lt;/p&gt;

&lt;p&gt;We locate a product and click the Add to Cart button next to it as a part of our test scenario. There is a higher chance of getting an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; as the webpage is not completely loaded, and we are trying to click on a WebElement that is currently not visible in DOM.&lt;/p&gt;

&lt;p&gt;Having learned about the causes for &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium, let’s now proceed and check out the multiple ways to handle the exception and run our Selenium test automation scripts hassle-free.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to handle ElementClickInterceptedException in Selenium?
&lt;/h3&gt;

&lt;p&gt;Before we write the test automation scripts, it would be good to share the details of the tools used in this blog to demo the solutions for handling the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language — Java 17&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Automation tool — Selenium WebDriver — version — 4.10.0&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool — &lt;a href="https://www.lambdatest.com/blog/getting-started-with-maven-for-selenium-testing" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner — &lt;a href="https://www.lambdatest.com/learning-hub/testng" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud Platform to run web automation tests — &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Project Setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Maven project has been created, and the respective dependencies for TestNG and Selenium WebDriver have been updated in the pom.xml. The build and plugins section in the pom.xml are updated with the &lt;em&gt;maven-sure-fire&lt;/em&gt; and &lt;em&gt;maven-compiler&lt;/em&gt; plugins to execute the tests using the command line interface. We will use different &lt;a href="https://www.lambdatest.com/learning-hub/test-scenario?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test scenarios&lt;/a&gt; in this project to demo how to handle the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; 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;&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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;selenium-exceptions-demo&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
&amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

&amp;lt;name&amp;gt;selenium-exceptions-demo&amp;lt;/name&amp;gt;
&amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

&amp;lt;properties&amp;gt;
&amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
&amp;lt;selenium.java.version&amp;gt;4.10.0&amp;lt;/selenium.java.version&amp;gt;
&amp;lt;testng.version&amp;gt;7.8.0&amp;lt;/testng.version&amp;gt;
&amp;lt;maven.compiler.version&amp;gt;3.11.0&amp;lt;/maven.compiler.version&amp;gt;
&amp;lt;surefire-version&amp;gt;3.1.2&amp;lt;/surefire-version&amp;gt;
&amp;lt;java.release.version&amp;gt;17&amp;lt;/java.release.version&amp;gt;
&amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
&amp;lt;suite-xml&amp;gt;test-suite/testng.xml&amp;lt;/suite-xml&amp;gt;
&amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;

&amp;lt;/properties&amp;gt;

&amp;lt;dependencies&amp;gt;
&amp;lt;!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --&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;${selenium.java.version}&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;${testng.version}&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;build&amp;gt;
&amp;lt;plugins&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
&amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
&amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
&amp;lt;executions&amp;gt;
&amp;lt;execution&amp;gt;
&amp;lt;goals&amp;gt;
&amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
&amp;lt;/goals&amp;gt;
&amp;lt;/execution&amp;gt;
&amp;lt;/executions&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
&amp;lt;properties&amp;gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&amp;lt;/properties&amp;gt;
&amp;lt;suiteXmlFiles&amp;gt;
&amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
&amp;lt;/suiteXmlFiles&amp;gt;
&amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;/plugins&amp;gt;
&amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AvYN0l7-PARwfyp7Y.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%2F800%2F0%2AvYN0l7-PARwfyp7Y.png" alt="image" width="382" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For better maintainability and re-using the page objects, the &lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model (POM)&lt;/a&gt; has been used in this project. It helps remove code duplication and separate the page objects from the tests, thus helping write cleaner automation tests.&lt;/p&gt;

&lt;p&gt;In this section, we will be going through multiple solutions that can be used to handle the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium. We will use a couple of websites to demo the solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Perform browser&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;test automation&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;on the most powerful cloud infrastructure. Leverage LambdaTest automation testing for faster, reliable and scalable experience on cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution 1: Using Explicit Waits in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;Performing click action on the WebElement that did not get loaded properly on the web page is one of the causes that might lead to &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium. To resolve this, we can use the &lt;a href="https://www.lambdatest.com/blog/selenium-webdriverwait/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Explicit Waits in Selenium WebDriver&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We can use the ExpectedConditions like &lt;em&gt;elementToBeClickable&lt;/em&gt; to be sure that the WebElement we are clicking is clickable. We may also use the &lt;em&gt;invisibilityOfElementLocated&lt;/em&gt; method. This comes in handy in case WebElements like notifications or snack bars overlap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the OWASP Juice Shop website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the Login Page.&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;Perform assertion for successful login by checking that the Logout link is displayed.&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%2F800%2F0%2A2KHvtFxfoMLogjWN.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%2F800%2F0%2A2KHvtFxfoMLogjWN.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Home Page of OWASP Juice Shop website&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AIMC18qxCx3d6fnB6.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%2F800%2F0%2AIMC18qxCx3d6fnB6.png" alt="image" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Login Page of OWASP Juice Shop website&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, when we try to click on the Login button on the login page after entering valid credentials, it throws &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; as the login button is overlapped by the language notification snack bar.&lt;/p&gt;

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

&lt;p&gt;In this scenario, we will first navigate to the Homepage of the OWASP Juice Shop website and close all the pop-up messages so we can smoothly run our automation tests.&lt;/p&gt;

&lt;p&gt;Next, we need to locate and click on the Account link to open it and locate the Login link. We will be navigated to the Login Page by clicking the Login link.&lt;/p&gt;

&lt;p&gt;The following is the code from the &lt;em&gt;HomePage&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HomePage {

private WebElement dismissBtn() {
return getDriver().findElement(By.cssSelector("button[aria-label=\"Close Welcome Banner\"]"));
}

public void closeBanner() {
dismissBtn().click();
}

private WebElement meWantItBtn() {
return getDriver().findElement(By.cssSelector("a[aria-label=\"dismiss cookie message\"]"));
}

public void closeCookieMessage() {
meWantItBtn().click();
}

protected WebElement accountLink() {
return getDriver().findElement(By.id("navbarAccount"));
}

private WebElement loginLink() {
return getDriver().findElement(By.id("navbarLoginButton"));
}

public LoginPage navigateToLoginPage() {
closeBanner();
closeCookieMessage();
accountLink().click();
loginLink().click();
return new LoginPage();
}

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

&lt;/div&gt;



&lt;p&gt;The following are two pop-up messages appearing on the website’s Home page that need to be handled first before moving ahead to the Login page. You can learn more about it through this blog on &lt;a href="https://www.lambdatest.com/blog/handling-login-popup-in-selenium-webdriver-using-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;handling pop-ups in Selenium&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%2F800%2F0%2A_2RgoOK0IQ8E7_Jl.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%2F800%2F0%2A_2RgoOK0IQ8E7_Jl.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Deep dive to learn about&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;test automation&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its uasage, types and also gain insights on how to get started with automated testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s search for the selectors of the Dismiss button in the DOM using Chrome browser’s Developer Tools.&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%2F800%2F0%2A6xSKU-S5uWBVW5ph.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%2F800%2F0%2A6xSKU-S5uWBVW5ph.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we inspect the Dismiss button in the Developer Tools, it takes us to the HTML tag button where the label is “Close Welcome Banner”. We can use this as the Selector for locating the Dismiss button. You can learn more about different locator strategies through this tutorial on &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators" rel="noopener noreferrer"&gt;locators in Selenium&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We will be using the &lt;a href="https://www.lambdatest.com/learning-hub/css-selectors?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;CSS Selector&lt;/a&gt; locator strategy to locate the Dismiss button, and the Selector will be &lt;em&gt;“button[aria-label=”CloseWelcome Banner”]”&lt;/em&gt;. Similarly, we can use the Developer Tools window to find other WebElements on this website; we can use the Developer Tools window.&lt;/p&gt;

&lt;p&gt;To handle the first popup, i.e., Welcome pop-up, the &lt;em&gt;dismissBtn(&lt;/em&gt;) method is created in the &lt;em&gt;HomePage&lt;/em&gt; class that locates the Dismiss button. The &lt;em&gt;closeBanner()&lt;/em&gt; method clicks on the Dismiss 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AgaM7p3lvqmkowemt.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%2F800%2F0%2AgaM7p3lvqmkowemt.png" alt="image" width="800" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To handle the next pop-up displayed on the screen’s right-hand corner, the &lt;em&gt;meWantItBtn()&lt;/em&gt; method is created in the &lt;em&gt;HomePage&lt;/em&gt; class that locates the Me &lt;em&gt;Want it&lt;/em&gt;! button, and the &lt;em&gt;closeCookieMessage()&lt;/em&gt; method clicks on Me &lt;em&gt;Want it!&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ApFGPpQ_W13OKFAlg.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%2F800%2F0%2ApFGPpQ_W13OKFAlg.png" alt="image" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we move to the Account Link, open it, and click the Login link to navigate to the Login page. The &lt;em&gt;accountLink()&lt;/em&gt; and &lt;em&gt;loginLink()&lt;/em&gt; methods locate the WebElements for Account Link and Login Link.&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%2F800%2F0%2AqCUpFXGgwQ5S6QvN.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%2F800%2F0%2AqCUpFXGgwQ5S6QvN.png" alt="image" width="800" height="435"&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%2F800%2F0%2AYjmB6ENDzWKi9dPJ.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%2F800%2F0%2AYjmB6ENDzWKi9dPJ.png" alt="image" width="800" height="603"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;navigateToLoginPage()&lt;/em&gt; method performs the actions for closing the banner. The cookie message clicks on the Account and Login links and finally returns a new instance of the &lt;em&gt;LoginPage&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AYNcEBYirHVQUbH-n.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%2F800%2F0%2AYNcEBYirHVQUbH-n.png" alt="image" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the Login page, as the language notification snackbar is displayed that overlaps the Login button, we need to wait for the notification to disappear so we can move ahead and click on the button and avoid the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The following code is from the &lt;em&gt;LoginPage&lt;/em&gt; class that handles the login actions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class LoginPage {

private final HomePage homePage;

public LoginPage() {
this.homePage = new HomePage();
}

private WebElement emailField() {
return getDriver().findElement(By.id("email"));
}

private WebElement passwordField() {
return getDriver().findElement(By.id("password"));
}

private WebElement loginBtn() {
return getDriver().findElement(By.id("loginButton"));
}

private void waitForSnackBarToDisappear() {
final WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(10));
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".mat-simple-snack-bar-content")));
}

public ProductPage login(final String email, final String password) {
emailField().sendKeys(email);
passwordField().sendKeys(password);
clickLoginBtn();
return new ProductPage();
}

public boolean checkLogoutLinkIsDisplayed() {
openAccountMenu();
return getDriver().findElement(By.id("navbarLogoutButton")).isDisplayed();
}

public void openAccountMenu () {
this.homePage.accountLink().click();
}

public void clickLoginBtn() {
waitForSnackBarToDisappear();
loginBtn().click();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;invisibilityOfElementLocated()&lt;/em&gt; method from the &lt;em&gt;ExpectedConditions&lt;/em&gt; class is used here to wait till the time the WebElement for the snackbar notification disappears so we can click on the Login button.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;waitForSnackBarToDisappear()&lt;/em&gt; method implements the logic discussed.&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%2F800%2F0%2AvHnzwBOGvWBfMeuG.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%2F800%2F0%2AvHnzwBOGvWBfMeuG.png" alt="image" width="800" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;automation testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let's take a look&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This &lt;em&gt;waitForSnackBarToDisappear()&lt;/em&gt; method is called before the Login button is clicked using the &lt;em&gt;clickLoginBtn()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Aa1Zep8OqH3GC7PDN.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%2F800%2F0%2Aa1Zep8OqH3GC7PDN.png" alt="image" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, the &lt;em&gt;login()&lt;/em&gt; method is created to perform actions of entering values in email and password fields and clicking on the Login button.&lt;/p&gt;

&lt;p&gt;Let’s write the test now and check out the actual working of the scenario. Here is the test method that is available in the &lt;em&gt;JuiceShopTests&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private ProductPage productPage;

@Test
public void testLogin() {
getDriver().get("https://juice-shop.herokuapp.com/#/");
final var loginPage = new HomePage().navigateToLoginPage();
this.productPage = loginPage.login("demo+1@gmail.com", "Juice@1234");
assertTrue(loginPage.checkLogoutLinkIsDisplayed());
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this test, we perform the steps to navigate to the OWASP Juice Shop website and call the &lt;em&gt;navigateToLoginPage()&lt;/em&gt; method that will open the Login page after which the &lt;em&gt;login()&lt;/em&gt; method will be called that has valid credentials as the parameters to login into the website.&lt;/p&gt;

&lt;p&gt;Finally, the assertion is performed to check that the Logout link is displayed; this completes the login test.&lt;/p&gt;

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

&lt;p&gt;To run the test, right-click on the testng.xml and select the option &lt;code&gt;Run …/testng.xml&lt;/code&gt;&lt;em&gt;.&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Below is the screenshot from the 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ATKwO2obX6dte0z-e.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%2F800%2F0%2ATKwO2obX6dte0z-e.png" alt="image" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before executing the test, it’s a good idea to check the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;. To do this, let’s temporarily disable the &lt;em&gt;waitForSnackBarToDisappear()&lt;/em&gt; method within the &lt;em&gt;clickLoginBtn()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Ax6INdyOV9icTi4uk.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%2F800%2F0%2Ax6INdyOV9icTi4uk.png" alt="image" width="748" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the test execution result that shows the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium was thrown, and the test failed.&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%2F800%2F0%2AaChyVpueH2gemrDn.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%2F800%2F0%2AaChyVpueH2gemrDn.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s uncomment the &lt;em&gt;waitForSnackBarToDisappear()&lt;/em&gt; method in the &lt;em&gt;clickLoginBtn()&lt;/em&gt; method and rerun 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A-yC4bEWVyS1Y1u5A.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%2F800%2F0%2A-yC4bEWVyS1Y1u5A.png" alt="image" width="778" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium was handled successfully, and the tests passed.&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%2F800%2F0%2AjI7IM3wHYDaDusGy.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%2F800%2F0%2AjI7IM3wHYDaDusGy.png" alt="image" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Solution 2: Locate the overlay WebElement and click on it
&lt;/h3&gt;

&lt;p&gt;The second solution we can try to handle the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is locating the overlay WebElement and clicking on it. Then, perform the next steps to click on the required WebElement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the OWASP Juice Shop website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Login to the website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the product page, add a product to the cart.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check that the cart shows “1” product added to it&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%2F800%2F0%2AmJqxmln4wf5nMZlr.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%2F800%2F0%2AmJqxmln4wf5nMZlr.png" alt="image" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, as soon as the product page is loaded after successful login, it is overlapped with an overlay screen that intercepts the click on the Add to Basket button on the page, and an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is thrown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;automation testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let's take a look&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;As we already discussed the login in Scenario 1, we will not be going into details for login again here. We will focus on the last 2 steps in this scenario: adding a product to the cart and checking that the cart shows “1” product added.&lt;/p&gt;

&lt;p&gt;The following code is written in the &lt;em&gt;ProductPage&lt;/em&gt; class that helps locate the WebElements and perform interactions on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ProductPage {

private WebElement appleJuiceAddToBasketBtn() {
return getDriver().findElement(By.cssSelector("mat-grid-tile:nth-child(1) &amp;amp;gt; div &amp;amp;gt; mat-card &amp;amp;gt; div:nth-child(2) &amp;amp;gt; button"));
}

private WebElement overlay() {
return getDriver().findElement(
By.cssSelector(".cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing"));
}
public void addAppleJuiceToCart() {
overlay().click();
appleJuiceAddToBasketBtn().click();
}

public String itemsInBasket() {
return getDriver().findElement(By.cssSelector("span.warn-notification")).getAttribute("innerText");
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;overlay()&lt;/em&gt; method locates and returns the WebElement for the overlay screen and is called in the &lt;em&gt;addAppleJuiceToCart()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;itemsInBasket()&lt;/em&gt; method returns the value of the items in the cart WebElement in the string format that will help us perform assertion.&lt;/p&gt;

&lt;p&gt;Here is the test method &lt;em&gt;testAddProductToBasket()&lt;/em&gt; available in the &lt;em&gt;JuiceShopTests&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;We have already covered the login step in Scenario 1. This Scenario 2 test will run after the Scenario 1 test, and the test order will be handled 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;@Test
public void testAddProductToBasket() {
this.productPage.addAppleJuiceToCart();
assertEquals(this.productPage.itemsInBasket(), "1 ");
}
&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;Here is the screenshot of the testng.xml file that will be used to run 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ADXaabeLyW8gWI0n8.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%2F800%2F0%2ADXaabeLyW8gWI0n8.png" alt="image" width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before running the tests, let’s comment out the statement where we are locating the overlay screen and clicking on it to replicate the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AoLgFdNnsQ1bV_vrq.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%2F800%2F0%2AoLgFdNnsQ1bV_vrq.png" alt="image" width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshot below shows the test execution result with the &lt;em&gt;ElementClickInterceptedException&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AmbzbyC3462kTcmZS.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%2F800%2F0%2AmbzbyC3462kTcmZS.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you check the logs closely, you will notice that it provides us with the WebElement locator for the overlay screen. This can be used directly to locate and click on the overlay screen WebElement.&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%2F800%2F0%2AIRxZJuVfYdBxLrcv.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%2F800%2F0%2AIRxZJuVfYdBxLrcv.png" alt="image" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s uncomment the statement that clicks on the overlay WebElement and handles the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A17bW-mT3vAeTK0kl.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%2F800%2F0%2A17bW-mT3vAeTK0kl.png" alt="image" width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s re-run the test and check the output.&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%2F800%2F0%2AdG8pX7XXisMKvZDc.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%2F800%2F0%2AdG8pX7XXisMKvZDc.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tests passed successfully using the solution where we clicked the overlay screen before clicking the Add to Basket button.&lt;/p&gt;

&lt;p&gt;Mobile &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;emulators online&lt;/a&gt; from LambdaTest allows you to seamlessly test your mobile applications, websites,and web apps on mobile browsers and mobile devices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution 3: Clicking on the WebElement using JavaScriptExecutor
&lt;/h3&gt;

&lt;p&gt;The third solution for handling the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is using the &lt;em&gt;JavaScriptExecutor&lt;/em&gt; to click on the WebElement. This is recommended in case the first two solutions don’t work. We can use this solution to directly click on the WebElement if we need a simple workaround.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest’s official website&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click and Play the video displayed on the right-hand side of the window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To verify that the video was played successfully, check that the close button on the video player is displayed.&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%2F800%2F0%2A7IjjSS7i5jhqne7x.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%2F800%2F0%2A7IjjSS7i5jhqne7x.png" alt="image" width="800" height="431"&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%2F800%2F0%2A_2n3JVPsOPV42D1F.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%2F800%2F0%2A_2n3JVPsOPV42D1F.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, if we try to click on the video directly by clicking on it, it throws an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;. So, we will be using the &lt;a href="https://www.lambdatest.com/blog/how-to-use-javascriptexecutor-in-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;JavaScriptExecutor&lt;/em&gt;&lt;/a&gt; and handling it.&lt;/p&gt;

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

&lt;p&gt;The implementation of this scenario is quite easy. We will navigate to the Home page, locate the web element for the video, and click on it.&lt;/p&gt;

&lt;p&gt;Finally, the assertion will be performed to check that the close button is displayed on the video player.&lt;/p&gt;

&lt;p&gt;The below code is from the &lt;em&gt;HomePage&lt;/em&gt; class created that takes care of the page objects and their respective interactions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HomePage {

private WebElement videoLink() {
return getDriver().findElement(By.cssSelector("div &amp;gt; div:nth-child(1) &amp;gt; span &amp;gt; picture &amp;gt; img"));
}

public void clickOnVideoLink() {
videoLink().click();
}

public void clickOnVideoLinkUsingJSExecutor() {
final JavascriptExecutor executor = (JavascriptExecutor) getDriver();
executor.executeScript("arguments[0].click();", videoLink());
}

public WebElement videoCloseBtn() {
final WebDriverWait wait = new WebDriverWait(getDriver(), Duration.ofSeconds(20));
return wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".popup span.close")));
}

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

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;videoLink()&lt;/em&gt; method locates the video link on the Home page. The &lt;em&gt;clickOnVideoLinkUsingJSExecutor()&lt;/em&gt; method performs click on the link using &lt;em&gt;JavaScriptExecutor&lt;/em&gt;, and the &lt;em&gt;clickOnVideoLink()&lt;/em&gt; method uses the native click method to perform click on the video link.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;videoCloseBtn()&lt;/em&gt; method returns the WebElement for Close button on the video player. This method will be further used in tests to write assertions to check that the button is displayed.&lt;br&gt;&lt;br&gt;
The test code is written for testing the working of this scenario.&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 testHomePage() {
getDriver().get("https://www.lambdatest.com");
final HomePage homePage = new HomePage();
homePage.clickOnVideoLinkUsingJSExecutor();
assertTrue(homePage.videoCloseBtn().isDisplayed());
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test is straightforward; it will first navigate to the LambdaTest’s official website, click on the video link and perform an assertion to check that the close button is displayed.&lt;/p&gt;

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

&lt;p&gt;The following test block in testng.xml will execute this scenario for us.&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%2F800%2F0%2AAdsAbk_ZyVVvTN7h.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%2F800%2F0%2AAdsAbk_ZyVVvTN7h.png" alt="image" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s first recreate the case where &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is thrown when the video is clicked on the Home page without using the &lt;em&gt;JavaScriptExecutor&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We will comment on the statement that executes the script to click with &lt;em&gt;JavaScriptExecutor&lt;/em&gt; and perform a normal click on the 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2APZt2noqMMmfHwhRK.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%2F800%2F0%2APZt2noqMMmfHwhRK.png" alt="image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following is the output of the test execution that shows that the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium was thrown while trying to click on the 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AEYTpH-na-PqvvEul.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%2F800%2F0%2AEYTpH-na-PqvvEul.png" alt="image" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s replace the &lt;em&gt;homepage.clickOnVideoLink()&lt;/em&gt; method with the &lt;em&gt;homePage.clickOnVideoLinkUsingJsExecutor()&lt;/em&gt; and re-run 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A58xQAz-XhpuyG5ea.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%2F800%2F0%2A58xQAz-XhpuyG5ea.png" alt="image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/appium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Appium&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, learn about Appium and its benefits for mobile automation testing. Take a look at how Appium works and see how to perform Appium testing of your mobile applications&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;em&gt;JavaScriptExecutor&lt;/em&gt;, the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium was handled successfully, and the tests passed.&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%2F800%2F0%2A2OTzS-TdPNfxxqMH.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%2F800%2F0%2A2OTzS-TdPNfxxqMH.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution 4: Scrolling into the View using JavaScriptExecutor before clicking on the WebElement
&lt;/h3&gt;

&lt;p&gt;The fourth solution that can be used for handling the exception is scrolling into the view. Hence, the WebElement is visible on the window and can be clicked. Using this solution, we will first scroll the web page to the point where the element is clearly visible on the page and then perform a click on it.&lt;/p&gt;

&lt;p&gt;This can be done using the &lt;em&gt;JavaScriptExecutor&lt;/em&gt; only; the only change is the argument that we pass in the &lt;em&gt;executeScript()&lt;/em&gt; method to execute the JavaScript. Here, we will be passing the &lt;em&gt;scrollIntoView()&lt;/em&gt; argument.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the UITestingPlayground website’s Overlapped Element window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the value in the &lt;em&gt;Id&lt;/em&gt; and &lt;em&gt;Name&lt;/em&gt; fields.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Perform assertion by checking the value typed in the &lt;em&gt;Name&lt;/em&gt; field.&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%2F800%2F0%2AWVAPwf5Yvo26989x.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%2F800%2F0%2AWVAPwf5Yvo26989x.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;UITestingPlayground&lt;/em&gt; website’s &lt;em&gt;Overlapped Element&lt;/em&gt; window&lt;/p&gt;

&lt;p&gt;In this website, the &lt;em&gt;Name&lt;/em&gt; field is overlapped by another WebElement, so if we try to click to type some value in the field, it will throw an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium.&lt;/p&gt;

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

&lt;p&gt;In this scenario, we will navigate the UITestingPlayground website’s Overlapped Element web page. Next, we will scroll into view using &lt;em&gt;JavaScriptExecutor&lt;/em&gt; and then type the value in the &lt;em&gt;Name&lt;/em&gt; field.&lt;/p&gt;

&lt;p&gt;Finally, assertion will be performed to check the value entered in the &lt;em&gt;Name&lt;/em&gt; field.&lt;/p&gt;

&lt;p&gt;The below code is available in the &lt;em&gt;OverLapElementPage&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class OverLapElementPage {

private WebElement idField() {
return getDriver().findElement(By.id("id"));
}

private WebElement nameField() {
return getDriver().findElement(By.id("name"));
}

public void fillForm(final String id, final String name) {
idField().click();
idField().sendKeys(id);
final var executor = (JavascriptExecutor) getDriver();
executor.executeScript("arguments[0].scrollIntoView(true);", nameField());
nameField().click();
nameField().sendKeys(name);
}

public String textInNameField() {
return nameField().getAttribute("value");
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;idField()&lt;/em&gt; and &lt;em&gt;nameField()&lt;/em&gt; methods locate and return the WebElements for the &lt;em&gt;Id&lt;/em&gt; and the &lt;em&gt;Name&lt;/em&gt; fields, respectively. Using the &lt;em&gt;fillForm()&lt;/em&gt; method, we can click on the &lt;em&gt;Id&lt;/em&gt; and &lt;em&gt;Name&lt;/em&gt; fields and type values in them. However, before we click on the &lt;em&gt;Name&lt;/em&gt; field, we will use the &lt;em&gt;JavaScriptExecutor&lt;/em&gt; to scroll into view.&lt;/p&gt;

&lt;p&gt;The following line of code will help scroll to the web page to the point where the &lt;em&gt;Name&lt;/em&gt; field is visible in the viewport.&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%2F800%2F0%2ATmnA7Tr3LdDQPjpN.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%2F800%2F0%2ATmnA7Tr3LdDQPjpN.png" alt="image" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the test written for this scenario. It is available in the &lt;em&gt;UITestingPlaygroundTests&lt;/em&gt; class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class UITestingPlaygroundTests extends BaseTest{

@Test
public void testOverLappingElement() {
getDriver().get("http://www.uitestingplayground.com/overlapped");

final var overLapElementPage = new OverLapElementPage();
final String id = "ID7763";
final String name = "Faisal K";
overLapElementPage.fillForm(id, name);

assertEquals(overLapElementPage.textInNameField(), name);

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

&lt;/div&gt;



&lt;p&gt;The first statement of code in the test navigates to the UITestingPlayground website’s Overlapped element page. Next, we call the &lt;em&gt;fillForm()&lt;/em&gt; method from the &lt;em&gt;OverLapElementPage&lt;/em&gt; class to fill values in the &lt;em&gt;Id&lt;/em&gt; and &lt;em&gt;Name&lt;/em&gt; fields.&lt;/p&gt;

&lt;p&gt;Finally, assertion is performed to check the values typed in the &lt;em&gt;Name&lt;/em&gt; field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Through this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/usability-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;usability testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, you will learn how usability testing is a great way to discover unexpected bugs, find what is unnecessary or unused before going any further, and have unbiased opinions from an outsider&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The following test block is added in the testng.xml to execute the tests for this scenario.&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%2F800%2F0%2AR1iWZLWKxEzuOTK0.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%2F800%2F0%2AR1iWZLWKxEzuOTK0.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s first replicate the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; thrown due to the &lt;em&gt;Name&lt;/em&gt; field getting overlapped with another WebElement. To do so, we must comment out the &lt;em&gt;JavaScriptExecutor&lt;/em&gt; statement in the &lt;em&gt;fillForm()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2APYRKOlU3F_jdUdfp.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%2F800%2F0%2APYRKOlU3F_jdUdfp.png" alt="image" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On executing the test, the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is thrown, as seen in the logs.&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%2F800%2F0%2A_DI_9A_2iZm5lJvE.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%2F800%2F0%2A_DI_9A_2iZm5lJvE.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s uncomment the &lt;em&gt;JavaScriptExecutor&lt;/em&gt; statement in the &lt;em&gt;fillForm()&lt;/em&gt; method and rerun 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AX4UUM_ChoVaotbW_.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%2F800%2F0%2AX4UUM_ChoVaotbW_.png" alt="image" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the &lt;em&gt;scrollintoView&lt;/em&gt; argument in &lt;em&gt;JavaScriptExecutor&lt;/em&gt; works perfectly fine handling the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;, and the tests 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A8f72bXj0l4iKcfQF.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%2F800%2F0%2A8f72bXj0l4iKcfQF.png" alt="image" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution 5: Using the Actions class of Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;The next solution we will discuss for handling the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; is using 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=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver’s &lt;em&gt;Actions&lt;/em&gt; class&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The primary reason for &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is that the respective element that needs to be clicked is either overlapped by another element or an overlay screen. So, using the Actions class’s &lt;em&gt;movetoElement()&lt;/em&gt; method, we can move the focus to the required WebElement and then perform a click on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest eCommerce&lt;/a&gt; demo website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the Home page, open the Shop by Category side menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With the Shop by Category side menu open, click on the Blog main menu.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the title of the Blog page.&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%2F800%2F0%2An2mydNSCuKrWGOe8.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%2F800%2F0%2An2mydNSCuKrWGOe8.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LambdaTest eCommerce website demo page&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A8c7n4NYhl82m5rzo.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%2F800%2F0%2A8c7n4NYhl82m5rzo.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LambdaTest eCommerce website — Blogs menu&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, after opening the Shop by Category side menu, when we try to click on the Blog main menu, it throws the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium. This exception is thrown as the Shop by Category menu overlaps the screen.&lt;/p&gt;

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

&lt;p&gt;In this scenario, we will first navigate to the LambdaTest eCommerce demo website and click on the Shop by Category side menu link. Once it opens, we will click on the Blogs menu.&lt;/p&gt;

&lt;p&gt;The following code is available in the &lt;em&gt;MainPage&lt;/em&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MainPage {

private WebElement shopByCategoryLink() {
return getDriver().findElement(By.linkText("Shop by Category"));
}

public void openShopByCategoryMenu() {
shopByCategoryLink().click();
}

private WebElement menuBar() {
return getDriver().findElement(By.cssSelector(".entry-section div.navbar-collapse"));
}
private WebElement blogLink() {
return getDriver().findElement(By.linkText("Blog"));
}
public BlogPage navigateToBlogs() {
final Actions actions = new Actions(getDriver());
actions.moveToElement(menuBar()).click().build().perform();
blogLink().click();
return new BlogPage();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;shopByCateogryLink()&lt;/em&gt; method locates and returns the WebElement for the menu link. &lt;em&gt;ShopByCategoryMenu()&lt;/em&gt; method performs the click on the Shop by Category menu.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;navigateToBlogs()&lt;/em&gt; method will help in clicking the Blog menu. The &lt;em&gt;moveToElement()&lt;/em&gt; method of the &lt;em&gt;Actions&lt;/em&gt; class is used to move the focus to the menu bar so the overlay screen can be removed and we can click on the Blog menu link.&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%2F800%2F0%2A_bo_kgCmSf1a8Tnf.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%2F800%2F0%2A_bo_kgCmSf1a8Tnf.png" alt="image" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To perform the assertion, we will be checking — “LATEST ARTICLES” in the page header on the Blog 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%2F800%2F0%2AKIxWJWdnXdSz9Pje.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%2F800%2F0%2AKIxWJWdnXdSz9Pje.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;BlogPage&lt;/em&gt; class has been created to locate the WebElement for the page header.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class BlogPage {

public String pageHeader () {
return getDriver().findElement(By.cssSelector(".entry-section div.mz-tab-listing-header h3")).getText();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;pageHeader()&lt;/em&gt; method locates the page header WebElement of a Blog page and returns its text in string format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/smoke-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;smoke testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial covers what smoke testing is, its importance, benefits, and how to perform it with real-time examples&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following automated test in the &lt;a href="https://github.com/mfaisalkhatri/selenium-exceptions-demo/blob/main/src/test/java/io/github/mfaisalkhatri/tests/LambdaTestEcommerceTest.java" rel="noopener noreferrer"&gt;&lt;em&gt;LambdaTestEcommerceTest&lt;/em&gt;&lt;/a&gt; class will help check the scenario with assertion.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class LambdaTestEcommerceTest extends BaseTest{

@Test
public void testNavigationToBlogsMenu() {
getDriver().get("https://ecommerce-playground.lambdatest.io/");
final var mainPage = new MainPage();
mainPage.openShopByCategoryMenu();
final var blogPage = mainPage.navigateToBlogs();
assertEquals(blogPage.pageHeader(), "LATEST ARTICLES");
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The test is simple to understand. We first navigate to the LambdaTest eCommerce website, open the Shop by Category menu, and then navigate to the Blog page by clicking the Blog menu.&lt;/p&gt;

&lt;p&gt;Finally, the assertion is performed to check that the page header is “LATEST ARTICLES”.&lt;/p&gt;

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

&lt;p&gt;The following test block is added in the testng.xml to execute the tests for this scenario&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%2F800%2F0%2Aq6XjekDwq7U1-LvM.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%2F800%2F0%2Aq6XjekDwq7U1-LvM.png" alt="image" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s first try to execute the test by clicking on the Blog menu link directly without using the &lt;em&gt;Actions&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;To do so, we will comment on the statements of code we wrote for using the &lt;em&gt;moveToElement()&lt;/em&gt; method from &lt;em&gt;Actions&lt;/em&gt; class, in the &lt;em&gt;navigateToBlogs()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AiVIVEwAuTESFfLTY.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%2F800%2F0%2AiVIVEwAuTESFfLTY.png" alt="image" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s run the test and check the output.&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%2F800%2F0%2AtGFRrTOFLo4rt7JF.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%2F800%2F0%2AtGFRrTOFLo4rt7JF.png" alt="image" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see the test failing after throwing an &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let’s re-run the test by uncommenting the &lt;em&gt;moveToElement()&lt;/em&gt; method statement of the &lt;em&gt;Actions&lt;/em&gt; class so it handles the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AzJCIJMMpQgCK5So6.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%2F800%2F0%2AzJCIJMMpQgCK5So6.png" alt="image" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the output of the test running 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%2F800%2F0%2ADTVruKfa4GZyl52q.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%2F800%2F0%2ADTVruKfa4GZyl52q.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A complete&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Manual testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial covering all aspects of Manual testing, including strategies and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution 6: Setting custom resolution for the browser
&lt;/h3&gt;

&lt;p&gt;The next solution is simple: maximizing the browser after we create the WebDriver instance. We can also set the custom window resolution for the browser in case we don’t want to run the tests by maximizing the browser window.&lt;/p&gt;

&lt;p&gt;As per &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=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Best Practices&lt;/a&gt;, it is advisable to maximize the window or use a custom window size that opens the window with wide mode for a uniform automation experience and to avoid elements overlapping issues related to &lt;em&gt;ElementClickInterceptedException&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Going through all the previous solutions, it can be noted that ideally, the WebElements overlap or are not in the viewport. Hence, the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is thrown while we try to click on the WebElement.&lt;/p&gt;

&lt;p&gt;So, by maximizing or resizing the window to a custom resolution, we can get a better window view where all elements are ideally visible, locatable, and can be clicked easily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maximizing the browser window&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following line of code can be used to maximize 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ALC4rAXA5sfHS5Ha4.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%2F800%2F0%2ALC4rAXA5sfHS5Ha4.png" alt="image" width="762" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customizing the browser screen resolution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two ways in which we can customize the resolution before we start running our automation tests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Customizing the window size by adding arguments using the &lt;em&gt;BrowserOptions&lt;/em&gt; class&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customizing the window size in a cloud grid like LambdaTest&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Resizing the browser window using Browser Options&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The respective class of browser options can be used to add arguments and resize the window. For example, we can resize the window of Chrome browser using the &lt;em&gt;ChromeOptions&lt;/em&gt; class as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private static void setupChromeDriver () {
final ChromeOptions options = new ChromeOptions ();
options.addArguments ("--no-sandbox");
options.addArguments ("--disable-dev-shm-usage");
options.addArguments ("--window-size=1050,650");
driver = new ChromeDriver(options);
driver.manage().window().maximize();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value for the screen resolution can be passed in the argument “&lt;em&gt;–window-size= &amp;lt; resolution in x,y format &amp;gt; ”:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Likewise, the same arguments can be used with &lt;em&gt;FirefoxOptions&lt;/em&gt; and &lt;em&gt;EdgeOptions&lt;/em&gt; classes as well for resizing the window in Firefox and Edge browsers respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resizing the browser window in LambdaTest Cloud Grid&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest is an AI-powered test orchestration and execution that allows you to perform manual and &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; on over 3000+ real browsers, devices, and platforms. It provides a reliable and scalable cloud grid to conduct &lt;a href="https://www.lambdatest.com/java-automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Java automation testing&lt;/a&gt; at scale.&lt;/p&gt;

&lt;p&gt;For &lt;a href="https://www.lambdatest.com/selenium-java-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Java testing&lt;/a&gt;, it provides the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator&lt;/a&gt; website that helps set all the capabilities using GUI. The code can be copied and used in the test configuration and setup.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/SqQ8SugRDos"&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" 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=sept_21&amp;amp;utm_term=ap&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=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, CI/CD, and more.&lt;/p&gt;

&lt;p&gt;To set the capabilities for screen resolution using the capabilities generator website, we need to click on &lt;em&gt;Configure Advanced Capabilities &amp;gt;&amp;gt;&lt;/em&gt; Screen Resolution and select the desired screen resolution as required.&lt;/p&gt;

&lt;p&gt;Once we select the resolution, the code is autogenerated and can be copied and pasted into the test automation scripts.&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%2F800%2F0%2AgQDgerpxPetEcPiR.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%2F800%2F0%2AgQDgerpxPetEcPiR.png" alt="image" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These capabilities are set in the &lt;em&gt;DriverManager&lt;/em&gt; class in the &lt;em&gt;setupRemoteDriver()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ACWwM0IXpTEE3gWxs.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%2F800%2F0%2ACWwM0IXpTEE3gWxs.png" alt="image" width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On executing the tests on the LambdaTest Cloud grid, we can check out the resolution details on the LambdaTest Automation Dashboard.&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%2F800%2F0%2AE90IL1yRHKZRFJmM.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%2F800%2F0%2AE90IL1yRHKZRFJmM.png" alt="image" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution 7: Using Thread.sleep() to debug the Exception
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/sleep-java-method/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;em&gt;Thread.sleep()&lt;/em&gt;&lt;/a&gt; is a kind of hard wait hence, it is not a recommended solution to be used in the test automation. However, when required we can use the &lt;em&gt;Thread.sleep()&lt;/em&gt; method to debug the issue to check if waiting for a certain amount of time does make the automation test work successfully and allows clicking on the WebElement.&lt;/p&gt;

&lt;p&gt;If the WebElement is clickable ideally after applying &lt;em&gt;Thread.sleep()&lt;/em&gt;, we may move to some of the ideal solutions that we discussed above.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which solution to choose for handling ElementClickInterceptedException?
&lt;/h3&gt;

&lt;p&gt;We discussed around 7 solutions to help us handle the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium. We should try using the maximize window or setting it in custom size so it opens in wide mode. This can help handle the overlapping elements quickly.&lt;/p&gt;

&lt;p&gt;If maximizing the window does not work, we can apply the &lt;em&gt;Explicit Wait&lt;/em&gt; on the element, wait for the element to be clickable, and then perform a click on it.&lt;/p&gt;

&lt;p&gt;Ideally, &lt;em&gt;JavaScriptExecutor&lt;/em&gt; should work as an ideal solution using click or scroll to view arguments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thread.sleep()&lt;/em&gt; is not a recommended solution to be used. However, we can use it for debugging purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this tutorial on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/agile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_21&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Agile testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, let's deep dive into the history of Agile testing, its advantages, disadvantages, methods, quadrants, and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;The primary reason that may lead to the &lt;em&gt;ElementClickInterceptedException&lt;/em&gt; in Selenium is that the WebElement required to be clicked may overlap with some other element. We discussed multiple solutions to handle this exception. The simplest solution we can try firsthand is to maximize the browser window or set a custom size that may make all the WebElements visible and interactable. However, if that still doesn’t work, we can try the other solutions discussed in this blog.&lt;/p&gt;

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

</description>
      <category>elementclickintercepted</category>
      <category>selenium</category>
      <category>javascript</category>
      <category>automationtesting</category>
    </item>
    <item>
      <title>Selenium Manager in Selenium 4.11.0: New Features and Improvementsx</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Wed, 06 Sep 2023 08:09:32 +0000</pubDate>
      <link>https://dev.to/testmuai/selenium-manager-in-selenium-4110-new-features-and-improvementsx-1jga</link>
      <guid>https://dev.to/testmuai/selenium-manager-in-selenium-4110-new-features-and-improvementsx-1jga</guid>
      <description>&lt;p&gt;Selenium WebDriver, as everyone knows, is used for automating browsers. It is used widely by many organizations for web automation testing. Using &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;, you can automate all the modern browsers like Google Chrome, Mozilla Firefox, Microsoft Edge, and Safari. With the release of the Selenium 4 version, WebDriver APIs run on the W3C standard protocol making &lt;a href="https://www.lambdatest.com/blog/selenium4-w3c-webdriver-protocol/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium 4 W3C Compliant&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Previously, in older versions of &lt;a href="https://www.lambdatest.com/selenium" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt;, it was required to provide the driver executable path to run the automated tests on the respective browser. Third-party libraries like &lt;a href="https://www.lambdatest.com/blog/webdrivermanager-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;WebDriverManager&lt;/em&gt;&lt;/a&gt; were used to automate the manual process of updating browser drivers.&lt;/p&gt;

&lt;p&gt;With Selenium’s version 4.6.0, Selenium Manager was introduced, providing a huge relief to the automation test engineers as it handles the browser drivers under the hood, so you don’t have to worry about the browser drivers.&lt;/p&gt;

&lt;p&gt;In this blog, let’s learn about Selenium WebDriver’s latest release, i.e., version 4.11.0, which ships the following features related to Selenium Manager:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Support for Chrome for Testing endpoints for Automated Chrome Management and ChromeDriver Management.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this tutorial, learn&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;what is Regression testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its importance, types, and how to perform it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Selenium Manager?
&lt;/h3&gt;

&lt;p&gt;Selenium Manager is a binary tool generated using Rust that provides automated driver management for Google Chrome, Mozilla Firefox, and Microsoft Edge. Selenium bindings use Selenium Manager by default, so there is no need to download it or add its dependency in the project to use it. It is still in Beta; however, it is becoming a relevant component of Selenium.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1603288968925044737-545" src="https://platform.twitter.com/embed/Tweet.html?id=1603288968925044737"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1603288968925044737-545');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1603288968925044737&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium Manager’s Automated Driver Management
&lt;/h3&gt;

&lt;p&gt;As discussed in the earlier section, Selenium Manager is used for automated driver management. When the following statement of code gets executed to run the browser using Selenium WebDriver, Selenium Manager is invoked and checks for the browser version of the respective browser installed on your machine. After downloading the browser driver, it caches it in the local &lt;code&gt;(~/.cache/selenium)&lt;/code&gt; folder. This ensures the smooth execution of future automated tests for the same browser/driver version.&lt;/p&gt;

&lt;p&gt;This caching of the drivers is done in the same folder location across macOS, Windows, and Linux.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebDriver driver = new ChromeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is the pictorial representation of Selenium Manager’s automated driver management.&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%2F800%2F0%2AgAbc15ckKEZay9ER.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%2F800%2F0%2AgAbc15ckKEZay9ER.png" alt="image" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium automation&lt;/a&gt; tests are executed, and no browser driver executable path is provided, Selenium Manager performs the following steps to manage the drivers in an automated way:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Browser version discovery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Selenium Manager checks the browser version installed on the machine where the web automation tests are executed. For example, for Chrome browser version discovery, Selenium Manager uses the command &lt;em&gt;google-chrome –version.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Driver version discovery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On getting the browser version from Step 1, the respective driver version is identified using the online metadata maintained by the browser vendors, e.g., &lt;a href="https://chromedriver.chromium.org/downloads" rel="noopener noreferrer"&gt;ChromeDriver&lt;/a&gt;, &lt;a href="https://github.com/mozilla/geckodriver/releases" rel="noopener noreferrer"&gt;geckodriver&lt;/a&gt;, or &lt;a href="https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/" rel="noopener noreferrer"&gt;msedgedriver&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Driver Download&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The driver artifact is downloaded using the driver URL obtained from Step 2. This artifact is uncompressed and stored locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 — Driver Cache&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All the driver binaries are saved to the local cache &lt;code&gt;(~/.cache/selenium)&lt;/code&gt;. This helps in re-using the same browser driver and executing the tests again if, in the future, the tests are run on the same browser/driver version.&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%2F800%2F0%2ALhBqT4jtLm-mzNf3.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%2F800%2F0%2ALhBqT4jtLm-mzNf3.png" alt="image" width="794" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Driver Cache — Windows&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AmIE8N740JI-NKIYD.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%2F800%2F0%2AmIE8N740JI-NKIYD.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Driver Cache — macOS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;tools for automation testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Running Tests on Chrome, Firefox, and Edge browsers using Selenium Manager
&lt;/h3&gt;

&lt;p&gt;Let’s now get into the implementation and check out the real-time working of Selenium Manager. But, before we move toward the demo following are some of the details related to the technical stack that we will be using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language — Java 17&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Automation Tool — Selenium WebDriver (4.11.0)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool — &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=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner — &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Project Setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Maven project has been created, and the Selenium WebDriver and TestNG dependencies are updated in the pom.xml file. Similarly, maven-compiler and &lt;em&gt;maven-surefire&lt;/em&gt; plugins are also updated in it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Dependencies updated in pom.xml&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Ap2cV5pr8jgV0lZzk.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%2F800%2F0%2Ap2cV5pr8jgV0lZzk.png" alt="image" width="800" height="797"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Filename: pom.xml&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;&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;com.lambdatest&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;selenium-manager-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;selenium-java.version&amp;gt;4.11.0&amp;lt;/selenium-java.version&amp;gt;
&amp;lt;webdrivermanager.version&amp;gt;5.4.1&amp;lt;/webdrivermanager.version&amp;gt;
&amp;lt;testng.version&amp;gt;7.8.0&amp;lt;/testng.version&amp;gt;
&amp;lt;maven.compiler.version&amp;gt;3.11.0&amp;lt;/maven.compiler.version&amp;gt;
&amp;lt;surefire-version&amp;gt;3.1.2&amp;lt;/surefire-version&amp;gt;
&amp;lt;java.release.version&amp;gt;17&amp;lt;/java.release.version&amp;gt;
&amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
&amp;lt;suite-xml&amp;gt;test-suite/testng.xml&amp;lt;/suite-xml&amp;gt;
&amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;
&amp;lt;/properties&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;${selenium-java.version}&amp;lt;/version&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;${testng.version}&amp;lt;/version&amp;gt;
&amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
&amp;lt;/dependency&amp;gt;
&amp;lt;!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager --&amp;gt;
&amp;lt;dependency&amp;gt;
&amp;lt;groupId&amp;gt;io.github.bonigarcia&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;webdrivermanager&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${webdrivermanager.version}&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;

&amp;lt;/dependencies&amp;gt;
&amp;lt;build&amp;gt;
&amp;lt;plugins&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
&amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
&amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
&amp;lt;executions&amp;gt;
&amp;lt;execution&amp;gt;
&amp;lt;goals&amp;gt;
&amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
&amp;lt;/goals&amp;gt;
&amp;lt;/execution&amp;gt;
&amp;lt;/executions&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
&amp;lt;properties&amp;gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&amp;lt;/properties&amp;gt;
&amp;lt;suiteXmlFiles&amp;gt;
&amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
&amp;lt;/suiteXmlFiles&amp;gt;
&amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;/plugins&amp;gt;
&amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AdjNrwyYMYJshilnA.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%2F800%2F0%2AdjNrwyYMYJshilnA.png" alt="image" width="382" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Demonstration — Working with Selenium Manager on Chrome, Firefox, and Edge browsers
&lt;/h4&gt;

&lt;p&gt;In this section, we will be going through a demo of three tests that will be running on Chrome, Firefox, and Edge browsers, where we will be instantiating the WebDriver and the browser driver management will be automatically done by Selenium Manager.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 1&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open Chrome browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert that the page title is “Your Store”.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open Firefox browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert that the page title is “Your Store”.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 3&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open Edge browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest’s eCommerce Playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Assert that the page title is “Your Store”.&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%2F800%2F0%2AMEEMq59Zc7Chai_W.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%2F800%2F0%2AMEEMq59Zc7Chai_W.png" alt="image" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LambdaTest’s eCommerce Playground Website&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;The following automation tests are written in the &lt;a href="https://github.com/LambdaTest-Learning/selenium-manager-demo/blob/main/src/test/java/SeleniumWebDriverManagerTests.java" rel="noopener noreferrer"&gt;&lt;em&gt;SeleniumWebDriverManagerTest&lt;/em&gt;&lt;/a&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class SeleniumWebDriverManagerTests {
private WebDriver driver;
@Test
public void testChromeLatestVersionWithSeleniumManager() {
this.driver = new ChromeDriver();
this.driver.get("https://ecommerce-playground.lambdatest.io/");

assertEquals(this.driver.getTitle(), "Your Store");
}
@Test
public void testOnFirefoxLatestVersionWithSeleniumManager() {
this.driver = new FirefoxDriver();
this.driver.get("https://ecommerce-playground.lambdatest.io/");

assertEquals(this.driver.getTitle(), "Your Store");
}

@Test
public void testOnEdgeLatestVersionWithSeleniumManager() {
this.driver = new EdgeDriver();
this.driver.get("https://ecommerce-playground.lambdatest.io/");

assertEquals(this.driver.getTitle(), "Your Store");
}

@AfterMethod(alwaysRun = true)
public void tearDown() {
this.driver.quit();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;testChromeLatestVersionWithSeleniumManager()&lt;/em&gt; is the code implementation for Scenario 1. It will open LambdaTest’s eCommerce website in the Chrome browser and perform an assertion to match the title.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;testOnFirefoxLatestVersionWithSeleniumManager()&lt;/em&gt; is the code implementation of Scenario 2. This code snippet launches the website using the Firefox browser and verifies the title through an assertion.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;testOnEdgeLatestVersionWithSeleniumManager()&lt;/em&gt; implements Scenario 3 and will perform the testing in Edge browser. It will navigate to the website and verify the title.&lt;/p&gt;

&lt;p&gt;Notice that in all three tests, we haven’t provided any driver executable path, nor have we used third-party libraries like &lt;em&gt;WebDriverManager&lt;/em&gt;. Selenium Manager will automatically handle the browser drivers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;automation testing tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Let’s create a testng.xml file and execute all three 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A2_7bVGsAsN_EUfHZ.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%2F800%2F0%2A2_7bVGsAsN_EUfHZ.png" alt="image" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the screenshot of the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; showing that all three tests passed 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%2F800%2F0%2AvwUjhkRjdVqLlvEy.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%2F800%2F0%2AvwUjhkRjdVqLlvEy.png" alt="image" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s also check the Driver Cache, as the latest browser driver should be downloaded and stored 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A7Mq7XulCFfatduC1.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%2F800%2F0%2A7Mq7XulCFfatduC1.png" alt="image" width="800" height="560"&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%2F800%2F0%2AjkzCSyGIz7ZUXIDF.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%2F800%2F0%2AjkzCSyGIz7ZUXIDF.png" alt="image" width="800" height="232"&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%2F800%2F0%2A5WIE2wCTpWTVRCXY.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%2F800%2F0%2A5WIE2wCTpWTVRCXY.png" alt="image" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium Manager Major Changes — Working with Drivers added to the PATH
&lt;/h3&gt;

&lt;p&gt;With the introduction of Selenium Manager, automated driver management is handled for the Selenium bindings. Selenium Manager is a fallback solution when no drivers are specified during setup.&lt;/p&gt;

&lt;p&gt;However, Selenium users can continue to manage the drivers manually by putting the drivers on the PATH or using System Properties, or by using third-party libraries like &lt;em&gt;WebDriverManager&lt;/em&gt;. Selenium Manager also helps users to notify the potential problems with the drivers on the PATH.&lt;/p&gt;

&lt;p&gt;For example, consider a scenario of running the &lt;a href="https://www.lambdatest.com/learning-hub/browser-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;browser automation&lt;/a&gt; tests on Chrome browser where the browser drivers are maintained manually by setting it on the environment variable PATH. So, when writing the tests, the latest version of Chrome browser was 113. Hence the respective browser driver of version 113 was downloaded and set in the environment variable PATH.&lt;/p&gt;

&lt;p&gt;Now, as Chrome browser has the auto-update feature, it gets updated with the latest version, i.e., 115, in the background. So, if we run the automation tests, it will throw an error stating that “&lt;em&gt;This version of ChromeDriver only supports Chrome version 113&lt;/em&gt;” because, with the latest Chrome browser, version 115, the browser driver with version 112 is incompatible.&lt;/p&gt;

&lt;p&gt;With Selenium’s 4.11.0 release, when an incompatible browser driver is found on the PATH, the following warning message is displayed in the console logs when Selenium tests are executed; this helps in better visibility of the error.&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%2F800%2F0%2ADgR4NQX2v_I2B80M.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%2F800%2F0%2ADgR4NQX2v_I2B80M.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This shows that when browser drivers are already set in the PATH variable, Selenium Manager will not auto-download the respective browser driver but will show a warning message to update the browser driver manually.&lt;/p&gt;

&lt;p&gt;Another approach to consider is leveraging Selenium Manager’s driver management capabilities. By eliminating the need for a driver PATH, Selenium Manager can autonomously identify and download the necessary browser, facilitating the execution of web automation tests.&lt;/p&gt;

&lt;h4&gt;
  
  
  Demonstration — Checking out the Warning message in Selenium 4.11.0 release for the incompatible browser driver set in the PATH
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Test Scenario
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Download the ChromeDriver executable for Chrome version 113.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the Chrome browser driver executable in the Environment Variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open the Chrome browser having the latest version 115 using Selenium WebDriver.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this scenario, we will manually set the driver for ChromeDriver version 113 in the environment variable PATH and try to perform &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt; on the Chrome browser’s latest version, which is 115.&lt;/p&gt;

&lt;p&gt;So ideally, we should get the following warning message in the console output along with SessionNoCreatedException.&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%2F800%2F0%2A6ise9VW--Pe1xKZ3.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%2F800%2F0%2A6ise9VW--Pe1xKZ3.png" alt="image" width="800" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;Chrome browser version 115 is currently installed on the local machine.&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%2F800%2F0%2AFbF_-ceFC7Ga7BPQ.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%2F800%2F0%2AFbF_-ceFC7Ga7BPQ.png" alt="image" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To test this scenario, we need to download the ChromeDriver executable for version 113. So there is a mismatch between the Chrome browser and the ChromeDriver versions. Here, we will be downloading the ChromeDriver.exe for Windows platform.&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%2F800%2F0%2AQMaoDsSSQxsjdQ7r.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%2F800%2F0%2AQMaoDsSSQxsjdQ7r.png" alt="image" width="800" height="407"&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%2F800%2F0%2AUjRe5dztZugabxKq.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%2F800%2F0%2AUjRe5dztZugabxKq.png" alt="image" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Once the ChromeDrive.exe is downloaded, let’s set the ChromeDriver executable path in the Environment variable.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to System Properties and open the Environment Variables window by clicking the Environment Variables button.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AnzUP3oYvQJ3rQILV.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%2F800%2F0%2AnzUP3oYvQJ3rQILV.png" alt="image" width="410" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the &lt;em&gt;Path&lt;/em&gt; variable and click on the Edit button.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AFM2mwRvLus4BqVyv.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%2F800%2F0%2AFM2mwRvLus4BqVyv.png" alt="image" width="616" height="582"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the &lt;em&gt;ChromeDriver.exe&lt;/em&gt;’s path in it.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AS5dLHvYYc6AA_2H1.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%2F800%2F0%2AS5dLHvYYc6AA_2H1.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the OK button and close the Environment Variable window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Perform browser&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;automation testing platform&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;on the most powerful cloud infrastructure. Leverage LambdaTest automation testing for faster, reliable and scalable experience on cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following automation test scripts are written in the &lt;a href="https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/#drivers-on-the-path" rel="noopener noreferrer"&gt;SeleniumWebDriverManagerTest&lt;/a&gt; class.&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 testOnChromeBySettingEnvVariablePath() {
   WebDriver driver = new ChromeDriver();
   driver.get("https://ecommerce-playground.lambdatest.io/");

   driver.quit();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;testOnChromeBySettingEnvVariablePath()&lt;/em&gt; will open the Chrome browser using the &lt;em&gt;ChromeDriver.exe&lt;/em&gt; set in the &lt;em&gt;PATH&lt;/em&gt; variable, navigate to the LambdaTest eCommerce website and close the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;This test will not run successfully and will fail, throwing the SessionNotCreatedException with a warning that the ChromeDriver.exe is incompatible.&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;The following test block is added in the testng.xml file that will help execute 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AZkzV69YBKRQ72veI.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%2F800%2F0%2AZkzV69YBKRQ72veI.png" alt="image" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the screenshot of the test execution showing the test failure with the warning and &lt;em&gt;NoSessionCreatedException.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ARuBm3EbfZUiDBfc1.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%2F800%2F0%2ARuBm3EbfZUiDBfc1.png" alt="image" width="800" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**Introduction to Chrome for Testing&lt;br&gt;&lt;br&gt;
**With the Selenium Manager’s 4.11.0 release, a major new feature, “Automated Browser Management,” has been introduced that manages the Chrome browser as well as its respective browser drivers for version 113 and above. This has been made possible due to the Chrome team’s latest release — Chrome for Testing (CfT).&lt;/p&gt;

&lt;p&gt;The Google Chrome team recently announced the release of Chrome for Testing(CfT). It is a new flavor of Chrome that specifically targets &lt;a href="https://www.lambdatest.com/learning-hub/web-application-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;web application testing&lt;/a&gt; and is created initially for web browser automation testing. It is not recommended for daily browsing.&lt;/p&gt;

&lt;p&gt;A regular Chrome release is evergreen, meaning the browsers are automatically upgraded to future versions. However, Chrome for Testing is not evergreen. This is the key difference between a normal Chrome release and Chrome for Testing.&lt;/p&gt;

&lt;p&gt;From Chrome version 114, the &lt;em&gt;ChromeDriver&lt;/em&gt; team has stopped publishing the &lt;em&gt;ChromeDriver&lt;/em&gt; releases and metadata on their traditional &lt;em&gt;ChromeDriver&lt;/em&gt; download repository.&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%2F800%2F0%2AMEsAvrrlRYCfK0y7" 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%2F800%2F0%2AMEsAvrrlRYCfK0y7" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The portable binary releases from &lt;em&gt;ChromeDriver&lt;/em&gt; version 115 for Chrome for Testing for Windows, Linux, and macOS for its different versions, including Stable, Beta, Dev, and Canary, can be programmatically checked using the &lt;a href="https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints" rel="noopener noreferrer"&gt;CfT JSON endpoints&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%2F800%2F0%2ALqTSU3N6L373-spE" 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%2F800%2F0%2ALqTSU3N6L373-spE" alt="image" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;**Automated Browser Management with Selenium Manager using Chrome for Testing&lt;br&gt;&lt;br&gt;
**In the earlier section of this blog, we learned how Selenium Manager automates driver management for modern browsers like Chrome, Firefox, and Edge. With the introduction of Chrome for Testing, Selenium Manager also implements automated browser management for Chrome browsers.&lt;br&gt;&lt;br&gt;
Below is the pictorial representation of Selenium Manager’s automated browser management for Chrome for 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AYLFneUPo0NimujNj" 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%2F800%2F0%2AYLFneUPo0NimujNj" alt="image" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Selenium Manager now downloads the Chrome browser in case Chrome is not installed on the machine where automation tests are run. When a web automation test is targeted to run on Chrome browser’s latest version or any other specified version (v113 and above), use the following statement in the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Webdriver driver = new ChromeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Selenium Manager will perform the following steps to perform automated browser management using Chrome for Testing.&lt;br&gt;&lt;br&gt;
*&lt;em&gt;Step 1 — Chrome browser version discovery&lt;br&gt;&lt;br&gt;
**Selenium Manager checks the Chrome browser version installed on the machine where the web automation tests are executed. It uses the command *google-chrome –version&lt;/em&gt; under the hood to check for the browser version.&lt;br&gt;&lt;br&gt;
*&lt;em&gt;Step 2 — Chrome Driver version discovery&lt;br&gt;&lt;br&gt;
**On getting the browser version from Step 1, the *ChromeDriver&lt;/em&gt; version is identified programmatically using &lt;a href="https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints" rel="noopener noreferrer"&gt;CfT JSON endpoints&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
*&lt;em&gt;Step 3 — Chrome Driver download&lt;br&gt;&lt;br&gt;
**Using the *ChromeDriver&lt;/em&gt; URL obtained from Step 2, the &lt;em&gt;ChromeDriver&lt;/em&gt; artifact is downloaded. This artifact is uncompressed and stored locally.&lt;br&gt;&lt;br&gt;
*&lt;em&gt;Step 4 — Chrome browser download CfT&lt;br&gt;&lt;br&gt;
**This step is a newly introduced feature in Selenium WebDriver from version 4.11.0. In this step, if the version of the Chrome browser is not installed on the machine on which the automated tests need to be executed, then the current stable CfT release is discovered, downloaded, and cached. In addition to the stable version, Selenium Manager also allows downloading the older version till v113.&lt;br&gt;&lt;br&gt;
In case the Chrome browser version specified in the test is lower than “113”, it will throw *NoSuchDriverException&lt;/em&gt; with the following error (here, the Chrome browser version was provided as “112” in the 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AOHSdm5g5tOK6Ux9L" 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%2F800%2F0%2AOHSdm5g5tOK6Ux9L" alt="image" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to the fixed browser versions, like 113, 114, etc., the following Chrome for Testing browser version &lt;em&gt;labels&lt;/em&gt; can also be specified in the automated tests.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Step 5 — Chrome driver cache&lt;br&gt;&lt;br&gt;
**All the Chrome for Testing releases are saved to the local cache *(~/.cache/selenium/chrome)&lt;/em&gt;. This helps in re-using the same browser driver and executing the tests again if the tests are required to be run on the same browser/driver in the future.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Perform browser on the most powerful&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;testing automation cloud&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;infrastructure. Leverage LambdaTest automation testing for faster, reliable and scalable experience on cloud.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running Tests on Chrome browser using Chrome for Testing with Selenium Manager&lt;br&gt;&lt;br&gt;
**Let’s now get our hands dirty by checking out the actual working of automated browser management using Chrome for Testing using Selenium Manager.&lt;br&gt;&lt;br&gt;
**Test Scenario 1&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Set the Chrome browser version to 113 (not installed on the machine).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Chrome browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest eCommerce playground website&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;**Implementation&lt;br&gt;&lt;br&gt;
**In this scenario, we will check that the Chrome browser(v113) that is targeted to run a web automated test is not installed on the machine where tests will be executed, so Selenium Manager should install and cache the Chrome browser(v113) using Chrome for Testing and run the test.&lt;br&gt;&lt;br&gt;
The following automation tests are written in the &lt;a href="https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/#drivers-on-the-path" rel="noopener noreferrer"&gt;&lt;em&gt;SeleniumWebDriverManagerTest&lt;/em&gt;&lt;/a&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private WebDriver driver;

@Test
public void testOnChromeOldVersionWithSeleniumManager() {
final ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("113");
this.driver = new ChromeDriver(options);
this.driver.get("https://ecommerce-playground.lambdatest.io/");
assertEquals(this.driver.getTitle(), "Your Store");
}

@AfterMethod(alwaysRun = true)
public void tearDown() {
this.driver.quit();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;testOnChromeOldVersionWithSeleniumManager()&lt;/em&gt; is created for testing this scenario. Using &lt;em&gt;ChromeOptions()&lt;/em&gt; class, we will set the Chrome browser version to 113 to run the tests. Once the browser is opened, it will navigate to LambdaTest’s eCommerce website and perform assertions to match the title.&lt;/p&gt;

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

&lt;p&gt;Let’s create a testng.xml file and execute 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ABDhyCPZrDr7Z4IFm.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%2F800%2F0%2ABDhyCPZrDr7Z4IFm.png" alt="image" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the test is run, Selenium Manager checks for the Chrome browser version. As v113 was not installed on the machine, it downloads and saves the browser binary and its respective driver(v113) in the &lt;code&gt;~/.cache/selenium/chrome&lt;/code&gt; folder on the machine. Finally, the Chrome browser with v113 was run as specified in the test.&lt;/p&gt;

&lt;p&gt;Here is the screenshot of the test execution showing the test passing 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%2F800%2F0%2AYVBocliSncwb7aZz.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%2F800%2F0%2AYVBocliSncwb7aZz.png" alt="image" width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, it can be noted that using Selenium’s latest version, 4.11.0, we can run automated tests on any Chrome browser version starting from 113 and above, even if it is not installed on the machine. Using &lt;a href="https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints" rel="noopener noreferrer"&gt;Chrome for Testing’s JSON Endpoints&lt;/a&gt;, the respective Chrome browser version will be downloaded and saved in the cache for running automated tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, we will be running the tests by setting the different Chrome versions using the Chrome for Testing version labels, namely, &lt;em&gt;stable, beta, dev, and canary&lt;/em&gt;, which is supported in the Selenium WebDriver’s latest release version, 4.11.0&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Set the Chrome browser version using the following labels in the &lt;em&gt;setBrowserVersion&lt;/em&gt; method of &lt;em&gt;ChromeOptions&lt;/em&gt; class.&lt;br&gt;&lt;br&gt;
a. stable&lt;br&gt;&lt;br&gt;
b. beta&lt;br&gt;&lt;br&gt;
c. dev&lt;br&gt;&lt;br&gt;
d. canary&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Chrome browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest eCommerce playground website&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;We will use the &lt;a href="https://www.lambdatest.com/blog/how-to-use-dataproviders-in-testng-with-examples/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;@DataProvider annotation of TestNG&lt;/em&gt;&lt;/a&gt; by parameterizing the browser version. This will help in handling all 4 test cases of running tests on &lt;em&gt;stable (v115.0.5790.170), beta(v116.0.5845.62), dev(117.0.5927.0), and canary(117.0.5936.0)&lt;/em&gt; in a single automation test.&lt;/p&gt;

&lt;p&gt;The following two methods &lt;em&gt;browserVersions()&lt;/em&gt; and &lt;em&gt;testChromeVersionsWithSeleniumManager()&lt;/em&gt; are created in the &lt;a href="https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/#drivers-on-the-path" rel="noopener noreferrer"&gt;&lt;em&gt;SeleniumWebDriverManagerTests&lt;/em&gt;&lt;/a&gt; class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private WebDriver driver;
@DataProvider
public Iterator&amp;lt;Object[]&amp;gt; browserVersions() {
final List&amp;lt;Object[]&amp;gt; versions = new ArrayList&amp;lt;&amp;gt;();
versions.add(new Object[]{"stable"});
versions.add(new Object[]{"beta"});
versions.add(new Object[]{"dev"});
versions.add(new Object[]{"canary"});
return versions.iterator();
}

@Test(dataProvider = "browserVersions")
public void testChromeVersionsWithSeleniumManager(final String browserVersion) throws InterruptedException {
final ChromeOptions options = new ChromeOptions();
options.setBrowserVersion(browserVersion);
this.driver = new ChromeDriver(options);

this.driver.get("https://ecommerce-playground.lambdatest.io/");

assertEquals(this.driver.getTitle(), "Your Store");
}

@AfterMethod(alwaysRun = true)
public void tearDown() {
this.driver.quit();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;browserVersions()&lt;/em&gt; method is created to pass the parameterized browser version values using the &lt;em&gt;@DataProvider&lt;/em&gt; annotation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;testChromeVersionsWithSeleniumManager()&lt;/em&gt; test is created to run the automation tests on different versions of Chrome browser. The &lt;em&gt;@DataProvider&lt;/em&gt; annotation will help iterate and pass on the browser version values in the &lt;em&gt;setBrowserVersion()&lt;/em&gt; method of &lt;em&gt;ChromeOptions&lt;/em&gt; class that is finally used for running the &lt;em&gt;ChromeDriver&lt;/em&gt;. It will run the tests four times for four different versions of browsers as specified in the &lt;em&gt;browserVersions()&lt;/em&gt; method.&lt;/p&gt;

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

&lt;p&gt;The following test block is added in the testng.xml that will execute the test for this scenario.&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%2F800%2F0%2AUGgFcuTtH3WXDsf6.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%2F800%2F0%2AUGgFcuTtH3WXDsf6.png" alt="image" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The test on the &lt;em&gt;stable&lt;/em&gt; version of Chrome runs successfully. However, the tests for &lt;em&gt;beta, dev, and canary&lt;/em&gt; versions failed, for which an issue has already been reported on &lt;a href="https://github.com/SeleniumHQ/selenium/issues/12457" rel="noopener noreferrer"&gt;Selenium’s GitHub Repo&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%2F800%2F0%2AxnsUOLH0MczJBt8H.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%2F800%2F0%2AxnsUOLH0MczJBt8H.png" alt="image" width="800" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Chrome for Testing release binaries are saved to &lt;code&gt;~/.cache/selenium/chrome&lt;/code&gt; folder.&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%2F800%2F0%2AkCKB4nI3DMAcMTJQ.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%2F800%2F0%2AkCKB4nI3DMAcMTJQ.png" alt="image" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are the details of the test execution showing the test failures for the test run on &lt;em&gt;beta, dev, and canary versions&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error displayed in the logs for beta, dev, and canary versions&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ASbfoDSxhUZ5UxBTw.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%2F800%2F0%2ASbfoDSxhUZ5UxBTw.png" alt="image" width="800" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution (Chrome — 113.0, Test Status — Pass)&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AL4jJHTRTJh61gIHD.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%2F800%2F0%2AL4jJHTRTJh61gIHD.png" alt="image" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution (Chrome — beta(v116.0.5845.62), Test Status — Fail)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the tests for the &lt;em&gt;beta, dev, and canary&lt;/em&gt; versions run, the Chrome browser icon is displayed with a &lt;em&gt;Test&lt;/em&gt; label on 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3Bjxx1RSGb1JTLSw.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%2F800%2F0%2A3Bjxx1RSGb1JTLSw.png" alt="image" width="320" height="200"&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%2F800%2F0%2A2GRgAUUOrDDgdiRI.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%2F800%2F0%2A2GRgAUUOrDDgdiRI.png" alt="image" width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution (Chrome — dev(v117.0.5927.0), Test Status — Fail)&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A4LZVGgOuZVqo6W4n.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%2F800%2F0%2A4LZVGgOuZVqo6W4n.png" alt="image" width="800" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution (Chrome — canary(v117.0.5930.0), Test Status — Failed)&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AJnHF1e-JQ0LbiPmU.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%2F800%2F0%2AJnHF1e-JQ0LbiPmU.png" alt="image" width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This marks the completion of this scenario where we checked by running the tests using Chrome for Testing browser versions &lt;em&gt;stable, beta, dev, and canary&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, we will be checking that when the Chrome browser version is set to 112 for running the automation tests and the &lt;em&gt;ChromeDriver&lt;/em&gt; executable is not provided.&lt;/p&gt;

&lt;p&gt;Here, Selenium Manager should not be automatically managing the Chrome browser and &lt;em&gt;ChromeDriver&lt;/em&gt; for version 112 as Chrome for Testing has been introduced for Chrome version 113 and above, so Selenium Manager won’t be able to find the download endpoints for 112 and throw an error.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Set the Chrome browser version to 112 (not installed on the local machine).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Chrome browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the &lt;a href="https://ecommerce-playground.lambdatest.io/" rel="noopener noreferrer"&gt;LambdaTest eCommerce playground&lt;/a&gt; website.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Let’s run a web automation test by setting the Chrome browser version to 112. However, in this scenario, the local Chrome browser installed has version 115. This test should fail as Chrome for Testing is available for versions 113 and above.&lt;/p&gt;

&lt;p&gt;The following test method, &lt;em&gt;testOnChomeOldVersion112()&lt;/em&gt;, is available in the &lt;em&gt;SeleniumWebDriverManagerTest&lt;/em&gt; class&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 testOnChromeOldVersion112() {
final ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("112");

this.driver = new ChromeDriver(options);
this.driver.get("https://ecommerce-playground.lambdatest.io/");

assertEquals(this.driver.getTitle(), "Your Store");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This test will set the browser version to 112 using the &lt;em&gt;setBrowserVersion()&lt;/em&gt; method of &lt;em&gt;ChromeOptions&lt;/em&gt; class, navigate to the LambdaTest eCommerce playground website and perform an assertion of the page title.&lt;/p&gt;

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

&lt;p&gt;Here, the testng.xml file has been updated to run 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AjsNP5ef9CEbJKjkk.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%2F800%2F0%2AjsNP5ef9CEbJKjkk.png" alt="image" width="800" height="553"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The test should fail with the following error: &lt;em&gt;Chrome for Testing was introduced for Chrome version 113, and the current version of the installed browser on the local machine is 115.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AtL9uu_4jKqMydXl_.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%2F800%2F0%2AtL9uu_4jKqMydXl_.png" alt="image" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the screenshot 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Ah9TLoSImIYBK0u-n.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%2F800%2F0%2Ah9TLoSImIYBK0u-n.png" alt="image" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This shows that Chrome for Testing is only available with versions 113 and above and can not be used with versions below it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This tutorial dive deep into&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/web-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;web testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to help you understand its life cycle, elements, angles, the role of automation, and more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;With the release of Selenium WebDriver’s version 4.11.0, it has proved to be more powerful with the latest features of Selenium Manager, which includes the batteries and allows it to run the browsers seamlessly, performing the discovery, download, and cache of the browser drivers.&lt;/p&gt;

&lt;p&gt;The release of Chrome for Testing (CfT) by the Chrome team has made the automation test engineer’s life easier as it will also allow testing the web application on Chrome’s upcoming versions like &lt;em&gt;beta, dev, and canary&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Also, testers don’t have to worry about the Chrome browser installation as well on the local machine as going ahead for version 113 and above, Selenium Manager will automatically perform the automated browser management allowing seamless execution of web automation tests.&lt;/p&gt;

&lt;p&gt;With the ease of directly invoking browsers using Selenium Manager, it was a hassle-free experience to use Selenium WebDriver’s latest version, 4.11.0. I recommend using Selenium WebDriver’s latest version, which provides automated drivers and Chrome browser management and helps us perform &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=sept_06&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; seamlessly.&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>automationtesting</category>
      <category>softwaretesting</category>
    </item>
    <item>
      <title>Thread.sleep() Method in Java – Complete Tutorial With Example</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Thu, 27 Jul 2023 07:29:45 +0000</pubDate>
      <link>https://dev.to/testmuai/threadsleep-method-in-java-complete-tutorial-with-example-b8h</link>
      <guid>https://dev.to/testmuai/threadsleep-method-in-java-complete-tutorial-with-example-b8h</guid>
      <description>&lt;h3&gt;
  
  
  Thread.sleep() Method in Java — Complete Tutorial With Example
&lt;/h3&gt;

&lt;p&gt;Steve (a fresher) recently joined our team as a Test Engineer. He was passionate and eager to learn new techniques and technologies and gain expertise in &lt;a href="https://www.lambdatest.com/learning-hub/software-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;software testing&lt;/a&gt;. We were working on an application that eased the customers’ pain of making offline medical payments by standing in queues to bring it all at their fingertips and make the payments online.&lt;/p&gt;

&lt;p&gt;It was a web application that helped customers to make payments easily using their Debit and Credit Cards. It had an intuitive interface that could be easily learned to use.&lt;/p&gt;

&lt;p&gt;As it was a web application, our team agreed to use &lt;a href="https://www.lambdatest.com/blog/selenium-with-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium WebDriver with Java&lt;/a&gt;, as most of the application was written using Java. Steve was given one task of automating the payment page. It had some fields related to the Credit/Debit Card numbers, CVV, and some fields to accept user details like First Name, Last Name, Address, etc.&lt;/p&gt;

&lt;p&gt;It was an easy task; however, since Steve was new to the &lt;a href="https://www.lambdatest.com/learning-hub/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test automation&lt;/a&gt; field, he could automate most of the stuff. However, he struggled with one automation test case where he had to click on the Continue button of a pop-up message after entering the card details for making a payment. As he could not find a solution, he approached me with the query, and we decided to debug the test further for the failure.&lt;/p&gt;

&lt;p&gt;We thought it might be an issue related to the incorrect locator of the Continue button. &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Locators in Selenium&lt;/a&gt; play a significant role in interacting with the web elements. Initially, XPath was used to locate the Continue button, so we changed it to &lt;a href="https://www.lambdatest.com/learning-hub/css-selectors?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;CSS Selector&lt;/a&gt; as it is faster and simpler than XPath. However, the test was still unable to click on the Continue button.&lt;/p&gt;

&lt;p&gt;To debug the issue, we decided to use &lt;em&gt;Thread.sleep()&lt;/em&gt; in the code to pause the code for 3 seconds and place it above the code statement where we were clicking on the Continue button. Voila, the test ran successfully!!&lt;/p&gt;

&lt;p&gt;When we investigated the problem further, we found that it took some time for the pop-up to appear on the screen. However, by the time the pop-up appeared, the code had passed the lines where it needed to click on the Continue button. Due to this, the test failed. Many test automation engineers might have faced a similar issue as well. The learnings of this blog on using &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java can be useful in resolving such issues.&lt;/p&gt;

&lt;p&gt;In this &lt;a href="https://www.lambdatest.com/learning-hub/selenium-java?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium Java&lt;/a&gt; tutorial, we will be talking about &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java to pause the code execution for some time and will move towards the best practices of using &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=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium’s Implicit, Explicit and Fluent Waits&lt;/a&gt; in the code for saving the time in test automation code execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Learn the essential concepts, techniques, and strategies for high-quality software through effective&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/software-quality-assurance?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Software Quality Assurance&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;. This guide covers its importance, benefits, practical tips, and best practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Thread.sleep()?
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Thread&lt;/em&gt; class is present in java.lang package and contains the &lt;em&gt;sleep()&lt;/em&gt; method in it.&lt;br&gt;&lt;br&gt;
&lt;em&gt;Thread.sleep()&lt;/em&gt; stops the execution of a program in the current thread for a certain time as per the duration specified as a parameter.&lt;/p&gt;

&lt;p&gt;This is a blocking wait unless any other thread generates an interrupt. So, when it comes to using T*hread.sleep()* in test automation, it can have huge repercussions if the delay is high.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;sleep()&lt;/em&gt; method does not return any value as the method is void. It throws an &lt;em&gt;InterruptedException&lt;/em&gt; in case any other thread interrupts the current thread.&lt;/p&gt;

&lt;p&gt;The following image explains the life cycle of a thread –&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%2F800%2F0%2AoOfSl0YW85xKwhm8.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%2F800%2F0%2AoOfSl0YW85xKwhm8.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a thread is created, it is in a New state meaning its code is yet to be run and is not started to execute.&lt;/p&gt;

&lt;p&gt;Next, it moves to a Runnable instance, which means the code is in the state to run and can be executed at any time.&lt;/p&gt;

&lt;p&gt;Running instance is where the code execution starts, after which the timed wait may be called for blocking or making the program wait for a fixed time duration, and the program will return to a runnable/running state after the duration has passed. For example, the &lt;em&gt;sleep()&lt;/em&gt; method is called in Thread to make the thread wait for a timed duration.&lt;/p&gt;

&lt;p&gt;Finally, the thread is Terminated either due to the program execution being complete or any error occurred, causing the program to exit abruptly. For example, an unhandled exception occurred.&lt;/p&gt;

&lt;p&gt;There are two overloaded &lt;em&gt;sleep()&lt;/em&gt; methods in the &lt;em&gt;Thread&lt;/em&gt; class as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;sleep(long millis)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;sleep(long millis, int nanos)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Discover the ins and outs of&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/ux-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;UX testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;with this comprehensive guide. Explore various testing methods, tools, and best practices for measuring success&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  sleep(long millis)
&lt;/h3&gt;

&lt;p&gt;This method accepts one parameter (i.e., duration of time in milliseconds). It throws an &lt;em&gt;InterruptedException&lt;/em&gt; if any other thread interrupts the current thread.&lt;/p&gt;

&lt;p&gt;Another exception this method can throw is an &lt;em&gt;IllegalArgumentException&lt;/em&gt; when the value of milliseconds supplied in the parameter is negative or not in the range from &lt;em&gt;0–999999.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following code shows a simple implementation of how to use &lt;em&gt;Thread.sleep()&lt;/em&gt; to pause your automation tests for debugging purposes.&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.lang.Thread;

@Test
public void testThreadSleep() throws InterruptedException {
WebDriver driver = new ChromeDriver();
driver.get("https://ecommerce-playground.lambdatest.io/");

Thread.sleep(3000);
String title = driver.getTitle();

System.out.println(title);
driver.quit();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above snippet will create a new instance of &lt;em&gt;ChromeDriver&lt;/em&gt; and navigate to the LambdaTest eCommerce playground. It will halt the test execution using &lt;em&gt;Thread.sleep&lt;/em&gt; for 3 seconds(3000 milliseconds = 3 seconds). It will get the web page’s title and print it in the console. Finally, the &lt;em&gt;quit()&lt;/em&gt; method of Selenium is called to quit the driver instance gracefully.&lt;/p&gt;

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

&lt;p&gt;On executing the tests, the page title &lt;em&gt;“Your Store”&lt;/em&gt; gets printed in the console. The total time taken to execute the tests is &lt;code&gt;10 seconds 561 ms&lt;/code&gt;, which includes the &lt;code&gt;3000 milliseconds (3 seconds)&lt;/code&gt; of &lt;em&gt;Thread.sleep()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3FaLL9jT_EL7jLfn.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%2F800%2F0%2A3FaLL9jT_EL7jLfn.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  sleep(long millis, int nanos)
&lt;/h3&gt;

&lt;p&gt;This is an overloaded version of the &lt;em&gt;sleep()&lt;/em&gt; method we discussed in the earlier section of this blog on using &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java. It accepts two parameters, the first duration of time in milliseconds, and the second is the time in nanoseconds that is provided as additional time for the thread to sleep.&lt;/p&gt;

&lt;p&gt;It throws an &lt;em&gt;InterruptedException&lt;/em&gt; in case any other thread interrupts the current thread. &lt;em&gt;IllegalArgumentException&lt;/em&gt; is thrown when the values in any of the two parameters are provided as negative or are not in the range &lt;em&gt;0–999999.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following snippet shows a simple implementation of how to use &lt;em&gt;Thread.sleep()&lt;/em&gt; to pause your automation tests for debugging purposes.&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.lang.Thread;

@Test
public void testThreadSleep() throws InterruptedException {
WebDriver driver = new ChromeDriver();
driver.get("https://ecommerce-playground.lambdatest.io/");

Thread.sleep(3000);
String title = driver.getTitle();

System.out.println(title);
driver.quit();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above snippet creates a new instance of *ChromeDriver*and navigates to the eCommerce playground. The execution is halted for 3000 milliseconds and 2 nanoseconds.&lt;/p&gt;

&lt;p&gt;Next, it will fetch the current URL using Selenium’s &lt;em&gt;getCurrentUrl()&lt;/em&gt; method and print the URL’s text in the console. Finally, Selenium’s &lt;em&gt;quit()&lt;/em&gt; method will be called to quit the driver gracefully.&lt;/p&gt;

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

&lt;p&gt;Here is the screenshot from IntelliJ that shows the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&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%2F800%2F0%2A0lMxlIoiqTtr3GtW.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%2F800%2F0%2A0lMxlIoiqTtr3GtW.png" alt="image" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The total time taken to execute tests is &lt;code&gt;11 seconds 161 ms&lt;/code&gt;, including the time duration &lt;code&gt;(3000 milliseconds and 2000 nanoseconds)&lt;/code&gt; added in the &lt;em&gt;Thread.sleep()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Explore our comprehensive guide on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/gui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;GUI Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, uncovering its vital role in software development. Learn about its different types, best practices, and steps for effective implementation to enhance your software’s user interaction.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thread.sleep() example in a multi-threaded program
&lt;/h3&gt;

&lt;p&gt;In the previous examples, we used &lt;em&gt;Thread.sleep()&lt;/em&gt; in a single-threaded program, meaning only one thread was Running.&lt;/p&gt;

&lt;p&gt;Let’s see how &lt;em&gt;Thread.sleep()&lt;/em&gt; can be used in a multi-threaded program.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;FileName:&lt;/em&gt; &lt;a href="http://ThreadLocalExample.java" rel="noopener noreferrer"&gt;&lt;em&gt;ThreadLocalExample.java&lt;/em&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;public class ThreadLocalExample implements Runnable {

private final ThreadLocal&amp;lt;Integer&amp;gt; threadLocal = new ThreadLocal&amp;lt;Integer&amp;gt;();

@Override
public void run() {
final long startTime = System.currentTimeMillis();
this.threadLocal.set((int) (Math.random() * 40D));
try {
Thread.sleep(2000);

} catch (final InterruptedException e) {
throw new RuntimeException(e);

}
final long endTime = System.currentTimeMillis();
final NumberFormat formatter = new DecimalFormat("#0.00000");
System.out.println("Thread Id - " + this.threadLocal.get() + " Execution time is " + formatter.format((endTime - startTime) / 1000d) + " seconds" + "\n");
}

public static void main(final String[] args) {
final ThreadLocalExample threadLocalExample = new ThreadLocalExample();
final Thread t1 = new Thread(threadLocalExample);
final Thread t2 = new Thread(threadLocalExample);
t1.start();
t2.start();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;em&gt;ThreadLocalExample&lt;/em&gt; class implements a Runnable interface that helps execute the thread. Runnable interface’s &lt;em&gt;run()&lt;/em&gt; method is implemented in this class that sets the &lt;em&gt;ThreadLocal&lt;/em&gt; value and gets the program’s start and end time in milliseconds.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thread.sleep()&lt;/em&gt; blocks the thread for 2000 milliseconds (i.e., 2 seconds). Finally, the total time to run the program is printed in decimals.&lt;/p&gt;

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

&lt;p&gt;The following screenshot from IntelliJ shows that the total time to execute the program was &lt;code&gt;2.00500 seconds&lt;/code&gt;. This includes 2 seconds blocked by &lt;em&gt;Thread.sleep().&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Axc_1Gz8BOOmgrSDL.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%2F800%2F0%2Axc_1Gz8BOOmgrSDL.png" alt="image" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why is using Thread.sleep() discouraged?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/threadsleep-java-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;Thread.sleep()&lt;/em&gt;&lt;/a&gt; is a blocking call that halts the execution for some time and helps the automation tests to proceed successfully, with all the respective elements getting loaded for interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine putting &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java with 5 seconds stop time at 5 different places in the test. We are putting in &lt;em&gt;25 seconds&lt;/em&gt; of hard waits in the test.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thread.sleep()&lt;/em&gt; once set is set for the session’s lifetime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next problem we may face with &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java is that we might need to change the time duration if the time required for locating the element or performing action over the element keeps changing. For example, while running the test for the first time, the 3 seconds wait time worked fine with the &lt;em&gt;sleep()&lt;/em&gt; method to locate an element and perform a click on it. However, in the next run, tests failed, and the duration was required to increase to 5 seconds.&lt;/p&gt;

&lt;p&gt;This happens as fixed time duration is a flaky approach as locating elements also depends on external factors like rendering time, internet speeds, etc., some of which are not under our control. Flaky internet speeds can also cause the tests to fail even after adding &lt;em&gt;Thread.sleep().&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another problem is the repetitive code we would require to add by adding the &lt;em&gt;Thread.sleep()&lt;/em&gt; statement multiple times in the code. The statement must be applied before locating the web element or performing an action. In case multiple elements need some wait, we will have to add &lt;em&gt;Thread.sleep()&lt;/em&gt; statements multiple times in the code, and there will be a time when our code will be mostly covered with &lt;em&gt;Thread.sleep()&lt;/em&gt; statements.&lt;/p&gt;

&lt;p&gt;We can use Selenium’s Waits to overcome this problem of hard waits. In the next section of this blog on the &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java, let’s study different types of Selenium Waits and how to implement them in the tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Looking to manage your tests more efficiently? In this blog, explore a variety of&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/best-test-management-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;test case management&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tools and select the one that suits your team’s needs:&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium Waits
&lt;/h3&gt;

&lt;p&gt;Selenium Waits are the best replacement for &lt;em&gt;Thread.sleep()&lt;/em&gt; as they help execute the &lt;a href="https://www.lambdatest.com/automated-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automated UI tests&lt;/a&gt; seamlessly on the browser. The issues that may arise due to variations in time lag can be easily handled using Selenium Waits. There are three types of Waits in &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Implicit Wait&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explicit Wait&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fluent Wait&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Implicit Wait in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;Implicit wait is useful when certain elements on the web page are not available immediately and need some time to load. This wait polls the DOM for a certain duration as specified in the wait. By default, implicit wait is set to 0 and is disabled. Once set in tests, it is set for the session’s life.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;implicitlyWait()&lt;/em&gt; method is available in the &lt;em&gt;timeouts()&lt;/em&gt; interface in Selenium WebDriver. It accepts one parameter, that is, duration of time. This parameter can be supplied using the &lt;em&gt;Duration&lt;/em&gt; class from java.time package.&lt;/p&gt;

&lt;p&gt;Once implicit wait is set in the test, it is non-blocking and does not wait for the entire time duration like &lt;em&gt;Thread.sleep()&lt;/em&gt;. This saves 5 seconds, whereas &lt;em&gt;Thread.sleep()&lt;/em&gt; will halt the code execution in the current thread for a full 10 seconds and then only move to the next line.&lt;/p&gt;

&lt;p&gt;If the web element is not found in the time duration set for the implicit wait, &lt;em&gt;NoSuchElementException&lt;/em&gt; will be thrown. You can learn more about it through this blog on &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=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Common Selenium Exceptions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AWrzvrv-cf-eqWcR5.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%2F800%2F0%2AWrzvrv-cf-eqWcR5.png" alt="image" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example&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.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explicit Wait in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;Explicit wait allows the test to wait for a certain time until the expected condition as specified in wait is met. It is applied for a single web element to load, unlike implicit wait, which applies to all the elements on the web page.&lt;/p&gt;

&lt;p&gt;Applying explicit wait is non-blocking and does not wait for the entire session life cycle like &lt;em&gt;Thread.sleep()&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;When the expected condition is not met within the specified time, explicit wait throws &lt;em&gt;TimeoutException.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AqhJG5YQ_fJDpnHeK.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%2F800%2F0%2AqhJG5YQ_fJDpnHeK.png" alt="image" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For setting the explicit wait, we first need to instantiate the &lt;em&gt;WebDriverWait&lt;/em&gt; class. This class needs an instance of &lt;em&gt;WebDriver&lt;/em&gt; and time duration as constructor values. The &lt;em&gt;ExpectedConditions&lt;/em&gt; can be set next by using the &lt;em&gt;until()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;Here is the list of some commonly used &lt;em&gt;ExpectedConditions&lt;/em&gt; in explicit wait:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;Expected Condition&lt;/td&gt;
        &lt;td&gt;Description &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;visibilityOfElementLocated(By locator)&lt;/td&gt;
        &lt;td&gt;This condition checks that the element is present in the DOM and visible. This condition expects a By locator as a parameter for the method. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;visibilityOf(WebElement element)&lt;/td&gt;
        &lt;td&gt;This condition checks that the element is present in the DOM and is visible. It expects a WebElement as a parameter for the method. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;alertIsPresent()&lt;/td&gt;
        &lt;td&gt;This condition checks if the alert is present. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;elementToBeClickable(By locator)&lt;/td&gt;
        &lt;td&gt;This condition checks that the element is present and visible and can be clicked. It expects a By locator as a parameter for the method. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;elementToBeClickable(WebElement element)&lt;/td&gt;
        &lt;td&gt;This condition checks that the element is present, visible, and can be clicked. It expects a WebElement as a parameter for the method. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;presenceOfElementLocated(By locator)&lt;/td&gt;
        &lt;td&gt;This condition checks that the element is present on the page using its By locator. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;textToBePresentInElement(WebElement element, final String text)&lt;/td&gt;
        &lt;td&gt;This condition checks that the text is present in the WebElement. &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;textToBePresentInElementLocated(By locator, final String text)&lt;/td&gt;
        &lt;td&gt;This condition checks that the text in the WebElement matches the given locator.&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;You can learn more about it through this blog on &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=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;ExpectedConditions&lt;/em&gt; in Selenium&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The ultimate guide to &lt;a href="https://www.lambdatest.com/learning-hub/software-testing-metrics?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;software testing metrics&lt;/a&gt;: definition, types, and examples explained for informed decisions. Enhance your testing process now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Example&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;WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
WebElement checkoutBtn = driver().findElement(By.cssSelector("#check"));
wait.until(ExpectedConditions.visibilityOf(checkoutBtn));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the Checkout button on the web page is located using explicit wait. First, the &lt;em&gt;WebDriverWait&lt;/em&gt; class is instantiated, providing the driver instance and time duration for the explicit wait. Next, the Checkout button is located and stored as a &lt;em&gt;WebElement&lt;/em&gt;. Finally, the expected condition is written to wait until the Checkout button is visible.&lt;/p&gt;

&lt;p&gt;As per &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=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium’s best practice&lt;/a&gt;, it is recommended not to mix the implicit and explicit waits as it might lead to unpredictable wait times. For example, if an implicit wait of 10 seconds is&lt;/p&gt;

&lt;p&gt;provided and an explicit wait of 15 seconds is also used, it might cause a timeout to occur after 20 seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fluent Wait in Selenium WebDriver
&lt;/h3&gt;

&lt;p&gt;Fluent wait allows you to wait for a maximum amount of time for a condition. It also allows to add the following two additional parameters to wait for that are not allowed in implicit and explicit waits –&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Polling Frequency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ignore Exceptions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Polling Frequency&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It sets the frequency in which the condition should be checked. For example, the total timeout can be set for 10 seconds with a polling frequency of 2 seconds, i.e., the condition will be checked for 10 seconds in every 2 seconds frequency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ignore Exceptions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With fluent waits, we can also set it to ignore the exception that can appear while waiting for the condition. For example, the total timeout can be set to 10 seconds polling every 2 seconds and ignoring &lt;em&gt;“NoSuchElementException”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Note: If the fluent wait condition is not fulfilled within the specified time, it will throw TimeoutException.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A-33hN-uEhTH0HlZ7.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%2F800%2F0%2A-33hN-uEhTH0HlZ7.png" alt="image" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For setting fluent wait, we need to use the Wait interface and instantiate an instance of FluentWait class. After instantiating the FluentWait class, we can chain its following methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;withTimeout():&lt;/em&gt; Accepts the total time for which the wait needs to be implemented.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;pollingEvery():&lt;/em&gt; Accepts the polling frequency time duration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;ignoring():&lt;/em&gt; Provides the exception name, which the fluent wait needs to ignore while waiting for the condition to be fulfilled.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Code Example&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;public String successMessageText() {
Wait&amp;lt;WebDriver&amp;gt; wait = new FluentWait&amp;lt;&amp;gt;(driver)
.withTimeout(Duration.ofSeconds(10))
.pollingEvery(Duration.ofSeconds(2))
.ignoring(NoSuchElementException.class);


WebElement successMessage = wait.until(driver -&amp;gt; notificationPopUp().findElement(By.tagName("p")));
return successMessage.getText();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code example, a fluent wait has been implemented for 10 seconds that will be polling at a frequency of 2 seconds ignoring &lt;em&gt;NoSuchElementException.&lt;/em&gt; This fluent wait will be used for locating the &lt;em&gt;successMessage&lt;/em&gt; text from a web element, and finally, the text will be returned in String format.&lt;/p&gt;

&lt;p&gt;Let’s now delve into coding and check out how to use &lt;em&gt;Thread.Sleep()&lt;/em&gt; in Java. We will also check out how to use implicit, explicit, and fluent waits using Selenium WebDriver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This tutorial focuses on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/mobile-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;mobile ui testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its significance, benefits, strategies, challenges, and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use Thread.sleep(), Implicit Wait, Explicit Wait, and Fluent Waits?
&lt;/h3&gt;

&lt;p&gt;Before I take you on the tour of &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java and Selenium Waits, let’s first discuss the Application Under Test (AUT), the tools used, and the &lt;a href="https://www.lambdatest.com/blog/effective-test-automation-strategy/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation strategy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application Under Test:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use LambdaTest’s eCommerce playground to demo Thread.sleep() in Java and the different Selenium Waits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools/Language used for running tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Following tools/language has been used in writing and running the tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language: Java&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mobile App Automation Tool: Selenium WebDriver (Version 4.10.0)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner: &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt; (Version 7.8.0)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool: &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=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud Platform to run the tests: LambdaTest.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Launch the LambdaTest’s eCommerce playground.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Search for a product using the search box on the Home Screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the product page, hover the mouse on the product.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Add to Cart button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the Checkout button on the pop-up message displayed.&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%2F800%2F0%2AthBDtV3hzofC7Yvw.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%2F800%2F0%2AthBDtV3hzofC7Yvw.png" alt="image" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We must wait for the pop-up to appear and get the success message text. Next, we need to click on the Checkout button to checkout the product from the cart.&lt;/p&gt;

&lt;p&gt;In the demo, we will first use the &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java to pause the test execution and then will use the explicit and fluent waits to replace &lt;em&gt;Thread.sleep()&lt;/em&gt; and remove the hard waits from the test.&lt;/p&gt;

&lt;p&gt;Before we move to product checkout, we need to perform two steps: logging in to the website and searching for a product, and finally, adding the product to the cart.&lt;/p&gt;

&lt;p&gt;The following screen will be used to log in to the website.&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%2F800%2F0%2AMYlSn552pC7w4-QD.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%2F800%2F0%2AMYlSn552pC7w4-QD.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following screen will be used to search for the product.&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%2F800%2F0%2A9gX3P3RRs6ftI_As.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%2F800%2F0%2A9gX3P3RRs6ftI_As.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As this blog on &lt;a href="https://www.lambdatest.com/java-automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Java automation testing&lt;/a&gt; focuses more on &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java and Selenium Waits, I will provide a minimal explanation of the two steps, i.e., logging in to the website and searching for a product.&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%2F800%2F0%2AQSyBM__b7X41hAqF.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%2F800%2F0%2AQSyBM__b7X41hAqF.png" alt="image" width="382" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;The project has been created using Maven, and the following image shows the structure of the 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AypnYSlESmczmt1Yy.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%2F800%2F0%2AypnYSlESmczmt1Yy.png" alt="image" width="800" height="1188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the project is built, we need to add the dependencies for Selenium WebDriver and TestNG in the pom.xml. I preferably follow the best practice of including all the dependencies in the properties tab block in the pom.xml file. You can find out the details in the following screenshots:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dependencies in pom.xml&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AS3dX1OpKyaH0od_W.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%2F800%2F0%2AS3dX1OpKyaH0od_W.png" alt="image" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Properties block in pom.xml&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AwAx23CnNLPQrxvy8.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%2F800%2F0%2AwAx23CnNLPQrxvy8.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;FileName — pom.xml&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;
&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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;selenium-wait-demo&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
&amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

&amp;lt;name&amp;gt;selenium-wait-demo&amp;lt;/name&amp;gt;
&amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

&amp;lt;properties&amp;gt;
&amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
&amp;lt;selenium.java.version&amp;gt;4.10.0&amp;lt;/selenium.java.version&amp;gt;
&amp;lt;testng.version&amp;gt;7.8.0&amp;lt;/testng.version&amp;gt;
&amp;lt;maven.compiler.version&amp;gt;3.11.0&amp;lt;/maven.compiler.version&amp;gt;
&amp;lt;surefire-version&amp;gt;3.1.2&amp;lt;/surefire-version&amp;gt;
&amp;lt;java.release.version&amp;gt;17&amp;lt;/java.release.version&amp;gt;
&amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
&amp;lt;suite-xml&amp;gt;testng.xml&amp;lt;/suite-xml&amp;gt;
&amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;
&amp;lt;/properties&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;${selenium.java.version}&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;${testng.version}&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;build&amp;gt;
&amp;lt;plugins&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
&amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
&amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;plugin&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
&amp;lt;executions&amp;gt;
&amp;lt;execution&amp;gt;
&amp;lt;goals&amp;gt;
&amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
&amp;lt;/goals&amp;gt;
&amp;lt;/execution&amp;gt;
&amp;lt;/executions&amp;gt;
&amp;lt;configuration&amp;gt;
&amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
&amp;lt;properties&amp;gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&amp;lt;/properties&amp;gt;
&amp;lt;suiteXmlFiles&amp;gt;
&amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
&amp;lt;/suiteXmlFiles&amp;gt;
&amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
&amp;lt;/configuration&amp;gt;
&amp;lt;/plugin&amp;gt;
&amp;lt;/plugins&amp;gt;
&amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The tests will be run on the Google Chrome browser on LambdaTest’s Cloud grid using Windows 10 Operating System. To set the browser, OS, and its respective version, we can use the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Discover the ins and outs of&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/ux-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;UX testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;with this comprehensive guide. Explore various testing methods, tools, and best practices for measuring success&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A1p-fTN5xnmvm9YYh.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%2F800%2F0%2A1p-fTN5xnmvm9YYh.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Implicit Wait in Selenium
&lt;/h3&gt;

&lt;p&gt;Once we know what capabilities we need to set in the cloud, we will create a &lt;em&gt;DriverManager&lt;/em&gt; class that will help set up the browser in the cloud.&lt;/p&gt;

&lt;p&gt;Following is the code implementation of the &lt;em&gt;DriverManager&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;FileName — DriverManager.class&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;
public class DriverManager {

WebDriver driver;
private static final String LT_USERNAME = System.getProperty("LT_USERNAME");
private static final String LT_ACCESS_KEY = System.getProperty("LT_ACCESS_KEY");
private static final String GRID_URL = "@hub.lambdatest.com/wd/hub";

public void createChromeDriverInCloud() {
final ChromeOptions browserOptions = new ChromeOptions();
browserOptions.setPlatformName("Windows 10");
browserOptions.setBrowserVersion("114.0");
final HashMap&amp;lt;String, Object&amp;gt; ltOptions = new HashMap&amp;lt;&amp;gt;();
ltOptions.put("username", LT_USERNAME);
ltOptions.put("accessKey", LT_ACCESS_KEY);
ltOptions.put("resolution", "2560x1440");
ltOptions.put("selenium_version", "4.0.0");
ltOptions.put("build", "LambdaTest ECommerce Playground Build");
ltOptions.put("name", "LambdaTest ECommerce Playground Tests");
ltOptions.put("w3c", true);
ltOptions.put("plugin", "java-testNG");
browserOptions.setCapability("LT:Options", ltOptions);
try {
driver = new RemoteWebDriver(new URL(format("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)), browserOptions);
} catch (MalformedURLException e) {
throw new Error("RemoteDriver's URL not set correctly!");
}
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
}

public void createChromeDriverLocal() {
driver = new ChromeDriver();
}

public WebDriver getDriver() {
return this.driver;
}

public void quitDriver() {
driver.quit();
}
}
&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;The first two variables declared in the class will help us read LambdaTest’s cloud login credentials, i.e., Username and AccessKey, on runtime, as these are secret variables and can not be declared as hard-coded values in the code. These values will be set in the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method in &lt;em&gt;DriverManager&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AJLQdiZ3rF05Fzp-7.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%2F800%2F0%2AJLQdiZ3rF05Fzp-7.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method will create a new Chrome browser instance on LambdaTest Cloud Grid. After the driver is set, the implicit wait will be set for 10 seconds using the following statement in the above 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AJ0FHz_NN23ySsF-G.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%2F800%2F0%2AJ0FHz_NN23ySsF-G.png" alt="image" width="800" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing the Test Scenarios&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first scenario we need to implement is the Login Scenario. This will help you log in to the website and perform further actions of adding the product to the cart and checking out easily. The code snippet of the &lt;em&gt;testLogin()&lt;/em&gt; method is available in the &lt;em&gt;LambdaTestEcommerceTests&lt;/em&gt; class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/mfaisalkhatri/selenium-wait-demo/blob/main/src/test/java/io/github/mfaisalkhatri/tests/LambdaTestEcommerceTests.java" rel="noopener noreferrer"&gt;&lt;em&gt;LambdaTestEcommerceTests&lt;/em&gt;&lt;/a&gt; class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class LambdaTestEcommerceTests extends BaseTest{

@Test
public void testLogin() {
HomePage homePage = new HomePage(driverManager.getDriver());
homePage.navigateToLoginPage();
LoginPage loginPage = new LoginPage(driverManager.getDriver());
loginPage.login(System.getProperty("username"),System.getProperty("password"));
assertEquals(loginPage.getMyAccountPageHeader(),"My Account");
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;testLogin()&lt;/em&gt; method will help in navigating to the Login Page and allow performing the login to the LambdaTest eCommerce website. The Username and Password for login will be supplied on run time. Finally, assertions will be performed to check that the page header should be “My Account” after successful login.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Login link on Home Page&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Avp4NjDPa5t2A7GSG.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%2F800%2F0%2Avp4NjDPa5t2A7GSG.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Login Page&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A9efur-Zcz71clZc6.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%2F800%2F0%2A9efur-Zcz71clZc6.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Account Page after successful login&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AJvq5DQMaUMUity2K.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%2F800%2F0%2AJvq5DQMaUMUity2K.png" alt="image" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the code snippet from the &lt;em&gt;HomePage&lt;/em&gt; class that has all the Page Objects for Home Page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Explore our comprehensive guide on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/gui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;GUI Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, uncovering its vital role in software development. Learn about its different types, best practices, and steps for effective implementation to enhance your software’s user interaction.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model&lt;/a&gt; helps segregate the page objects with the actions, enabling easy code maintenance. It is a popular design pattern used in test automation to enhance the maintainability and reusability of test code, particularly in web-based applications. It achieves this by segregating the web elements on a page from the test actions 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;public class HomePage {
WebDriver driver;

public HomePage(WebDriver driver) {
this.driver = driver;
}

private WebElement searchField() {
return driver.findElement(By.name("search"));
}

private WebElement searchBtn() {
return driver.findElement(By.cssSelector("button[type='submit'][class='type-text']"));
}

public void searchProduct(String productName) {
searchField().clear();
searchField().sendKeys(productName);
searchBtn().click();
}

public String searchResultText() {
return driver.findElement(By.cssSelector("div.product-layout:nth-child(1) div:nth-child(1) h4 &amp;gt; a.text-ellipsis-2")).getText();
}

public void navigateToLoginPage() {
driver.findElement(By.linkText("My account"))
.click();
driver.findElement(By.linkText("Login")).click();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;BaseTest&lt;/em&gt; class is extended by &lt;em&gt;LambdaTestEcommerceTests&lt;/em&gt; class. The &lt;em&gt;BaseTest&lt;/em&gt; class has two methods, namely, &lt;em&gt;testSetup()&lt;/em&gt; and &lt;em&gt;tearDown()&lt;/em&gt;. The &lt;em&gt;testSetup()&lt;/em&gt; method helps instantiate the &lt;em&gt;DriverManager&lt;/em&gt; class and calls the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; to run the tests on the Chrome browser in the LambdaTest cloud grid. The &lt;em&gt;tearDown()&lt;/em&gt; method helps in gracefully quitting the WebDriver after the tests 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;public class BaseTest {

DriverManager driverManager;

@BeforeTest(alwaysRun = true)
public void testSetup() {
driverManager = new DriverManager();
driverManager.createChromeDriverInCloud();
driverManager.getDriver().get("https://ecommerce-playground.lambdatest.io/");
}

@AfterTest(alwaysRun = true)
public void tearDown() {
driverManager.quitDriver();
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next scenario is to search for a product from the Home Page after logging in to the website.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Search products from the Home Page&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ACCgMenVa1bxdeGG5.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%2F800%2F0%2ACCgMenVa1bxdeGG5.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Search results&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2As4nCA4dl33vDcsdv.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%2F800%2F0%2As4nCA4dl33vDcsdv.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following is the test to search for the product.&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 testSearchProduct() {
String productName = "Palm Treo Pro";
HomePage homePage = new HomePage(driverManager.getDriver());
homePage.searchProduct(productName);
assertEquals(homePage.searchResultText(), productName);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;“&lt;em&gt;Palm Treo Pro&lt;/em&gt;” is the product that will be searched from the website’s Home Page; after the results appear, the text will be asserted against it.&lt;/p&gt;

&lt;p&gt;The following method — &lt;em&gt;searchProduct()&lt;/em&gt; from the &lt;em&gt;HomePage&lt;/em&gt; class will help us search the product, and the &lt;em&gt;searchresultText()&lt;/em&gt; method will help us verify the search result text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Looking to manage your tests more efficiently? In this blog, explore a variety of&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/best-test-management-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;test case management&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tools and select the one that suits your team’s needs.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AkP8rv06RSeLfall8.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%2F800%2F0%2AkP8rv06RSeLfall8.png" alt="image" width="800" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, the add product to the cart step will be automated. To add products to the cart, we need to hover on the product and click on the “&lt;em&gt;add to cart&lt;/em&gt;” icon after the hovering toolbar appears.&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%2F800%2F0%2ASUOiO9DVF6hov9Se.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%2F800%2F0%2ASUOiO9DVF6hov9Se.png" alt="image" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, a pop-up message will appear showing the success message for adding the product to the cart with the Checkout button. We will be asserting the success message and clicking on the Checkout button.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Thread.sleep() in Selenium
&lt;/h3&gt;

&lt;p&gt;Below code is of the &lt;em&gt;testAddProductToCart()&lt;/em&gt; method that performs all the actions mentioned in the earlier paragraph.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;testAddProductToCart()&lt;/em&gt; in &lt;em&gt;LambdaTestEcommerceTests&lt;/em&gt; class&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 testAddProductToCart() {
ProductPage productPage = new ProductPage(driverManager.getDriver());
productPage.addPalmTreoCameraLensToCart();
final String expectedMessage = "{0}\n{1}\n{2}\n{3}\n{4}";
assertEquals(productPage.successMessageText(), format(expectedMessage, "Success: You have added", "Palm Treo Pro", "to your",
"shopping cart", "!"));
productPage.checkoutProduct();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;ProductPage&lt;/em&gt; class is created for storing the product page web elements and interacting with them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ProductPage {
WebDriver driver;

public ProductPage(WebDriver driver) {
this.driver = driver;
}

public void addPalmTreoCameraLensToCart() {
final Actions actions = new Actions(driver);
actions.moveToElement(palmTreoCameraLens())
.pause(200)
.moveToElement(addToCartBtn())
.pause(100)
.click()
.perform();
}

public void checkoutProduct() {
checkoutBtn().click();
}

public String successMessageText() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return notificationPopUp().findElement(By.tagName("p")).getText();
}

private WebElement addToCartBtn() {
return driver.findElement(By.cssSelector("div.product-action &amp;gt; button.btn.btn-cart.cart-29"));
}

private WebElement checkoutBtn() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return notificationPopUp().findElement(By.cssSelector("div.form-row &amp;gt; div:nth-child(2) &amp;gt; a"));
}

private WebElement notificationPopUp() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return driver.findElement(By.id("notification-box-top"));
}

private WebElement palmTreoCameraLens() {
return driver.findElement(By.cssSelector(".product-layout"));
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As mentioned earlier, we need to wait for the pop-up notification to appear. The following method &lt;em&gt;notificationPopUp()&lt;/em&gt; has &lt;em&gt;Thread.sleep()&lt;/em&gt; implemented, which pauses the test for 2 seconds to wait for the notification to appear. In this method, &lt;em&gt;try catch&lt;/em&gt; block is used for implementing &lt;em&gt;Thread.sleep()&lt;/em&gt; as it is more convenient and helps catch the run time exceptions. Once try catch is implemented, we don’t have to put the words throws &lt;em&gt;InterruptedException&lt;/em&gt; in every method that uses this &lt;em&gt;notificationPopUp()&lt;/em&gt; method, which has &lt;em&gt;Thread.sleep()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AR72INpAHdjPUpfj3.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%2F800%2F0%2AR72INpAHdjPUpfj3.png" alt="image" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Likewise, &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java is used in the &lt;em&gt;successMessageText()&lt;/em&gt; method as well, as we need to wait for a success message to appear to get its text.&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%2F800%2F0%2A80myATZ7sCUcx8mq.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%2F800%2F0%2A80myATZ7sCUcx8mq.png" alt="image" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java pauses the test for locating the Checkout button. Here is the code snippet for the &lt;em&gt;checkoutBtn()&lt;/em&gt; method that returns the web element for the checkout 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AzYAHrd_5dSh7FVAq.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%2F800%2F0%2AzYAHrd_5dSh7FVAq.png" alt="image" width="800" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Let’s execute the tests using &lt;em&gt;testng.xml&lt;/em&gt; by right-clicking on the file and selecting the option &lt;code&gt;Run ...\testng.xml&lt;/code&gt;. Here we are using the cloud testing platform, LambdaTest to execute the tests.&lt;/p&gt;

&lt;p&gt;LambdaTest is a digital experience cloud platform that lets you perform &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; at scale on over 3000+ real desktop and mobile browsers. Just like the &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java helps you pause test execution for a certain amount of time, running tests on a cloud-based grid will further improve the accuracy of your tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The ultimate guide to&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/software-testing-metrics?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;software testing metrics&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;: definition, types, and examples explained for informed decisions. Enhance your testing process now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Moreover, running your automated tests in parallel will cut down your test execution time, enabling faster &lt;a href="https://www.lambdatest.com/selenium-java-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium Java testing&lt;/a&gt; to ensure a quality web experience.&lt;/p&gt;

&lt;p&gt;To run tests on LambdaTest, we need to enter the following values to execute the tests successfully.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LambdaTest AccessKey&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Username of LambdaTest eCommerce Website&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Password of LambdaTest eCommerce Website&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Username and Password for LambdaTest’s eCommerce Website must be supplied for successfully logging in to the website.&lt;/p&gt;

&lt;p&gt;All the values can be supplied using the Edit configuration window and supplying the values as&lt;/p&gt;

&lt;p&gt;&lt;em&gt;-DLT_USERNAME=&amp;lt; LambdaTest Username&amp;gt; -DLT_ACCESS_KEY=&amp;lt; LambdaTest Access Key &amp;gt; -Dusername=&amp;lt; Website username for login scenario &amp;gt; -Dpassword=&amp;lt; Website password for login scenario &amp;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;&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="LambdaTest ecommerce playground website test suite "&amp;gt;
&amp;lt;test name="Search Product tests " &amp;gt;
&amp;lt;classes&amp;gt;
&amp;lt;class name="io.github.mfaisalkhatri.tests.LambdaTestEcommerceTests"&amp;gt;
&amp;lt;methods&amp;gt;
&amp;lt;include name="testLogin"/&amp;gt;
&amp;lt;include name="testSearchProduct"/&amp;gt;
&amp;lt;include name="testAddProductToCart"/&amp;gt;
&amp;lt;/methods&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;em&gt;Screenshot of the test run locally using TestNG in IntelliJ&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Au6xts-RrQ6rIIRIa.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%2F800%2F0%2Au6xts-RrQ6rIIRIa.png" alt="image" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The total time taken to run the tests can be seen as &lt;code&gt;37 Seconds and 307 ms&lt;/code&gt;, this includes the hard waits we have implemented using &lt;em&gt;Thread.sleep()&lt;/em&gt; in the tests.&lt;/p&gt;

&lt;p&gt;Let’s now check out how to replace the &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java with the explicit and fluent wait to take down the hard waits from the tests and save test execution time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Explicit Wait and Fluent Wait in Selenium
&lt;/h3&gt;

&lt;p&gt;There are three methods in the &lt;em&gt;ProductPage&lt;/em&gt; class, namely, &lt;em&gt;notificationPopUp()&lt;/em&gt;, &lt;em&gt;successMessageText()&lt;/em&gt;, and &lt;em&gt;checkoutBtn()&lt;/em&gt;, where we have used &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java for pausing the test execution. Hence, our tests run smoothly by locating and interacting with the web elements on the Product Page. The &lt;em&gt;Thread.sleep()&lt;/em&gt; statements in the code are commented out and have been kept to let us know that it was replaced with explicit and fluent waits in its place, so we know where the hard waits were replaced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;It is not a good practice to keep commented code in the class. Once the code refactoring is done, the commented code should be removed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replacing Thread.sleep() with Fluent Wait&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s use the fluent wait in the &lt;em&gt;successMessageText()&lt;/em&gt; method and replace it with &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;successMessageText()&lt;/em&gt; method in &lt;em&gt;ProductPage&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A6MzXPSlpw1moxd2n.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%2F800%2F0%2A6MzXPSlpw1moxd2n.png" alt="image" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fluent wait is defined for 10 seconds polling every 2 seconds ignoring &lt;em&gt;NoSuchElementException&lt;/em&gt;. So, if the element is located within 10 seconds, it will move to the next statement of code rather than waiting for a full timeout of 10 seconds to complete. This is the benefit of using Selenium Waits.&lt;/p&gt;

&lt;p&gt;Once the web element for &lt;em&gt;successMessage&lt;/em&gt; is located using the fluent wait condition. &lt;em&gt;successMessageText()&lt;/em&gt; method will return its text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;If the web element is not located within 10 seconds, the fluent wait will throw TimeoutException. The following screenshot shows the TimeoutException printed in the console in IntelliJ.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3KdrGuhKLsqghyzO.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%2F800%2F0%2A3KdrGuhKLsqghyzO.png" alt="image" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replacing Thread.sleep() with Explicit Wait&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is now time to refactor the &lt;em&gt;notificationPopup()&lt;/em&gt; method and &lt;em&gt;checkoutBtn()&lt;/em&gt; method by removing the &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java and replacing it with the explicit wait. As we will be using the explicit wait in two methods, it is better to declare it globally, instantiate it in the class’s constructor, and use it in the respective methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This tutorial focuses on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/mobile-ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;mobile ui testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;, its significance, benefits, strategies, challenges, and best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Declaring WebDriverWait&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AicFuRbgF90agdZm4.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%2F800%2F0%2AicFuRbgF90agdZm4.png" alt="image" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the instantiation of the &lt;em&gt;WebDriverWait&lt;/em&gt; class is done, we are good to use it in the &lt;em&gt;notificationPopUp()&lt;/em&gt; and &lt;em&gt;checkoutBtn()&lt;/em&gt; methods.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;notificationPopUp() method&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AtdKEwU5-mchBQ-PK.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%2F800%2F0%2AtdKEwU5-mchBQ-PK.png" alt="image" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using explicit wait, &lt;em&gt;ExpectedCondition&lt;/em&gt; — &lt;em&gt;visibilityOfElementLocated()&lt;/em&gt; using By locator is used in this method to wait for the notification box to appear.&lt;/p&gt;

&lt;p&gt;If the element is not located within the explicit wait timeout of 10 seconds, &lt;em&gt;TimeoutException&lt;/em&gt; will be thrown.&lt;/p&gt;

&lt;p&gt;The following screenshot shows the &lt;em&gt;TimeoutException&lt;/em&gt; printed in the console in IntelliJ.&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%2F800%2F0%2AL5Aam5h2cb48Yfmj.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%2F800%2F0%2AL5Aam5h2cb48Yfmj.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Coming to the &lt;em&gt;checkoutBtn()&lt;/em&gt; method, &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java has been replaced by using the &lt;em&gt;ExpectedCondition&lt;/em&gt; — &lt;em&gt;visibilityOf()&lt;/em&gt; method, where a web element is supplied in its parameter.&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%2F800%2F0%2AMJQ5d-GLVNFPPf42.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%2F800%2F0%2AMJQ5d-GLVNFPPf42.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before running the tests, let’s remove the implicit wait that we had added in the &lt;em&gt;createChromeDriverInCloud()&lt;/em&gt; method in &lt;em&gt;DriverManager&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AAHmvZczJVzPGQPGl.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%2F800%2F0%2AAHmvZczJVzPGQPGl.png" alt="image" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Let’s execute the tests using testng.xml by right-clicking on the file and selecting the option &lt;code&gt;Run ...\testng.xml&lt;/code&gt;. As discussed earlier, the following values can be supplied using the Edit configuration window.&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%2F800%2F0%2AnB3mAzEZ_r8UgMeD.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%2F800%2F0%2AnB3mAzEZ_r8UgMeD.png" alt="image" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Screenshot of the test run locally using TestNG in IntelliJ:&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%2F800%2F0%2ALilettKn7FVhEwwX.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%2F800%2F0%2ALilettKn7FVhEwwX.png" alt="image" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be seen that the test execution time has reduced to &lt;code&gt;24 seconds 707 ms.&lt;/code&gt; This shows that Selenium’s explicit and fluent waits are powerful and can help in bringing down the test execution time and also make the code more readable, maintainable, and less flaky.&lt;/p&gt;

&lt;p&gt;If you desire to excel in automation testing and improve your Java skills, enrolling in a &lt;a href="https://www.lambdatest.com/certifications/selenium-java-101" rel="noopener noreferrer"&gt;Selenium Java 101&lt;/a&gt; certification program is an excellent first step toward becoming an automation testing expert. This program will equip you with a robust understanding of using Selenium Java for testing and pave the way for a promising career in this field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Explore our in-depth guide comparing&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/protractor-vs-selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=jul_27&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Protractor vs Selenium&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to make informed decisions for your test automation needs. Gain valuable insights into the key differences, advantages, and ideal use cases of these widely-used testing frameworks.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Though &lt;em&gt;Thread.sleep()&lt;/em&gt; in Java can be used for pausing the test execution for a certain time, it is not a good option to use it in your automation tests as it is a kind of hard wait and can eat up most of the test execution time.&lt;/p&gt;

&lt;p&gt;Instead, &lt;em&gt;implicit&lt;/em&gt;, &lt;em&gt;explicit&lt;/em&gt;, and fluent waits in Selenium WebDriver can be used. These are more advanced waits and can help to pause the test for a certain time to find the locator/wait for the expected condition to be fulfilled and execute the rest of the code as soon as the element is found. It is recommended to refactor your code and use Selenium Waits wherever possible to save the test execution time and keep your tests less flaky.&lt;/p&gt;

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

</description>
    </item>
    <item>
      <title>GPS Geolocation vs IP Geolocation: How To Test Them On Real Devices?</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Mon, 29 May 2023 05:05:18 +0000</pubDate>
      <link>https://dev.to/testmuai/gps-geolocation-vs-ip-geolocation-how-to-test-them-on-real-devices-3jg9</link>
      <guid>https://dev.to/testmuai/gps-geolocation-vs-ip-geolocation-how-to-test-them-on-real-devices-3jg9</guid>
      <description>&lt;p&gt;In this era of technological advancements, the widespread adoption of Location Services in mobile phones has paved the way for eCommerce companies to offer personalized products and services through mobile apps.&lt;/p&gt;

&lt;p&gt;From showing personalized advertisements to delivering food to our doorstep, Location Services play a vital role and have become important in determining how the product reaches its customers.&lt;/p&gt;

&lt;p&gt;Location-based marketing has greatly impacted businesses by raising brand awareness and generating more income with low expenses. It also helps businesses reach specific customer segments with special offers and improve customer satisfaction.&lt;/p&gt;

&lt;p&gt;Using GPS geolocation and IP geolocation, businesses can target specific locations and increase the overall engagement for their products. Location-based marketing and advertisements can help convert prospective buyers to actual customers by targeting the local areas specifically. The targeted location marketing for a local product can provide relevant advertisements to the buyers and help defend their product against the marketing competition.&lt;/p&gt;

&lt;p&gt;Applications like Google Maps, Uber, DoorDash, etc. use GPS geolocations to know the real location of the user so they can serve them better and accurately show them the correct route, distance, time to travel, time for delivery, etc.&lt;/p&gt;

&lt;p&gt;To begin with, let’s first understand different types of Location terminologies. Two terms were re-used on a broader scale for identifying the Location.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;GPS Geolocation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IP Geolocation&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this blog, you will learn about GPS geolocation vs IP geolocation and the different related terms, and how to perform manual and &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; by changing GPS geolocation and IP geolocation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/exploratory-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Exploratory Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what Exploratory Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is GPS Geolocation?
&lt;/h3&gt;

&lt;p&gt;GPS geolocation is a general term that uses latitude, longitude, and altitude attributes to identify a user’s location. GPS geolocation can be captured using both programming and hardware. On web browsers, GPS geolocation is implemented through Geolocation API, written in JavaScript. This API always works on the client side of the application, like a web browser.&lt;/p&gt;

&lt;p&gt;In addition to the Geolocation API, modern smartphones are equipped with GPS receiver chipsets that enable the precise capture of geolocation data. These chipsets play a crucial role in accurately determining the location of smartphone users.&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%2F800%2F0%2AhKQZoH-2nObf79Ke.jpeg" 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%2F800%2F0%2AhKQZoH-2nObf79Ke.jpeg" alt="image" width="761" height="1600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;GPS Location — Google Maps shows the current location&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;GPS geolocation also provides more information related to the user’s current location like country, state, city, street, etc. The identification process involves utilizing geographic coordinates, such as latitude and longitude, obtained through GPS and leveraging these coordinates to pinpoint a precise location.&lt;/p&gt;

&lt;p&gt;By harnessing geolocation information, businesses can enhance Smart Navigation capabilities. For instance, they can update their store locations on platforms like Google Maps, enabling users to effortlessly locate and visit their physical stores, fostering convenience and seamless customer experiences.&lt;/p&gt;

&lt;p&gt;It can also be used for sending personalized advertisements or push notifications related to promotions or offers based on their location.&lt;/p&gt;

&lt;p&gt;The marketing team can also use this information to target potential buyers and convert them into actual customers by performing the data analysis based on geographical location.&lt;/p&gt;

&lt;p&gt;The following are the important technical terms used for &lt;a href="https://www.lambdatest.com/blog/how-to-test-geolocation/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;geolocation testing&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/ui-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;UI testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what UI testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Geotargeting
&lt;/h3&gt;

&lt;p&gt;IP addresses are the basis of geotargeting. The location of users can then be determined by comparing device IP addresses to factors like the user’s country of residence and postal code.&lt;/p&gt;

&lt;p&gt;It refers to serving the users with content and services based on their geographic location. Users may receive push notifications or in-app messages based on their location if they have opted to provide access to the location in the app.&lt;/p&gt;

&lt;p&gt;Personalization helps improve customer experience, which is the main advantage of geo-targeted marketing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases for Geotargeting&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;eCommerce&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Local news and weather&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Geofencing
&lt;/h3&gt;

&lt;p&gt;Geofencing is a process of establishing virtual boundaries for devices or products.&lt;/p&gt;

&lt;p&gt;It is a location-based service in which RFID (radio-frequency identification) tags, GPS, WiFi, or cellular data are used to track a device’s location near a virtual geographic boundary. Push notifications, automatic emails, text messages, or even targeted social media advertisements can be triggered when a device enters or leaves a Geofence.&lt;/p&gt;

&lt;p&gt;In the logistics industry, for example, it is used for security purposes. Hence, the goods/parcels reach their destinations safely with all necessary tracking notifications to the administrators of the service as well as to the end users.&lt;/p&gt;

&lt;p&gt;Likewise, it is also used by many fleet owners to track their vehicles and monitor if they are heading to the correct destinations. This is done as a precautionary measure to avoid theft of the vehicles.&lt;/p&gt;

&lt;p&gt;Geofencing is also helpful in keeping an eye on the kids. Some smartwatches and apps have this feature, which sends a notification to the parent if their kids move out of the geofence area. This helps parents in monitoring their kids easily and keeping them safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases for Geofencing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Google Maps&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Food Delivery (e.g., Zomato)&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Geotagging
&lt;/h3&gt;

&lt;p&gt;Geotagging adds geographical information to media, such as photos and videos. This information is typically included in the metadata of a media file and can include longitude and latitude coordinates, altitude, etc.&lt;/p&gt;

&lt;p&gt;It can be done manually or automatically, providing a great way to store and share location-based data.&lt;/p&gt;

&lt;p&gt;Examples include applications like &lt;em&gt;Facebook (check-ins)&lt;/em&gt; and &lt;em&gt;Instagram&lt;/em&gt;, where users can tag photos at the exact location. Also, search engines like Google use geolocation to search for the accurate image of the places searched for.&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%2F800%2F0%2Asa89MXGrD7GTNIxO.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%2F800%2F0%2Asa89MXGrD7GTNIxO.png" alt="image" width="500" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Facebook (Geotagging feature)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases for Geotagging&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Google Maps&lt;/strong&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AFhALae-ex4Ck9sr8.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%2F800%2F0%2AFhALae-ex4Ck9sr8.png" alt="image" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example of Geotagging — LambdaTest Office image&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A60lrq9YP4ft8H5cy.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%2F800%2F0%2A60lrq9YP4ft8H5cy.png" alt="image" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example of Geotagging — Microsoft Office image on Google Maps&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Geoblocking
&lt;/h3&gt;

&lt;p&gt;Geoblocking is the process of restricting access to certain websites and services based on geolocation.&lt;/p&gt;

&lt;p&gt;It is typically implemented by telecommunications companies, websites, and other content providers and intellectual proprietors, often for the sake of copyright restrictions. Geoblocking is done based on the IP address of the user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases for Geoblocking&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OTT Platforms&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Online Streaming&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/ad-hoc-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Ad hoc testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, let’s deep dive into what Ad hoc testing is, its advantages, disadvantages, types, characteristics, and their best practices.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Localization and Internationalization
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/internationalization-and-localization-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Localization and Internationalization&lt;/a&gt; are two factors that impact the overall user experience.&lt;/p&gt;

&lt;p&gt;Localization refers to adapting a product or service to meet the needs of a particular language, culture, or desired population’s “look and feel”. It helps personalize the product/ services to the native population of specific regions.&lt;/p&gt;

&lt;p&gt;On the other hand, internationalization refers to taking the local product to an international level. It is the process of designing a local product to meet users’ needs in many countries.&lt;/p&gt;

&lt;p&gt;For example, a website developed locally for Chinese regions may be designed so that it can be translated to English easily so people from international regions can access and use it.&lt;/p&gt;

&lt;p&gt;As the end users can get the product/services in their local language, it helps reach the audience through effective advertisement and product use. This allows Sales to gain business within the geographical region for which the application is developed and advertised.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases for Localization and Internationalization&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AztcBU8_jG7rRCxTy.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%2F800%2F0%2AztcBU8_jG7rRCxTy.png" alt="image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Netflix uses Localization for their website for the Brazilian region&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is IP Geolocation?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/importance-of-geolocation-browser-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;IP geolocation&lt;/a&gt; is the process of tracking the physical location of an IP address. It uses information gathered by IP address to determine the geographical location of a device on a map.&lt;/p&gt;

&lt;p&gt;This information can be used to restrict access to certain regions, improve security, track users’ activities, and customize content. IP geolocation can ideally be found using a website like &lt;a href="http://whatismyip.com" rel="noopener noreferrer"&gt;whatismyip.com&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference between GPS Geolocation and IP Geolocation
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;POINTERS&lt;/th&gt;
&lt;th&gt;GPS GEOLOCATION&lt;/th&gt;
&lt;th&gt;IP GEOLOCATION&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Technology&lt;/td&gt;
&lt;td&gt;GPS geolocation uses Global Positioning System (GPS) technology to determine the precise location of a device.&lt;/td&gt;
&lt;td&gt;IP geolocation uses the IP address of the device to determine its location.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Location Tracking Mechanism&lt;/td&gt;
&lt;td&gt;GPS geolocation uses a satellite-based navigation system to provide location information.&lt;/td&gt;
&lt;td&gt;IP geolocation uses an IP address, a unique numerical identifier assigned to every device connected to the internet, to provide location information.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td&gt;It uses a satellite-based navigation system(GPS), so it is more accurate than IP geolocation.&lt;/td&gt;
&lt;td&gt;It may be inaccurate as IP addresses can be shared and reassigned.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/data-driven-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Data driven testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, let us deep dive into what data driven testing is, its pros &amp;amp; cons, its types, data driven testing in an agile environment, benefits, and their best practices&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  How to perform GPS and IP Geolocation testing on Real Devices?
&lt;/h3&gt;

&lt;p&gt;In the earlier section of the blog, we discussed terms like Geotargeting, Geofencing, Geoblocking, Localization, etc. All these terms are quite important from the Business and Sales point of view. So, if we are considering any of these points from the mobile application or websites, we need to ensure that we perform thorough testing for the use cases before we proceed to release our mobile application/website to the market.&lt;/p&gt;

&lt;p&gt;Consider a mobile application whose major functionalities are based on the user’s current location. Hence, it is important to perform geolocation testing before the application is signed off for release.&lt;/p&gt;

&lt;p&gt;In one of my previous projects, we were working on testing a mobile application with scenarios related to Geofencing.&lt;/p&gt;

&lt;p&gt;This mobile application had the following critical Geofencing scenarios which required attention while testing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The Mobile application should show the end users Free Coupons for buying Coffee if the current location is in Spain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It should not show any Free Coupons to the user if the current location is not in Spain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the user’s current location is Germany, it should provide the user with a discount coupon (10–15% discount on the total price) to buy coffee.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As we all were working remotely, the ultimate problem we faced here was our QA team was neither in Spain nor Germany. We were all working remotely from India. Now, the question which came to everyone’s mind was, “How do we test these Geofencing features?”&lt;/p&gt;

&lt;p&gt;These were critical scenarios directly related to business and, if not tested well, may result in bugs related to the non-functional or mistargeted notifications and marketing services.&lt;/p&gt;

&lt;p&gt;This could lead to overall poor customer experiences, eventually bringing a decline in rating on the App and PlayStore and finally impacting the business.&lt;/p&gt;

&lt;p&gt;The GPS geolocation testing feature provided by the cloud platform in real devices came to our rescue. We mocked the GPS geolocations and performed all the testing seamlessly.&lt;/p&gt;

&lt;p&gt;Let’s move to the next section of this blog to perform the testing related to GPS geolocation and IP geolocation on the LambdaTest cloud platform.&lt;/p&gt;

&lt;p&gt;LambdaTest is a digital experience testing platform that offers a &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;real device cloud&lt;/a&gt; to run GPS and IP geolocation tests on 3000+ real browsers, devices, and operating systems. With the LambdaTest cloud testing platform, you can perform live interactive and automated &lt;a href="https://www.lambdatest.com/online-browser-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; on real mobile and desktop browsers running on real operating systems.&lt;/p&gt;

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

&lt;p&gt;You can also subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=video" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorial around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Run your&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/jest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Jest testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;automation tests in massive parallel across multiple browser and OS combinations with LambdaTest, Read more .&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing GPS Geolocation and IP Geolocation on Real Devices
&lt;/h3&gt;

&lt;p&gt;There are two ways in which we can perform GPS geolocation and IP geolocation testing on Real mobile devices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Manual Testing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automated testing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Manual Testing
&lt;/h4&gt;

&lt;p&gt;Testing manually is easy, but it requires more effort and is time-consuming. As the same tests need to be repeated as a part of &lt;a href="https://www.lambdatest.com/learning-hub/regression-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;regression tests&lt;/a&gt;, it becomes a tiresome task for the test engineer. Also, repeatedly mocking the location to create the actual scenario for performing location-based testing makes it tedious.&lt;/p&gt;

&lt;p&gt;While performing &lt;a href="https://www.lambdatest.com/learning-hub/manual-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;manual testing&lt;/a&gt;, chances are human error might also lead to bugs being released to the production environment.&lt;/p&gt;

&lt;p&gt;This is where &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; helps.&lt;/p&gt;

&lt;h4&gt;
  
  
  Automated Testing
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/mobile-automation-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Mobile automation testing&lt;/a&gt;, on the other hand, is the perfect solution for today’s world. It saves time and cost. Boring, tedious, and repeated tests can be automated and run as regression tests. It provides faster feedback in the builds leading to quick release time to market.&lt;/p&gt;

&lt;p&gt;Let’s now get into automated testing and write some tests for geolocation testing using &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Demonstration: Emulating GPS and IP Geolocation using Appium
&lt;/h3&gt;

&lt;p&gt;In this section, we will write automated tests for checking the GPS geolocation and IP geolocation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenarios&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we move towards writing automated tests, let’s first discuss the scenarios that will be considered for this demo.&lt;/p&gt;

&lt;p&gt;We will set mock GPS geolocation and IP geolocation on the LambdaTest cloud platform using the following Real mobile devices:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Samsung Galaxy S20 Plus&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Samsung Galaxy Note 20&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 1&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The GPS geolocation and IP geolocation values will be passed in automated tests using the Appium 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3kewDfpZqGxvjp-c.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%2F800%2F0%2A3kewDfpZqGxvjp-c.png" alt="image" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the GPS geolocation and IP geolocation are set, we will retrieve the latitude and longitude values in the test and compare them with the values we set using the desired capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, we will set the IP geolocation as &lt;em&gt;“United Kingdom&lt;/em&gt;” and verify the Country name is correctly displayed after opening the Chrome browser in the Real Device — &lt;em&gt;Samsung Galaxy Note 20&lt;/em&gt; and navigating to the &lt;a href="http://iplocation.com" rel="noopener noreferrer"&gt;iplocation.com&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;We will be expecting this website to show the Country as “&lt;em&gt;United Kingdom&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AUXw6RC0tYMPv_xwB.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%2F800%2F0%2AUXw6RC0tYMPv_xwB.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s move further to set up the project and implement the test scenarios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/xcuitest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;XCUITest&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, learn about XCUITest framework and its benefits for mobile automation testing. Take a look at how XCUITest works and see how to use it to test your mobile applications&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Setup and Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We first need to create a &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=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven Project&lt;/a&gt; and add the dependencies for &lt;a href="https://www.lambdatest.com/blog/appium-with-testng-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Appium Java Client and TestNG&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%2F800%2F0%2AlETASZpJCkRD59Zf.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%2F800%2F0%2AlETASZpJCkRD59Zf.png" alt="image" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is the best practice to update the versions of the dependencies in a separate &lt;strong&gt;properties block&lt;/strong&gt;. This helps in maintaining the versions easily in a single place.&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%2F800%2F0%2ATI0UBa4V5vvvfNqA.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%2F800%2F0%2ATI0UBa4V5vvvfNqA.png" alt="image" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s move ahead toward writing the automated tests now.&lt;/p&gt;

&lt;p&gt;As discussed in the test scenarios, we will be setting the GPS geolocation and IP geolocation using Appium’s Desired Capabilities. The easy way to do that is using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator&lt;/a&gt;. The Country, as well as the Longitude and Latitude, can be set using the Capabilities generator screen.&lt;/p&gt;

&lt;p&gt;LambdaTest’s Capabilities generator automatically generates the required code per the values selected in the UI for setting the capabilities using the W3C protocol. We just need to copy the code and paste it into the place where we will be setting the capabilities for the automated 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AcaAp7hZTvUzrOejB.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%2F800%2F0%2AcaAp7hZTvUzrOejB.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Setting the Language, Framework, Tool, and Real Device&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting the Geolocation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To open the Geolocation settings menu, click on the Real User Conditions link to expand the menu and view the Geolocation setting fields.&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%2F800%2F0%2AFR-qwFkLbnk9zogh.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%2F800%2F0%2AFR-qwFkLbnk9zogh.png" alt="image" width="709" height="672"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s set the IP geolocation to “&lt;em&gt;United Kingdom&lt;/em&gt;” and GPS Geolocation to “&lt;em&gt;United Kingdom&lt;/em&gt;” as well by setting the Latitude to “51.5072” and Longitude to “0.1276“.&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%2F800%2F0%2Aa6-GJOsd30_V5H3u.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%2F800%2F0%2Aa6-GJOsd30_V5H3u.png" alt="image" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we set the IP and the GPS geolocation, the capabilities generator automatically generates the required lines of code for setting the GPS and IP geolocation.&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%2F800%2F0%2AaBNIOgujhEp6mzLY.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%2F800%2F0%2AaBNIOgujhEp6mzLY.png" alt="image" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the same code we get from the capabilities generator, DesiredCapabilities can be set as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private DesiredCapabilities setCapabilities () {

   DesiredCapabilities capabilities = new DesiredCapabilities ();
   HashMap&amp;lt;String, Object&amp;gt; ltOptions = new HashMap&amp;lt;String, Object&amp;gt; ();
   ltOptions.put ("w3c", true);
   ltOptions.put ("build", buildName);
   ltOptions.put ("name", testName);
   ltOptions.put (MobileCapabilityType.PLATFORM_NAME, platform);
   ltOptions.put (MobileCapabilityType.PLATFORM_VERSION, platformVersion);
   ltOptions.put (MobileCapabilityType.DEVICE_NAME, deviceName);
   ltOptions.put (MobileCapabilityType.APP, app);
   ltOptions.put(MobileCapabilityType.BROWSER_NAME, "Chrome");
   ltOptions.put(MobileCapabilityType.BROWSER_VERSION, "107");
   ltOptions.put ("geoLocation", "GB");
   HashMap&amp;lt;String, String&amp;gt; locationObj = new HashMap&amp;lt;&amp;gt; ();
   locationObj.put ("lat", "51.5072");
   locationObj.put ("long", "0.1276");
   ltOptions.put ("location", locationObj);
   ltOptions.put ("isRealMobile", true);;
   ltOptions.put ("visual", true);
   ltOptions.put ("console", true);
   ltOptions.put ("devicelog", true);
   capabilities.setCapability ("lt:options", ltOptions);
   return capabilities;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code Walkthrough (Test Scenario 1)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is the test method; we will be asserting the latitude and longitude in this test.&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 getGeoLocationCoOrdinatesTest() {
   Location location = driverManager.getDriver().location();

   assertEquals(location.getLatitude(), 51.5072);
   assertEquals(location.getLongitude(), 0.1276);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Location class, originally belonging to &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt;, helps us in getting the Longitude and Latitude for the current location.&lt;/p&gt;

&lt;p&gt;Using this class’s &lt;em&gt;getLatitude()&lt;/em&gt; and &lt;em&gt;getLongitude()&lt;/em&gt; methods, we can get the Latitude and Longitude, respectively. These values can be used to assert the value that we had set in the capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough (Test Scenario 2)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before we move toward the test, let me show you the configuration part, which will help us run the test in the mobile browser.&lt;/p&gt;

&lt;p&gt;The following desired capabilities related to Browser Name and Browser Version will help open the Chrome mobile browser version 107 in the real mobile device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Mobile&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/mobile-emulator-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;emulators online&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;from LambdaTest allows you to seamlessly test your mobile applications, websites,and web apps on mobile browsers and mobile devices.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AiaDKkDoT-nRKvCSg.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%2F800%2F0%2AiaDKkDoT-nRKvCSg.png" alt="image" width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the code for verifying the test scenario 2 as discussed earlier.&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 testGeoLocation() {
 driverManager.getDriver().get(“https://iplocation.com/");
 IPLocationPage ipLocationPage = new IPLocationPage(driverManager);
 assertEquals(ipLocationPage.getCountryText(), “United Kingdom”);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this test, we navigate to the iplocation website in the mobile browser and check the value displayed for the Country field.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;IPLocationPage&lt;/em&gt; class is created to store all the page objects here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class IPLocationPage {

   private DriverManager driverManager;
   private WebDriverWait wait;

   public IPLocationPage(final DriverManager driverManager) {
       this.driverManager = driverManager;
       wait = new WebDriverWait(driverManager.getDriver(), Duration.ofSeconds(30));
   }

   public String getCountryText() {
       return wait.until(ExpectedConditions.visibilityOfElementLocated
               (By.cssSelector(".table &amp;gt; tbody &amp;gt; tr:nth-child(4) &amp;gt; td"))).getText();
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;getCountryText()&lt;/em&gt; method returns the text for the country field which is finally used in the test to assert with the country name &lt;em&gt;“United Kingdom”&lt;/em&gt;. Notice that the &lt;a href="https://www.lambdatest.com/blog/how-pro-testers-use-css-selectors-in-selenium-automation-scripts/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS Selector&lt;/a&gt; locator strategy is used here to locate the element for the country field. This is because we are locating the element on the browser in the mobile device. Hence all Selenium WebDriver related &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;locator strategies&lt;/a&gt; should work here.&lt;/p&gt;

&lt;p&gt;Let’s now run the test and demo the actual execution of the automation test scripts.&lt;/p&gt;

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

&lt;p&gt;There are two ways to run the tests&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Using &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using Maven&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using TestNG&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To run the tests using TestNG, a &lt;em&gt;testng.xml&lt;/em&gt; file is required to be created and by right-clicking on the file and selecting the option Run &lt;em&gt;‘…\testng.xml’&lt;/em&gt; the tests can be executed.&lt;/p&gt;

&lt;p&gt;testng.xml file used to execute the tests is given below. In the second test, the value for the app parameter is not given, as we need to run the tests on a mobile browser.&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="Lambda tests Mobile automation test suite" parallel="tests" thread-count="2" &amp;gt;
   &amp;lt;test name="Geolocation Automation Tests" &amp;gt;
       &amp;lt;parameter name="buildName" value="Android Build"/&amp;gt;
       &amp;lt;parameter name="testName" value="Lat and Long Geolocation tests"/&amp;gt;
       &amp;lt;parameter name="platformName" value="ANDROID"/&amp;gt;
       &amp;lt;parameter name="app" value="lt://APP10160531401673546544779159"/&amp;gt;
       &amp;lt;parameter name="version" value="11"/&amp;gt;
       &amp;lt;parameter name="device" value="Galaxy S20 Plus"/&amp;gt;
       &amp;lt;classes&amp;gt;
           &amp;lt;class name="io.github.mfaisalkhatri.mobileautomation.tests.AndroidTests"&amp;gt;
               &amp;lt;methods&amp;gt;
                   &amp;lt;include name="getGeoLocationCoOrdinatesTest"/&amp;gt;
               &amp;lt;/methods&amp;gt;
           &amp;lt;/class&amp;gt;
       &amp;lt;/classes&amp;gt;
   &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;
   &amp;lt;test name="IP Geolocation Automation Tests"&amp;gt;
       &amp;lt;parameter name="buildName" value="Android Build"/&amp;gt;
       &amp;lt;parameter name="testName" value="IP Geolocation tests"/&amp;gt;
       &amp;lt;parameter name="platformName" value="ANDROID"/&amp;gt;
       &amp;lt;parameter name="app" value=""/&amp;gt;
       &amp;lt;parameter name="version" value="11"/&amp;gt;
       &amp;lt;parameter name="device" value="Galaxy Note20"/&amp;gt;
       &amp;lt;classes&amp;gt;
           &amp;lt;class name="io.github.mfaisalkhatri.mobileautomation.tests.AndroidTests"&amp;gt;
               &amp;lt;methods&amp;gt;
                   &amp;lt;include name="testGeoLocation"/&amp;gt;
               &amp;lt;/methods&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;Here is the screenshot of the test run locally using IntelliJ IDE:&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%2F800%2F0%2Aca_eE7siJrTrucuK.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%2F800%2F0%2Aca_eE7siJrTrucuK.png" alt="image" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Maven&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To run the tests using Maven, run the following command on the terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mvn clean test -DLT_USERNAME=&amp;lt; LambdaTest Username &amp;gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;-DLT_ACCESS_KEY=&amp;lt; LambdaTest_Access_key &amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here is the screenshot of the test results after tests were run locally using terminal:&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%2F800%2F0%2AamWzWxYACgkygaIA.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%2F800%2F0%2AamWzWxYACgkygaIA.png" alt="image" width="800" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Demonstration: Testing GPS Geolocation and IP Geolocation manually on Cloud Grid
&lt;/h3&gt;

&lt;p&gt;To perform testing using LambdaTest, we first need to &lt;a href="https://accounts.lambdatest.com/register" rel="noopener noreferrer"&gt;Register/Sign&lt;/a&gt; up on the LambdaTest Platform. Once registration is successful, you can log in to your LambdaTest Account, which will land you on the Dashboard page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;New&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/selenium-ide-what-is-it-why-is-it-must-for-every-qa/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Selenium IDE&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;supports cross browser testing and parallel tests for automation along with record and replay function. Here’s why you shouldn’t miss out on it.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GPS Geolocation for App Testing in Real Device
&lt;/h3&gt;

&lt;p&gt;Using the LambdaTest Cloud platform’s Real Devices, we can mock the GPS geolocation and perform the &lt;a href="https://www.lambdatest.com/mobile-app-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile application testing&lt;/a&gt; as per our requirement.&lt;/p&gt;

&lt;p&gt;The steps below will help start with GPS geolocation testing of the mobile application.&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%2F800%2F0%2A6hfSk-af5uFKiKgK.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%2F800%2F0%2A6hfSk-af5uFKiKgK.png" alt="image" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Starting an Android Real Device Session
&lt;/h4&gt;

&lt;p&gt;On the left-hand panel, click on Real Device &amp;gt;&amp;gt; App 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ADYt4CYBSMla5qlsR.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%2F800%2F0%2ADYt4CYBSMla5qlsR.png" alt="image" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the App Testing screen, we can upload the mobile application using the &lt;em&gt;Upload&lt;/em&gt; button and select the Android or iOS device as required for testing from the list of multiple real devices for Android and iOS with different OS versions.&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%2F800%2F0%2AbojNqrDX0I2rj5Nh.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%2F800%2F0%2AbojNqrDX0I2rj5Nh.png" alt="image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s perform the testing on the Android Real Device using the &lt;em&gt;Google Maps&lt;/em&gt; application, which comes pre-installed on the Android Device.&lt;/p&gt;

&lt;p&gt;Let’s select &lt;em&gt;Samsung Galaxy S22 5G&lt;/em&gt; with &lt;em&gt;Android OS version 13&lt;/em&gt; and click on the &lt;em&gt;START&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3Fz-7KEOQ1QUjYXa.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%2F800%2F0%2A3Fz-7KEOQ1QUjYXa.png" alt="image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the &lt;em&gt;Proverbial App by LambdaTest&lt;/em&gt; is chosen as we need to provide one default application to load for mobile app testing.&lt;/p&gt;

&lt;p&gt;The following screen will be displayed once we click on the &lt;em&gt;START&lt;/em&gt; button to launch the real 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AKNU4xffrQFyF4ZeY.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%2F800%2F0%2AKNU4xffrQFyF4ZeY.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the device is ready with the default app, we should see the following screen loaded with the real device and the &lt;em&gt;Proverbial App&lt;/em&gt; launched by default.&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%2F800%2F0%2AUdZEGbCRPCq8-Yfe.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%2F800%2F0%2AUdZEGbCRPCq8-Yfe.png" alt="image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s click on the &lt;em&gt;Home&lt;/em&gt; button to load the Home Screen of the Real 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A2UnVgoeAb5WbCjDN.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%2F800%2F0%2A2UnVgoeAb5WbCjDN.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Home Screen is loaded, we should be able to see the following screen.&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%2F800%2F0%2A5GTlq1FjPwZGU95S.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%2F800%2F0%2A5GTlq1FjPwZGU95S.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s now open the &lt;em&gt;Google Maps&lt;/em&gt; application and check the current location displayed by default.&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%2F800%2F0%2A3EC-hwiypMW5qqlO.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%2F800%2F0%2A3EC-hwiypMW5qqlO.png" alt="image" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Manual GPS Geolocation Testing on Real Mobile Devices
&lt;/h4&gt;

&lt;p&gt;It shows the current location as &lt;em&gt;Dublin&lt;/em&gt;. Now, let’s change the Geolocation and set it to &lt;em&gt;Dubai&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To change the Geolocation, click on the &lt;em&gt;Geolocation&lt;/em&gt; button and click the &lt;em&gt;Set Location&lt;/em&gt; button as displayed in 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AIkmdGsfpwWzbrZye.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%2F800%2F0%2AIkmdGsfpwWzbrZye.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will open a new screen (check the screenshot below) to set the location. We can use the &lt;em&gt;latitude&lt;/em&gt; and &lt;em&gt;longitude&lt;/em&gt; of the location to mock or type the actual place name.&lt;br&gt;&lt;br&gt;
Here, we will type the location name as &lt;em&gt;DUBAI&lt;/em&gt; and click &lt;em&gt;Yes&lt;/em&gt; to confirm the location.&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%2F800%2F0%2Af9aDgncY76XMjuO0.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%2F800%2F0%2Af9aDgncY76XMjuO0.png" alt="image" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following confirmation message will be displayed on the screen.&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%2F800%2F0%2Aui8vOO3HApnz6wqJ.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%2F800%2F0%2Aui8vOO3HApnz6wqJ.png" alt="image" width="800" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s now check if the current location is updated as &lt;em&gt;DUBAI&lt;/em&gt; by reopening Google Maps and re-checking the current location.&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%2F800%2F0%2AtPehDM0MiS8t1QLd.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%2F800%2F0%2AtPehDM0MiS8t1QLd.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Geolocation was updated correctly as &lt;em&gt;DUBAI&lt;/em&gt;. We can perform all the testing of the scenarios as per the location set easily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;The same steps can be followed for iOS Real Devices, and GPS Location can be updated.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  IP Geolocation for App Testing in Real Device
&lt;/h3&gt;

&lt;p&gt;Using LambdaTest Cloud platform’s Real Devices, we can mock the IP geolocation and perform the mobile application testing as required.&lt;/p&gt;

&lt;p&gt;The steps below will help start with IP geolocation testing of the mobile application.&lt;/p&gt;

&lt;h4&gt;
  
  
  Starting an iOS Real Device Session
&lt;/h4&gt;

&lt;p&gt;On the left-hand panel, click on Real Device &amp;gt;&amp;gt; App 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3Jpub8IwPZjTzWhG.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%2F800%2F0%2A3Jpub8IwPZjTzWhG.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this demo, let’s use &lt;em&gt;iPhone 14 Pro Max&lt;/em&gt; Real Device with iOS 16 Version. For a demo, let’s use the &lt;em&gt;Proverbial App&lt;/em&gt; by LambdaTest &lt;em&gt;(Other Apps can also be uploaded using the UPLOAD button, Or we can provide the app URL from which it can be uploaded directly)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Once the selection is made for the App and Real Device, Click the &lt;em&gt;START&lt;/em&gt; button on the right-hand top of the screen.&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%2F800%2F0%2AkJpS7CM8olMkV-3A.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%2F800%2F0%2AkJpS7CM8olMkV-3A.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s click on the &lt;em&gt;GeoLocation&lt;/em&gt; button in the App to check out the current IP Location.&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%2F800%2F0%2AUPCI7GDLeGXh0SR_.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%2F800%2F0%2AUPCI7GDLeGXh0SR_.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will open the GeLocation window and show the current IP Geolocation as &lt;em&gt;Dublin&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AS6QcmOVyloup9RPt.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%2F800%2F0%2AS6QcmOVyloup9RPt.png" alt="image" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Manual IP Geolocation Testing on Real Mobile Devices
&lt;/h4&gt;

&lt;p&gt;Now, let’s change the IP Geolocation to some other country — &lt;em&gt;Canada&lt;/em&gt;. We can do this by clicking on the &lt;em&gt;Change Geolocation&lt;/em&gt; menu and selecting the required Country from the Country dropdown list.&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%2F800%2F0%2ASF-q1Ti6Ffocbe1b.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%2F800%2F0%2ASF-q1Ti6Ffocbe1b.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Country is selected, the message will be displayed on the top of the screen as &lt;em&gt;Updating Location&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AdwHx5g-ZXwTogD6c.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%2F800%2F0%2AdwHx5g-ZXwTogD6c.png" alt="image" width="800" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s now open the app again and click on the Geolocation button to verify that the IP location has been changed to &lt;em&gt;Canada&lt;/em&gt; correctly.&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%2F800%2F0%2AzqlE_v3Kr1iShfv6.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%2F800%2F0%2AzqlE_v3Kr1iShfv6.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we can see that the IP Geolocation has been changed to &lt;em&gt;Canada&lt;/em&gt; now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;The same steps can be followed for Android Real Devices, and IP GeoLocation can be changed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Automated&lt;/em&gt;&lt;/strong&gt; &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=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Functional Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tests helps to ensure that your web app works as it was intented to. Learn more about functional tests, and how automating them can give you a faster release cycle!&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;GPS Geolocation and IP Geolocation are important factors in testing location-based &lt;a href="https://www.lambdatest.com/blog/designing-and-conducting-digital-experience-testing-for-mobile-applications/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;mobile applications&lt;/a&gt; and websites. Multiple important technology terms include Geotargeting, Geotagging, Geofencing, Geoblocking, and Localization.&lt;/p&gt;

&lt;p&gt;In this blog, we went through a detailed demo of performing geolocation testing on Real Devices using the LambdaTest Cloud Platform with Appium. We can also use the Real Mobile devices from the LambdaTest Cloud Platform and set mock locations to perform &lt;a href="https://www.lambdatest.com/learning-hub/sanity-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=may_29&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;sanity testing&lt;/a&gt; manually on websites and mobile applications.&lt;/p&gt;

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

</description>
      <category>geolocation</category>
      <category>gps</category>
      <category>realdevices</category>
      <category>automationtesting</category>
    </item>
    <item>
      <title>How To Automate ServiceNow With Selenium</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Mon, 13 Mar 2023 10:20:54 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-automate-servicenow-with-selenium-1al6</link>
      <guid>https://dev.to/testmuai/how-to-automate-servicenow-with-selenium-1al6</guid>
      <description>&lt;p&gt;As businesses grow, there is a need to digitize the processes as manual work becomes tedious. For example, a company with 5000+ employees must digitize its IT department for different works like Asset management, IT Operations, queries related to software, managing the Software licenses, etc.&lt;/p&gt;

&lt;p&gt;ServiceNow, a cloud platform, provides service, operations, and business management solutions that organizations use to manage their digital workflows and streamline their business processes.&lt;/p&gt;

&lt;p&gt;When it comes to testing ServiceNow, &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; is a popular choice among organizations. Selenium is a widely used open-source &lt;a href="https://www.lambdatest.com/blog/automation-testing-frameworks/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing framework&lt;/a&gt; that can be used to test ServiceNow workflows and ensure a high-quality user experience.&lt;/p&gt;

&lt;p&gt;In this blog, we will learn how to test ServiceNow using Selenium WebDriver to ensure the workflows and applications are working as expected, ultimately improving the overall efficiency and quality of the testing process.&lt;/p&gt;

&lt;p&gt;So, let’s get started!&lt;/p&gt;

&lt;h3&gt;
  
  
  What is ServiceNow?
&lt;/h3&gt;

&lt;p&gt;ServiceNow offers a platform for a fast‑changing world. It is a cloud-based platform that helps to manage your day-to-day operations and plays an important role in enhancing the digital experience for users. The platform provides a wide range of tools and capabilities that can help organizations to improve their digital workflows, automate and optimize processes, and enhance communication and collaboration. ServiceNow helps digitize and unify organizations to find smarter, faster, better ways to make work flow.&lt;/p&gt;

&lt;p&gt;Here are some of the figures from the QA 2022 and FY 2022 regarding ServiceNow business:&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%2F800%2F0%2AohCYfWgmbfhzaFLO.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%2F800%2F0%2AohCYfWgmbfhzaFLO.png" alt="image" width="759" height="494"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Discover the top 45 essential&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/vercel-test-case-template?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Vercel test&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;cases along with its importance, types and usage for better understanding.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Now Platforms
&lt;/h3&gt;

&lt;p&gt;Now Platform helps digitize your entire business by optimizing the processes and creating values on a single unifying platform. Check out the different Now Platforms provided 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AaYM7rKL-ScTsk_Br.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%2F800%2F0%2AaYM7rKL-ScTsk_Br.png" alt="image" width="783" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source&lt;/p&gt;

&lt;h3&gt;
  
  
  Tokyo Release
&lt;/h3&gt;

&lt;p&gt;ServiceNow releases are scheduled two times per year. That latest Tokyo release was done in Q4 of 2022. ServiceNow’s next release, Utah, is planned for Q2 2023. Check out the features from Tokyo General Availability release highlights.&lt;/p&gt;

&lt;p&gt;As per the report, ServiceNow Inc improved its market share to approximately 0.79 % due to strong revenue growth of 20.12% overall.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is ATF (Automated Test Framework)?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/servicenow-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;ServiceNow testing&lt;/a&gt; is performed on supported ServiceNow applications to ensure that the product is free from bugs and all the desired functionalities are working as per the business requirements.&lt;/p&gt;

&lt;p&gt;ServiceNow has an Automated Test Framework for testing the ServiceNow applications. Automated Test Framework is an out-of-the-box test framework developed by ServiceNow. It helps test the functionalities in ServiceNow, allowing you to create and run automated tests on your ServiceNow instances (Production &amp;amp; Non-Production).&lt;/p&gt;

&lt;p&gt;This is done using the special ATF plugin that aids in accessing the application. It is intended to test the changes you make to your instance and not the ServiceNow functionality.&lt;/p&gt;

&lt;p&gt;Using ATF, we can verify and validate application functionalities, test end-to-end scenarios, server-side scripting tests, configurations, customizations, and many more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shortcomings of ATF
&lt;/h3&gt;

&lt;p&gt;While the ATF of ServiceNow provides many benefits to organizations to test their digital workflows and applications, there are some potential drawbacks to consider, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ATF tests ServiceNow workflows in local browsers, but advanced testing requires external &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing tools&lt;/a&gt;. ATF is primarily designed for form testing and might not be suitable for testing other modules, such as testing notifications or service portals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ATF also requires monitoring of the tests that are run.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ATF may require manual intervention to run the next tests in succession instead of running the tests automatically once the current test is completed. This is where open-source frameworks like Selenium can be extremely useful for extensively testing the front-end components.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to test ServiceNow using Selenium WebDriver?
&lt;/h3&gt;

&lt;p&gt;After discussing ATF and its drawback, let’s consider &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; for testing ServiceNow’s Demo Developer instance website, as Selenium has all the required features for &lt;a href="https://www.lambdatest.com/blog/website-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;website testing.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Application Under Test (ServiceNow Instance)
&lt;/h3&gt;

&lt;p&gt;ServiceNow’s Demo Developer instance is used for executing the tests (Tokyo Release). You can create the instance by following the below steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sign up on the ServiceNow website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you fill out the form, select the required options displayed after signing up. You should receive an email with the instance link, username, and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can log in and perform the testing using this link and its credentials.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;ServiceNow’s Demo Developer Instance — Login Page&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ADp1j8YEasLrSxSim.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%2F800%2F0%2ADp1j8YEasLrSxSim.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Incident Creation Page&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AhXO5LKsSnKNPFG4q.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%2F800%2F0%2AhXO5LKsSnKNPFG4q.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Incident List Page&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AgTqlF68sIuIPxLGX.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%2F800%2F0%2AgTqlF68sIuIPxLGX.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As per the ServiceNow documentation, the instance hibernates after 10 hours, and refreshing it is required by logging into your ServiceNow account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started with ServiceNow testing
&lt;/h3&gt;

&lt;p&gt;Following tools/language has been used in writing and running the tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language: Java&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Automation Tool: Selenium WebDriver (Version 4.8.0)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner: &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool: &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=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud Platform to run the tests: &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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;p&gt;&lt;strong&gt;&lt;em&gt;Learn 37 excellent&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/wix-test-case-templates?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Wix test cases&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;for testing websites by reading this guide. Every significant test case will be covered in detail in this guide, along with how to set up your Wix website testing.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Scenarios
&lt;/h3&gt;

&lt;p&gt;We will target the New Incident Creation page and the Incident List page for automation. However, before we move on to those screens, we need to login into the developer instance. Hence our first scenario will be to automate the Login Screen.&lt;/p&gt;

&lt;p&gt;The developer instance link will be different for different users as it is assigned by ServiceNow. It is not a common demo website that can be used by all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/automate-login-page-using-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Automate the login page&lt;/a&gt; by entering the username and password and clicking the Log in 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A40RiZhOI93t3QMxw.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%2F800%2F0%2A40RiZhOI93t3QMxw.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to the New &lt;em&gt;Incident&lt;/em&gt; page, and verify the header on the page to validate that we are on the right page before we start creating a new incident. Enter valid values in the &lt;em&gt;Caller Name, Channel,&lt;/em&gt; select &lt;em&gt;Service&lt;/em&gt; and finally, click on the Submit button to create a new incident.&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%2F800%2F0%2AnGXmkR36wiSEBrTP.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%2F800%2F0%2AnGXmkR36wiSEBrTP.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the new incident is created, it is displayed on the &lt;em&gt;Incident List&lt;/em&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The third scenario will be to navigate to the &lt;em&gt;Incident List page&lt;/em&gt; and verify the values displayed on the first row, checking that whatever values were entered at the time of the creation of the new incident are displayed correctly here.&lt;/p&gt;

&lt;p&gt;In case you are wondering how to write effective test cases for your test scenarios, you can refer to this tutorial on the &lt;a href="https://www.lambdatest.com/learning-hub/servicenow-test-case-template?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;ServiceNow test case template.&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%2F800%2F0%2AZilL65maynaT7H1q.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%2F800%2F0%2AZilL65maynaT7H1q.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;As discussed earlier, this project has been created using &lt;em&gt;Maven&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Project Structure and Packages&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Ah3Lj7C3NF77ZIZb-.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%2F800%2F0%2Ah3Lj7C3NF77ZIZb-.png" alt="image" width="343" height="629"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Discover the top 90+ essential&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/shopify-test-case-template?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Shopify test&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;cases to ensure your store’s functionality, performance, and customer experience. Download our comprehensive template now.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;TestNG&lt;/em&gt; is used as a test runner. Once the project is created, we need to add the dependency for &lt;em&gt;Selenium WebDriver&lt;/em&gt; and &lt;em&gt;TestNG&lt;/em&gt; in the &lt;code&gt;pom.xml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Dependencies in pom.xml&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AUVfZUUlg3yj4BVT_.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%2F800%2F0%2AUVfZUUlg3yj4BVT_.png" alt="image" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Versions of the dependencies are set in a separate &lt;em&gt;properties block&lt;/em&gt;. This is done for easy maintainability. So, if you need to update the versions, you can do it easily without searching throughout the &lt;em&gt;pom.xml file&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Properties block in pom.xml&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ACc4xe1mIXS_KB0rd.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%2F800%2F0%2ACc4xe1mIXS_KB0rd.png" alt="image" width="800" height="413"&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;&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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
   &amp;lt;artifactId&amp;gt;servicenow-selenium-testing&amp;lt;/artifactId&amp;gt;
   &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
   &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

   &amp;lt;name&amp;gt;servicenow-selenium-testing&amp;lt;/name&amp;gt;
   &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

   &amp;lt;properties&amp;gt;
       &amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
       &amp;lt;selenium.java.version&amp;gt;4.8.0&amp;lt;/selenium.java.version&amp;gt;
       &amp;lt;testng.version&amp;gt;7.7.1&amp;lt;/testng.version&amp;gt;
       &amp;lt;lombok.version&amp;gt;1.18.24&amp;lt;/lombok.version&amp;gt;
       &amp;lt;maven.compiler.version&amp;gt;3.10.1&amp;lt;/maven.compiler.version&amp;gt;
       &amp;lt;surefire-version&amp;gt;3.0.0-M8&amp;lt;/surefire-version&amp;gt;
       &amp;lt;java.release.version&amp;gt;15&amp;lt;/java.release.version&amp;gt;
       &amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
       &amp;lt;suite-xml&amp;gt;testng.xml&amp;lt;/suite-xml&amp;gt;
       &amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;
   &amp;lt;/properties&amp;gt;

   &amp;lt;dependencies&amp;gt;
       &amp;lt;!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --&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;${selenium.java.version}&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;${testng.version}&amp;lt;/version&amp;gt;
           &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
       &amp;lt;/dependency&amp;gt;
       &amp;lt;!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --&amp;gt;
       &amp;lt;dependency&amp;gt;
           &amp;lt;groupId&amp;gt;org.projectlombok&amp;lt;/groupId&amp;gt;
           &amp;lt;artifactId&amp;gt;lombok&amp;lt;/artifactId&amp;gt;
           &amp;lt;version&amp;gt;${lombok.version}&amp;lt;/version&amp;gt;
           &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
       &amp;lt;/dependency&amp;gt;
   &amp;lt;/dependencies&amp;gt;

   &amp;lt;build&amp;gt;
       &amp;lt;plugins&amp;gt;
           &amp;lt;plugin&amp;gt;
               &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
               &amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
               &amp;lt;configuration&amp;gt;
                   &amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
                   &amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
                   &amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
               &amp;lt;/configuration&amp;gt;
           &amp;lt;/plugin&amp;gt;
           &amp;lt;plugin&amp;gt;
               &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
               &amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
               &amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
               &amp;lt;executions&amp;gt;
                   &amp;lt;execution&amp;gt;
                       &amp;lt;goals&amp;gt;
                           &amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
                       &amp;lt;/goals&amp;gt;
                   &amp;lt;/execution&amp;gt;
               &amp;lt;/executions&amp;gt;
               &amp;lt;configuration&amp;gt;
                   &amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
                   &amp;lt;properties&amp;gt;
                       &amp;lt;property&amp;gt;
                           &amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
                           &amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
                       &amp;lt;/property&amp;gt;
                   &amp;lt;/properties&amp;gt;
                   &amp;lt;suiteXmlFiles&amp;gt;
                       &amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
                   &amp;lt;/suiteXmlFiles&amp;gt;
                   &amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
               &amp;lt;/configuration&amp;gt;
           &amp;lt;/plugin&amp;gt;
       &amp;lt;/plugins&amp;gt;
   &amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first step is to create a DriverManager class, which will be used to start the specific driver for the required browser.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1603288996011945985-114" src="https://platform.twitter.com/embed/Tweet.html?id=1603288996011945985"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1603288996011945985-114');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1603288996011945985&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Configuration (DriverManager class)&lt;/em&gt;&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;public class DriverManager {


    private static final ThreadLocal&amp;lt;WebDriver&amp;gt; DRIVER        = new ThreadLocal&amp;lt;&amp;gt; ();
    private static final String                 GRID_URL      = "@hub.lambdatest.com/wd/hub";
    private static final String                 LT_ACCESS_KEY = System.getProperty ("LT_ACCESS_KEY");
    private static final String                 LT_USERNAME   = System.getProperty ("LT_USERNAME");


    public static void createDriver (final Browsers browser) {
        switch (browser) {
            case REMOTE_FIREFOX:
                setupFirefoxInCloud ();
                break;
            case REMOTE_CHROME:
            default:
                setupChromeInCloud ();
        }
        setupBrowserTimeouts ();
    }


    public static WebDriver getDriver () {
        return DriverManager.DRIVER.get ();
    }


    public static void quitDriver () {
        if (null != DRIVER.get ()) {
            getDriver ().quit ();
            DRIVER.remove ();
        }
    }


    private static void setDriver (final WebDriver driver) {
        DriverManager.DRIVER.set (driver);
    }


    private static void setupBrowserTimeouts () {
        getDriver ().manage ()
            .timeouts ()
            .implicitlyWait (Duration.ofSeconds (30));
        getDriver ().manage ()
            .timeouts ()
            .pageLoadTimeout (Duration.ofSeconds (30));
        getDriver ().manage ()
            .timeouts ()
            .scriptTimeout (Duration.ofSeconds (30));
    }


    private static void setupChromeInCloud () {
        final ChromeOptions browserOptions = new ChromeOptions ();
        browserOptions.setPlatformName ("Windows 10");
        browserOptions.setBrowserVersion ("108.0");
        browserOptions.setCapability ("LT:Options", ltOptions ());
        try {
            setDriver (
                new RemoteWebDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)),
                    browserOptions));
        } catch (final MalformedURLException e) {
            System.out.print ("Error setting up cloud browser in LambdaTest " + e);
        }


    }


    private static void setupFirefoxInCloud () {
        final FirefoxOptions browserOptions = new FirefoxOptions ();
        browserOptions.setPlatformName ("Windows 10");
        browserOptions.setBrowserVersion ("108.0");
        browserOptions.setCapability ("LT:Options", ltOptions ());
        try {
            setDriver (
                new RemoteWebDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)),
                    browserOptions));
        } catch (final MalformedURLException e) {
            System.out.println ("Error setting up firefox  browser in LambdaTest " + e);
        }
    }


    private static HashMap&amp;lt;String, Object&amp;gt; ltOptions () {
        final HashMap&amp;lt;String, Object&amp;gt; ltOptions = new HashMap&amp;lt;&amp;gt; ();
        ltOptions.put ("username", LT_USERNAME);
        ltOptions.put ("accessKey", LT_ACCESS_KEY);
        ltOptions.put ("resolution", "2560x1440");
        ltOptions.put ("selenium_version", "4.0.0");
        ltOptions.put ("build", "ServiceNow Build");
        ltOptions.put ("name", "ServiceNow Tests");
        ltOptions.put ("w3c", true);
        ltOptions.put ("plugin", "java-testNG");
        return ltOptions;
    }


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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Code Walkthrough
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Static Variables in the DriverManager class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ThreadLocal&lt;/em&gt; class is used here for setting the drivers as it is thread-safe and works very well when tests are run in parallel. The main reason behind using ThreadLocal is that two threads run in isolated ways.ThreadLocal variables, even if two threads set different values on the same ThreadLocal object.&lt;/p&gt;

&lt;p&gt;Next is the &lt;em&gt;GRID_URL&lt;/em&gt;, which must be set for running tests on the LambdaTest platform. Similarly, &lt;em&gt;LT_USERNAME&lt;/em&gt; and &lt;em&gt;LT_ACCESS_KEY&lt;/em&gt; are required to authenticate and start new sessions on the LambdaTest platform. You can set these capabilities from the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cloud testing platforms like LambdaTest allow you to perform &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cross browser testing&lt;/a&gt; at scale over an &lt;a href="https://www.lambdatest.com/online-browser-farm?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;online browser farm&lt;/a&gt; of 3000+ browsers and operating systems. It offers a &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cloud Selenium grid&lt;/a&gt;, using which you can automate testing ServiceNow workflows to ensure a high-quality user experience.&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;&lt;strong&gt;&lt;em&gt;Testing a&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/site-generator-test-cases?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;site generator test cases&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;website is crucial as it ensures the generated code is error-free &amp;amp; adheres to industry standards, providing a seamless user experience.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorial around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; automation testing, and more.&lt;/p&gt;

&lt;p&gt;Coming back to the LambdaTest Capabilities Generator, it helps you to generate desired capabilities for your Selenium tests in a set of key-value pairs that define the desired behavior of the browser or device under tests, such as browser name, version, platform, screen resolution, and more.&lt;/p&gt;

&lt;p&gt;The parameter &lt;code&gt;Browsers&lt;/code&gt; used in the &lt;code&gt;createDriver()&lt;/code&gt; method is an enum &lt;em&gt;(An enum type is a special data type that enables a variable to be a set of predefined constants)&lt;/em&gt;, which is used to declare the Browser names on which we are planning to run the tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Configuration (Browsers(enum)&lt;/em&gt;&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;@Getter
public enum Browsers {


    REMOTE_FIREFOX,
    /**
     * LambdaTest Chrome browser.
     */
    REMOTE_CHROME


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

&lt;/div&gt;



&lt;p&gt;Notice the @Getter annotation above enum is imported from Lombok dependency and has to set the Getters for the variables set inside the enum on runtime, helping us to save time and effort by not writing the code for Getter methods inside this class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting the Chrome and Firefox drivers in Cloud&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next important methods to note are &lt;code&gt;setupChromeInCloud()&lt;/code&gt; and &lt;code&gt;setupFirefoxInCloud()&lt;/code&gt;. These methods help set up Chrome and Firefox browsers in the LamdaTest cloud platform and help run the tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;setupChromeInCloud() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A36pXbeDnwXhoh973.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%2F800%2F0%2A36pXbeDnwXhoh973.png" alt="image" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;setupFirefoxInCloud() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A4Bscy6MojdX_69uQ.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%2F800%2F0%2A4Bscy6MojdX_69uQ.png" alt="image" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These methods have one thing in common — ltOptions, which are required to set the Configurations related to LambdaTest platforms in W3C format since &lt;a href="https://www.lambdatest.com/blog/selenium4-w3c-webdriver-protocol/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium 4 is W3C compliant&lt;/a&gt;. As both methods for setting up browsers need these ltOptions, a common method ltOptions() is created to set the respective configs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;ltOptions() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Afk1rqQu9CjzobkJg.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%2F800%2F0%2Afk1rqQu9CjzobkJg.png" alt="image" width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to write automated tests for ServiceNow workflows?
&lt;/h3&gt;

&lt;p&gt;First, we write the base tests where the common configuration, like starting and quitting the drivers will be set up, and this base test will be extended to the Test Class, where actual tests will be written.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;BaseTest class&lt;/em&gt;&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;public class BaseTest {


    @Parameters ("browser")
    @BeforeClass (alwaysRun = true)
    public void setupTest (final String browser) {
        createDriver (Browsers.valueOf (browser.toUpperCase ()));
    }


    @AfterClass (alwaysRun = true)
    public void tearDown () {
        quitDriver ();
    }


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

&lt;/div&gt;



&lt;p&gt;@Parameters &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=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;annotation in TestNG&lt;/a&gt; is used to set the browser parameter from testng.xml. So if we need to run the tests on different browsers, we don’t have to change the code every time. The browser name could be updated in the &lt;em&gt;testng.xml&lt;/em&gt; and the test could be run accordingly.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CreateDriver()&lt;/code&gt; method from the DriverManager class is called here to set the Drivers as per the Browser value passed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;createDriver() method (DriverManager class)&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AsSw5OKtoR9htHNET.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%2F800%2F0%2AsSw5OKtoR9htHNET.png" alt="image" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;setupBrowserTimeouts()&lt;/code&gt; method is called for setting the browser timeouts after the driver is set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;setupBrowserTimeouts() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AVtOgBAwloKHiI72V.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%2F800%2F0%2AVtOgBAwloKHiI72V.png" alt="image" width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All our configurations are now set, and we are ready to write the tests. Let’s jump into the Scenarios that we discussed earlier and write tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;Here is the test that covers all three scenarios discussed in the &lt;a href="https://www.lambdatest.com/blog/effective-test-automation-strategy/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;test automation strategy.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;ServiceNowTests class&lt;/em&gt;&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;public class ServiceNowTests extends BaseTest {


    private static final String CALLER_NAME       = "John Adams";
    private static final String CHANNEL           = "Phone";
    private static final String SHORT_DESCRIPTION = "New incident created from automated test!";


@BeforeClass
     public void setup () {
        getDriver ().navigate ()
            .to ("https://dev21190.service-now.com/");
    }


    @Test
    public void testNewIncident () {
        LoginPage loginPage = new LoginPage ();
        loginPage.performLogin ();
        NewIncidentPage newIncidentPage = new NewIncidentPage ();
        assertEquals (newIncidentPage.getPageTitle (), "New record");


        IncidentListPage incidentListPage = newIncidentPage.createNewIncident (CALLER_NAME, CHANNEL, SHORT_DESCRIPTION);

        assertNotNull (incidentListPage.getIncidentNumber ());
        assertTrue (incidentListPage.getOpenedValue ()
            .contains (incidentListPage.getCurrentDate ()));
        assertEquals (incidentListPage.getShortDescriptionValue (), SHORT_DESCRIPTION);
        assertEquals (incidentListPage.getCallerNameValue (), CALLER_NAME);
        assertEquals (incidentListPage.getStateValue (), "New");
        assertEquals (incidentListPage.getCategoryValue (), "Inquiry / Help");
    }


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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;em&gt;Page Object Model&lt;/em&gt;&lt;/a&gt; is followed while writing the tests, and since we have three different pages to test; namely, &lt;em&gt;Login Page&lt;/em&gt;, &lt;em&gt;Incident Page&lt;/em&gt;, and &lt;em&gt;IncidentList Page&lt;/em&gt;. Hence, three Page Object classes are created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation (Test Scenario 1)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As discussed in the &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; strategy, let’s implement the Login Scenario, where the valid user will log in in the instance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LoginPage class&lt;/em&gt;&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;public class LoginPage {


    private String userName = System.getProperty ("website_username");
    private String password = System.getProperty ("website_password");


    private WebElement userNameField () {
        return getDriver ().findElement (By.id ("user_name"));
    }


    private WebElement passwordField () {
        return getDriver ().findElement (By.id ("user_password"));
    }


    private WebElement loginBtn () {
        return getDriver ().findElement (By.id ("sysverb_login"));
    }


    public NewIncidentPage performLogin () {
        userNameField ().sendKeys (userName);
        passwordField ().sendKeys (password);
        loginBtn ().click ();
        getDriver ().navigate ()
            .to ("https://dev21190.service-now.com/incident.do");
        return new NewIncidentPage ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Login Page&lt;/em&gt; has all the locators for the Login Screen, which has fields like User name, Password, and the &lt;em&gt;Log in&lt;/em&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the User name field&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A0GnOyl5IWkxDHiwQ.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%2F800%2F0%2A0GnOyl5IWkxDHiwQ.png" alt="image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Username field has the &lt;a href="https://www.lambdatest.com/blog/making-the-move-with-id-locator-in-selenium-webdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;ID locator&lt;/a&gt; in the DOM, which can be used to locate the field.&lt;/p&gt;

&lt;p&gt;Similarly, the Password Field and Login button can be located using the appropriate &lt;a href="https://www.lambdatest.com/learning-hub/selenium-locators?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;locator strategies&lt;/a&gt; (e.g., Name, id, linkText, etc.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Password field&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ARJfhEObwTVHYbtwv.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%2F800%2F0%2ARJfhEObwTVHYbtwv.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Log in button&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AuzGriJwMfTd2fq7b.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%2F800%2F0%2AuzGriJwMfTd2fq7b.png" alt="image" width="800" height="414"&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%2F800%2F0%2AcMuxW6F9UAjN75Y9.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%2F800%2F0%2AcMuxW6F9UAjN75Y9.png" alt="image" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;performLogin()&lt;/em&gt; method helps to login into the website. Here, we are not passing the username and password values in the method parameter. Instead, we get it using the &lt;em&gt;System.getProperty()&lt;/em&gt; method.&lt;/p&gt;

&lt;p&gt;This is done to ensure that we don’t expose the &lt;em&gt;Username and Password&lt;/em&gt; secret values while testing. The values in the fields are entered using &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=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;sendKeys() in Selenium WebDriver.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;performLogin() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AuYz12emI4kA4RVXZ.pn" 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%2F800%2F0%2AuYz12emI4kA4RVXZ.pn" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the login is successful, we will navigate to the new incident creation page using its respective URL and return a new instance of &lt;em&gt;NewIncidentPage&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation (Test Scenario 2)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Scenario 2, we discussed creating a new Incident by checking the page header first and then moving ahead to create a new incident.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;New Incident Creation Page&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AElu0UakmTw8UfgGw.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%2F800%2F0%2AElu0UakmTw8UfgGw.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test for creating a new Incident&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AzAvLTIFBG-NJbjeB.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%2F800%2F0%2AzAvLTIFBG-NJbjeB.png" alt="image" width="800" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NewIncidentPage&lt;/em&gt; class is created for locating the fields required to create a new incident. &lt;em&gt;createNewIncident()&lt;/em&gt; method performs the action required to create a new Incident.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;NewIncidentPage class&lt;/em&gt;&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;public class NewIncidentPage {


    private WebElement callerNameField () {
        return getDriver ().findElement (By.cssSelector (".input-group &amp;gt; input#sys_display\\.incident\\.caller_id"));
    }


    private WebElement serviceField () {
        return getDriver ().findElement (
            By.cssSelector (".input-group &amp;gt; input#sys_display\\.incident\\.business_service"));
    }


    private WebElement serviceFieldHelpBtn () {
        return getDriver ().findElement (By.cssSelector (".input-group-btn &amp;gt; #lookup\\.incident\\.business_service"));
    }


    public void clickServiceFieldHelpBtn () {
        serviceFieldHelpBtn ().click ();
    }


    private Select channelField () {
        return new Select (getDriver ().findElement (By.cssSelector (".form-group select#incident\\.contact_type")));
    }


    public void selectChannelByVisibleText (String channelName) {
        channelField ().selectByVisibleText (channelName);
    }


    private WebElement shortDescriptionField () {
        return getDriver ().findElement (By.cssSelector (".form-group &amp;gt; div input#incident\\.short_description"));
    }


    private WebElement submitBtn () {
        return getDriver ().findElement (By.id ("sysverb_insert_bottom"));
    }


    private WebElement selectServicesLink () {
        return getDriver ().findElement (By.cssSelector (
            "#cmdb_ci_service &amp;gt; #cmdb_ci_service_table &amp;gt; tbody &amp;gt; tr:nth-child(2) &amp;gt; td:nth-child(3) &amp;gt; a"));
    }


    public void selectServices () {
        WebDriverWait wait = new WebDriverWait (getDriver (), Duration.ofSeconds (30));
        final String originalWindow = getDriver ().getWindowHandle ();
        wait.until (ExpectedConditions.numberOfWindowsToBe (2));
        for (final String windowHandle : getDriver ().getWindowHandles ()) {
            if (!originalWindow.contentEquals (windowHandle)) {
                getDriver ().switchTo ()
                    .window (windowHandle);
                selectServicesLink ().click ();
                break;
            }
        }
        getDriver ().switchTo ()
            .window (originalWindow);
    }


    public String getPageTitle () {
        return getDriver ().findElement (By.cssSelector ("h1 &amp;gt; div &amp;gt; div.navbar-title-display-value"))
            .getText ();
    }


    public IncidentListPage createNewIncident (String callerName, String channelName, String shortDesc) {
        callerNameField ().sendKeys (callerName);
        selectChannelByVisibleText (channelName);
        clickServiceFieldHelpBtn ();
        selectServices ();
        shortDescriptionField ().sendKeys (shortDesc);
        submitBtn ().click ();
        getDriver ().navigate ()
            .to ("https://dev21190.service-now.com/incident_list.do");
        return new IncidentListPage ();
    }


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

&lt;/div&gt;



&lt;p&gt;Lets deep dive into the &lt;em&gt;createNewIncident()&lt;/em&gt; method. This method accepts three parameters, namely, &lt;em&gt;callerName&lt;/em&gt;, &lt;em&gt;channelName, and shortDesc&lt;/em&gt;, which will help us to generate a new entry for the incident.&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%2F800%2F0%2AwFM_yKKj64d0LHIr.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%2F800%2F0%2AwFM_yKKj64d0LHIr.png" alt="image" width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Caller Name&lt;/em&gt; field is an input text field. Lets locate this field using Chrome DevTools.&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%2F800%2F0%2AW-KG-SVmzws3Rfzb.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%2F800%2F0%2AW-KG-SVmzws3Rfzb.png" alt="image" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Our tutorial on&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/website-builder-test-case-template?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Website Builder Test Case&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;Templates offers comprehensive guide for effective website testing. Start optimizing your website’s quality today.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you look closely, the id to locate the field in the DOM is “&lt;em&gt;sys_display.incident.caller_id&lt;/em&gt;“.&lt;br&gt;&lt;br&gt;
However, when it comes to locating the field, the value for id is given as “&lt;em&gt;#sys_display\.incident\.caller_id&lt;/em&gt;” &lt;em&gt;(Notice the “\” in between the names before the “.”)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;“\” is used as an escape character here, as in &lt;a href="https://www.lambdatest.com/blog/css-selectors-cheat-sheet/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;CSS Selector,&lt;/a&gt; “.” is used for class names. However, since we need to pass on dots for full id value, we must pass the “\” as an escape character.&lt;/p&gt;

&lt;p&gt;In Java, “ \ ” is used for escape characters to pass the actual “\” for the String value. Hence for the CSS Selector value “ \\ ” is passed.&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%2F800%2F0%2APEuTusJFf1YjrLbM.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%2F800%2F0%2APEuTusJFf1YjrLbM.png" alt="image" width="800" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Channel field is a single select dropdown list. In the DOM, we can see that it has the &lt;code&gt;&amp;lt; Select &amp;gt;&lt;/code&gt; tag, which makes it easier to locate the field and use Selenium’s Select class to select the desired option and &lt;a href="https://www.lambdatest.com/blog/handling-dropdowns-in-selenium-webdriver-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;handle drop-down in Selenium.&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%2F800%2F0%2AYD0buvStxU498GDH.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%2F800%2F0%2AYD0buvStxU498GDH.png" alt="image" width="800" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Code to select the value from the Channel field&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A4fd1wL5zriz-2fz1.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%2F800%2F0%2A4fd1wL5zriz-2fz1.png" alt="image" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, the &lt;em&gt;Channel&lt;/em&gt; field is located using the CSS Selector, and a new instance of the Select class is returned from the &lt;code&gt;channelField() method. selectChannelByVisibleText()&lt;/code&gt; method accepts the channelName as a parameter and selects the desired channel as provided in the text.&lt;/p&gt;

&lt;p&gt;This passing of the parameter allows the tester to pass any visible text available in the field rather than hard coding any available value in the dropdown list.&lt;/p&gt;

&lt;p&gt;The next field we need to locate and automate is the &lt;em&gt;Service field&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AxNHxRV9fjzvDurWD.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%2F800%2F0%2AxNHxRV9fjzvDurWD.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To enter the value in this field, there are two ways, either type in the valid service name in the field or open the &lt;em&gt;Service&lt;/em&gt; Search window and select the required service.&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%2F800%2F0%2AYucblkNla_2lMwt9.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%2F800%2F0%2AYucblkNla_2lMwt9.png" alt="image" width="800" height="374"&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%2F800%2F0%2AtvyIroz5_2C2rqxr.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%2F800%2F0%2AtvyIroz5_2C2rqxr.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use the second way, i.e., open the &lt;em&gt;Search Service&lt;/em&gt; window and choose the service of it. The steps that we need to perform are to click on the &lt;em&gt;Search&lt;/em&gt; icon.&lt;/p&gt;

&lt;p&gt;Here is the code snippet from the &lt;code&gt;NewIncidentPage&lt;/code&gt; class, which will locate the &lt;em&gt;Service&lt;/em&gt; field &lt;em&gt;Help&lt;/em&gt; button and click on 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AH0fzjisiZnf5MeDh.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%2F800%2F0%2AH0fzjisiZnf5MeDh.png" alt="image" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, move the focus to the &lt;em&gt;Search Service&lt;/em&gt; window and click on the &lt;em&gt;Service&lt;/em&gt; name to select 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AFfpwFrhH8BbzLD2Q.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%2F800%2F0%2AFfpwFrhH8BbzLD2Q.png" alt="image" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;selectServices()&lt;/code&gt; method performs all the major actions here. It will switch to the new window and select the service (&lt;em&gt;The Second Service name from the Services list in the window is selected&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Here, for switching between windows, we need window handles of all the windows opened. A window handle is a unique identifier that holds the address of all the windows. It is a pointer that returns a String value.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;getWindowHandles()&lt;/code&gt; method helps us store the window handles and switch to the next open window.&lt;/p&gt;

&lt;p&gt;Once the Service name selection is done, the Search Service window gets closed, and the focus needs to be shifted to the New Incident window. The following code line will ensure that the focus is shifted back to the original window. To learn more about it, you can go through this blog on &lt;a href="https://www.lambdatest.com/blog/how-to-handle-multiple-windows-in-selenium-webdriver-using-java/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;handling Windows 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;getDriver ().switchTo ().window (originalWindow);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, the &lt;em&gt;Short Description&lt;/em&gt; field is located, and text is entered in it as it is a mandatory field. After that, the &lt;em&gt;Submit&lt;/em&gt; button will be clicked and using the below statement, we will navigate to the IncidentList Page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getDriver ().navigate ()
            .to ("https://dev21190.service-now.com/incident_list.do");
        return new IncidentListPage ();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assertions are the core of the test. With &lt;a href="https://www.lambdatest.com/blog/asserts-in-testng/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;TestNG assertions&lt;/a&gt;, we will ensure that whatever data we have entered in the system using the &lt;em&gt;New Incident Page&lt;/em&gt; is displayed correctly on the &lt;em&gt;Incident List Page&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AJMw6Ui5m_69QggiF.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%2F800%2F0%2AJMw6Ui5m_69QggiF.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The record entered from the &lt;em&gt;New Incident Page&lt;/em&gt; is reflected as the first on the &lt;em&gt;Incident List Page&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation (Test Scenario 3)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;IncidentListPage&lt;/em&gt; class is created to locate all the elements on this page and return the text of the first row.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;IncidentListPage class&lt;/em&gt;&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;public class IncidentListPage {


    public String getOpenedValue () {
        return getDriver ().findElement (By.cssSelector ("#incident_table &amp;gt;tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(4)"))
            .getText ();
    }


    public String getShortDescriptionValue () {
        return getDriver ().findElement (By.cssSelector ("#incident_table &amp;gt;tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(5)"))
            .getText ();
    }


    public String getCallerNameValue () {
        return getDriver ().findElement (By.cssSelector ("#incident_table &amp;gt;tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(6)"))
            .getText ();
    }


    public String getStateValue () {
        return getDriver ().findElement (By.cssSelector ("#incident_table &amp;gt;tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(8)"))
            .getText ();
    }


    public String getCategoryValue () {
        return getDriver ().findElement (By.cssSelector ("#incident_table &amp;gt;tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(9)"))
            .getText ();
    }


    public String getIncidentNumber () {
        return getDriver ().findElement (By.cssSelector ("#incident_table &amp;gt;tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(3)"))
            .getText ();
    }


    public String getCurrentDate () {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern ("yyyy-MM-dd");
        LocalDateTime now = LocalDateTime.now (ZoneId.of ("America/Los_Angeles"));
        return dateTimeFormatter.format (now);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you observe the &lt;em&gt;Incident List Page&lt;/em&gt; Screen, it can be seen that it is a table, and values are respectively presented in rows and columns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Incident List Page Screen with locators&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2ARZ0y7jvZghKKyfGA.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%2F800%2F0%2ARZ0y7jvZghKKyfGA.png" alt="image" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will find that most of the locators are located using the CSS Selectors, and the CSS Selectors are almost the same; only the respective child is changed at the end.&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%2F800%2F0%2Adw4sSZpv9Xfu-P_W.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%2F800%2F0%2Adw4sSZpv9Xfu-P_W.png" alt="image" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, CSS Selector for Opened Column and Short Description column are &lt;code&gt;#incident_table &amp;gt; tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(4)&lt;/code&gt; &lt;em&gt;for opened Column.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AtikiUQYT-5Ou-Ovb.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%2F800%2F0%2AtikiUQYT-5Ou-Ovb.png" alt="image" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#incident_table &amp;gt; tbody &amp;gt; tr:nth-child(1) &amp;gt; td:nth-child(5)&lt;/code&gt; &lt;em&gt;for Short Description Column&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A_xMe10c0l-VOgUEA.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%2F800%2F0%2A_xMe10c0l-VOgUEA.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;nth-child&lt;/em&gt; matches every element that is the nth child of its parent. And since the &lt;em&gt;Incident List Page&lt;/em&gt; has a table, we can just update the child reference, locate the required column, and get its value.&lt;/p&gt;

&lt;p&gt;Now, coming to assertions in the test, in the test, the respective column value will be compared with the expected value that we used while creating a new incident.&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%2F800%2F0%2AI8S9eLWsgI4MO-YI.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%2F800%2F0%2AI8S9eLWsgI4MO-YI.png" alt="image" width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the assertions, we have completed our tests and covered all the scenarios we discussed as a test automation strategy.&lt;/p&gt;

&lt;p&gt;Let’s now run the tests and check the result.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Execution
&lt;/h3&gt;

&lt;p&gt;There are two ways to run the tests for verifying functionalities on the ServiceNow dashboard:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;From the IDE using TestNG.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the CLI using Maven.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Using TestNG
&lt;/h4&gt;

&lt;p&gt;TestNG is used as a test runner; hence testng.xml has been created. Tests can be run by right-clicking on the file and selecting the option &lt;strong&gt;Run ‘…\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="Service Now Tests Suite with Selenium WebDriver" parallel="tests"&amp;gt;
    &amp;lt;test name="Testing ServiceNow Demo website on Chrome browser - LambdaTest"&amp;gt;
        &amp;lt;parameter name="browser" value="remote_chrome"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="io.github.mfaisalkhatri.tests.ServiceNowTests"&amp;gt;
                &amp;lt;methods&amp;gt;
                    &amp;lt;include name="testNewIncident"/&amp;gt;
                &amp;lt;/methods&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;
    &amp;lt;test name="Testing ServiceNow Demo website on Firefox Browser - LambdaTest "&amp;gt;
        &amp;lt;parameter name="browser" value="remote_firefox"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="io.github.mfaisalkhatri.tests.ServiceNowTests"&amp;gt;
                &amp;lt;methods&amp;gt;
                    &amp;lt;include name="testNewIncident"/&amp;gt;
                &amp;lt;/methods&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;The following four values need to be supplied as per the Test Configurations otherwise the tests won’t run:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Access Key&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ServiceNow’s Demo Developer Website Username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ServiceNow’s Demo Developer WebSite Password&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These values can be passed as “-Dwebsite_username=&amp;lt; servicenow_username &amp;gt; -Dwebsite_password=&amp;lt; servicenow_password &amp;gt; -DLT_USERNAME=&amp;lt; LambdaTest Username &amp;gt; -DLT_ACCESS_KEY=&amp;lt; LambdaTest Access Key &amp;gt;”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Screenshot of the test run locally using Intellij IDE&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AncmNulrRHzSGm5Vo.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%2F800%2F0%2AncmNulrRHzSGm5Vo.png" alt="image" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parallel Execution of the Tests:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The tests we just ran using TestNG were executed in parallel. In sequential execution, we have to wait for the first test to finish, and then only the next test gets executed.&lt;br&gt;&lt;br&gt;
Parallel execution saves time in test execution as all the tests are run in parallel at the same time.&lt;/p&gt;

&lt;p&gt;For performing &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=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing in TestNG,&lt;/a&gt; we need to mention &lt;code&gt;parallel=”tests”&lt;/code&gt; in testng.xml. Here, all the test blocks updated in testng.xml will start executing in parallel.&lt;/p&gt;

&lt;p&gt;We have already used the &lt;strong&gt;ThreadLocal&lt;/strong&gt; class in our code. Hence our execution will be thread-safe, so we don’t have to worry about things like test sessions overlapping, etc.&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%2F800%2F0%2A0XkucNCS6W-XmFJv.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%2F800%2F0%2A0XkucNCS6W-XmFJv.png" alt="image" width="800" height="175"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Using Maven
&lt;/h4&gt;

&lt;p&gt;To run the tests using maven, the following steps need to be run:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open command Prompt/Terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the root folder of the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type the command on the terminal:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Screenshot of the test results run using Maven&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AcZv_1QdGWQ7lQSlZ.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%2F800%2F0%2AcZv_1QdGWQ7lQSlZ.png" alt="image" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the tests are run successfully, we can check out the &lt;a href="https://automation.lambdatest.com/build?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt; and view all the video recordings, screenshots, device logs, and step-by-step granular details of the test run in the &lt;a href="https://www.lambdatest.com/blog/lambdatest-analytics/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Analytics.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Check out the screenshots below, which will give you a fair idea of the dashboard for automated app tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LambdaTest 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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2AhKXUf-EmvIM9FrJu.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%2F800%2F0%2AhKXUf-EmvIM9FrJu.png" alt="image" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following screenshots show the details of the build and the tests that were run. Again, the test name, browser name, browser version, OS name, respective OS version, and screen resolution are all correctly visible for each test.&lt;/p&gt;

&lt;p&gt;It also has the video of the test that was run, giving a better idea about how tests were run on the device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LambdaTest Build Details — Chrome Browser&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2Ajj2x8EXBB16kp0_H.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%2F800%2F0%2Ajj2x8EXBB16kp0_H.png" alt="image" width="800" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ServiceNow Developer’s Demo Instance Test execution on Chrome browser on LambdaTest platform:&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;LambdaTest Build Details — Firefox Browser&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F0%2A3OKKKvgGJ3Vo05fy.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%2F800%2F0%2A3OKKKvgGJ3Vo05fy.png" alt="image" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ServiceNow Developer’s Demo Instance Test execution on Firefox browser on LambdaTest platform:&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Over 57 different&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/ecommerce-test-cases?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;e-commerce test cases&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;websites and application test cases are covered to guarantee a flawless and secure purchasing experience for customers.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this blog, we discussed what ServiceNow is. We looked into the Now Platform and Automated Test Framework(ATF) created by ServiceNow.&lt;/p&gt;

&lt;p&gt;Selenium WebDriver, as an external tool, was used to demonstrate how automated testing of the ServiceNow application can be performed over the Chrome and Firefox browsers using a &lt;a href="https://www.lambdatest.com/testing-cloud/servicenow-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar13_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;ServiceNow Cloud Testing Platform&lt;/a&gt; like LambdaTest. I hope you enjoyed reading this blog and learned something from it.&lt;/p&gt;

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

</description>
      <category>selenium</category>
      <category>webdriver</category>
      <category>automationtesting</category>
      <category>cloudtesting</category>
    </item>
    <item>
      <title>How To Automate ServiceNow With Appium</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Tue, 07 Mar 2023 14:13:17 +0000</pubDate>
      <link>https://dev.to/testmuai/how-to-automate-servicenow-with-appium-4apa</link>
      <guid>https://dev.to/testmuai/how-to-automate-servicenow-with-appium-4apa</guid>
      <description>&lt;p&gt;As organizations and businesses grow, managing the Operations, HR, and IT activities becomes quite difficult. Let’s take an example of a company with a 5000+ workforce, where multiple vendors and contractors are assigned different roles. So, when it comes to managing contracts, licenses, and different ventures, it becomes a tedious task.&lt;/p&gt;

&lt;p&gt;To resolve such complex situations of managing the different operation activities,&lt;br&gt;&lt;br&gt;
ServiceNow, a cloud platform, provides service, operations, and business management solutions that organizations use to manage their digital workflows and streamline their business processes.&lt;/p&gt;

&lt;p&gt;So, if a contract needs to be extended for a contractor, the contractor can use the application built on top of ServiceNow to apply for an extension. Now, with businesses working remotely, mobile applications come quite handy, where the senior management team can provide approval on the go as soon as they see a notification in the mobile app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of using ServiceNow on Mobile:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It can be rebranded as our app by adding your logo, color theme, splash Screen, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tailored experiences can be delivered for routine employee needs from a single app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It simplifies development by creating a customized, elegant app for Android and iOS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It can create an immediate impact by providing out-of-the-box workflows for common use cases with seamless connection to data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, before we move towards releasing the mobile application to the end-customers (ideally a business), it is necessary to test it to validate that all the functionalities are working as expected. In the context of digital experience, ensuring that a product or service is functional and performs seamlessly across different devices and screen sizes is essential. This is because customers today interact with digital platforms using various devices, such as desktops, laptops, tablets, and smartphones, and the screen size and specifications of these devices can vary widely.&lt;/p&gt;

&lt;p&gt;When testing ServiceNow mobile applications, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt; is a popular choice among organizations. Appium is a widely used open-source mobile automation testing framework that can be used to test ServiceNow workflows for shipping a full-functional top-quality mobile application.&lt;/p&gt;

&lt;p&gt;In this blog on ServiceNow with Appium, we will learn how to test ServiceNow using Appium to ensure the workflows and applications are working as expected, ultimately improving the overall efficiency and quality of the testing process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Automated&lt;/em&gt;&lt;/strong&gt; &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=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Functional Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tests helps to ensure that your web app works as it was intented to. Learn more about functional tests, and how automating them can give you a faster release cycle&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  What is ServiceNow?
&lt;/h3&gt;

&lt;p&gt;ServiceNow provides a cloud-based platform designed to keep up with the rapid pace of change in today’s world. This platform enables you to manage your daily operations effectively and plays a vital role in improving the digital experience for all users. With various tools and capabilities at its disposal, the platform offered by ServiceNow enables organizations to streamline their digital workflows, automate and optimize processes, and improve communication and collaboration. By unifying and digitizing operations, ServiceNow empowers organizations to discover more efficient and effective ways of making work flow smoothly.&lt;/p&gt;

&lt;p&gt;Here are some figures from the QA 2022 and FY 2022 regarding ServiceNow business:&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%2F640%2F0%2AAe_NfhXrNZDFxH2e.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%2F640%2F0%2AAe_NfhXrNZDFxH2e.png" alt="image01" width="640" height="417"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Now Platforms
&lt;/h3&gt;

&lt;p&gt;The Now Platform is designed to streamline your entire business by optimizing processes and creating value through a unified platform. Explore the various Now Platform options 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ArFYyFYjgSeCxWI_b.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%2F640%2F0%2ArFYyFYjgSeCxWI_b.png" alt="image02" width="640" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/black-box-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Black Box testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&lt;em&gt;? Don’t worry; we will be covering what is Black box testing, merits, demerits, types &amp;amp; techniques.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Tokyo Release
&lt;/h3&gt;

&lt;p&gt;ServiceNow follows a biannual schedule for its releases, with the most recent Tokyo release being launched in Q4 of 2022. The upcoming Utah release is expected to be rolled out in Q2 of 2023. To explore the features introduced in the Tokyo General Availability release, please refer to the release highlights.&lt;/p&gt;

&lt;p&gt;This report indicates that ServiceNow Inc’s market share increased to around 0.79% due to a robust overall revenue growth of 20.12%.&lt;/p&gt;
&lt;h3&gt;
  
  
  How to Automate ServiceNow with Appium?
&lt;/h3&gt;

&lt;p&gt;Before we move towards &lt;a href="https://www.lambdatest.com/blog/servicenow-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;ServiceNow testing&lt;/a&gt;, it’s good to discuss the Application Under Test (AUT), the tools used, and the &lt;a href="https://www.lambdatest.com/blog/effective-test-automation-strategy/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation test strategy&lt;/a&gt; to define the scenarios for testing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Application Under Test (ServiceNow Demo Application)
&lt;/h3&gt;

&lt;p&gt;In this ServiceNow with Appium tutorial, ServiceNow’s mobile application is used for testing. It is available online and can be downloaded from the Google Play Store.&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%2F640%2F0%2AQCf_aukDs7x_K7OY.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%2F640%2F0%2AQCf_aukDs7x_K7OY.png" alt="image03" width="640" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On clicking the “T*RY WITH A DEMO ACCOUNT*” link, the application will ask for a persona to choose, We will be choosing the “&lt;em&gt;Service Desk Agent&lt;/em&gt;” option and accordingly will test the application further. Check out the Test Scenarios section below to learn more about the &lt;a href="https://www.lambdatest.com/blog/best-mobile-app-testing-scenarios/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;scenarios used for testing&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Getting Started with ServiceNow Testing
&lt;/h3&gt;

&lt;p&gt;In this blog section on ServiceNow with Appium, let’s see how to get started with ServiceNow Testing.&lt;/p&gt;

&lt;p&gt;Following tools/language has been used in writing and running the tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Programming Language: &lt;strong&gt;Java&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mobile App Automation Tool: Appium &lt;em&gt;(Appium Java Client version 8.3.0)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test Runner: &lt;a href="https://www.lambdatest.com/learning-hub/testng?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;TestNG&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build Tool: &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=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Maven&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud Platform to run the tests: &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Test Scenarios
&lt;/h3&gt;

&lt;p&gt;We will target the New &lt;em&gt;Incident Creation screen&lt;/em&gt; and &lt;em&gt;My Incidents&lt;/em&gt; page for &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;test automation&lt;/a&gt;. However, before we move on to those screens, we need to launch the demo instance of the application and choose the &lt;em&gt;Service Agent&lt;/em&gt; persona.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Scenario 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will automate the following steps in the current test:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Launch the application, click on the “&lt;em&gt;TRY WITH A DEMO ACCOUNT&lt;/em&gt;” link.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose &lt;em&gt;Service Desk Agent&lt;/em&gt; persona and launch the demo app.&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;&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;io.github.mfaisalkhatri&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;servicenow-appium-testing&amp;lt;/artifactId&amp;gt;
  &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
  &amp;lt;packaging&amp;gt;jar&amp;lt;/packaging&amp;gt;

  &amp;lt;name&amp;gt;servicenow-appium-testing&amp;lt;/name&amp;gt;
  &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;

  &amp;lt;properties&amp;gt;
    &amp;lt;appium-java-client-version&amp;gt;8.3.0&amp;lt;/appium-java-client-version&amp;gt;
    &amp;lt;testng-version&amp;gt;7.7.1&amp;lt;/testng-version&amp;gt;
    &amp;lt;lombok-version&amp;gt;1.18.26&amp;lt;/lombok-version&amp;gt;
    &amp;lt;maven.compiler.source&amp;gt;11&amp;lt;/maven.compiler.source&amp;gt;
    &amp;lt;maven.compiler.target&amp;gt;11&amp;lt;/maven.compiler.target&amp;gt;
    &amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;
    &amp;lt;maven.compiler.version&amp;gt;3.10.1&amp;lt;/maven.compiler.version&amp;gt;
    &amp;lt;surefire-version&amp;gt;3.0.0-M8&amp;lt;/surefire-version&amp;gt;
    &amp;lt;java.release.version&amp;gt;11&amp;lt;/java.release.version&amp;gt;
    &amp;lt;maven.source.encoding&amp;gt;UTF-8&amp;lt;/maven.source.encoding&amp;gt;
    &amp;lt;suite-xml&amp;gt;testng.xml&amp;lt;/suite-xml&amp;gt;
    &amp;lt;argLine&amp;gt;-Dfile.encoding=UTF-8 -Xdebug -Xnoagent&amp;lt;/argLine&amp;gt;
  &amp;lt;/properties&amp;gt;

  &amp;lt;dependencies&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;${testng-version}&amp;lt;/version&amp;gt;
      &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
    &amp;lt;/dependency&amp;gt;
    &amp;lt;!-- https://mvnrepository.com/artifact/io.appium/java-client --&amp;gt;
    &amp;lt;dependency&amp;gt;
      &amp;lt;groupId&amp;gt;io.appium&amp;lt;/groupId&amp;gt;
      &amp;lt;artifactId&amp;gt;java-client&amp;lt;/artifactId&amp;gt;
      &amp;lt;version&amp;gt;${appium-java-client-version}&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;
    &amp;lt;!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --&amp;gt;
    &amp;lt;dependency&amp;gt;
      &amp;lt;groupId&amp;gt;org.projectlombok&amp;lt;/groupId&amp;gt;
      &amp;lt;artifactId&amp;gt;lombok&amp;lt;/artifactId&amp;gt;
      &amp;lt;version&amp;gt;${lombok-version}&amp;lt;/version&amp;gt;
      &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
    &amp;lt;/dependency&amp;gt;
  &amp;lt;/dependencies&amp;gt;

  &amp;lt;build&amp;gt;
    &amp;lt;plugins&amp;gt;
      &amp;lt;plugin&amp;gt;
        &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;${maven.compiler.version}&amp;lt;/version&amp;gt;
        &amp;lt;configuration&amp;gt;
          &amp;lt;release&amp;gt;${java.release.version}&amp;lt;/release&amp;gt;
          &amp;lt;encoding&amp;gt;${maven.source.encoding}&amp;lt;/encoding&amp;gt;
          &amp;lt;forceJavacCompilerUse&amp;gt;true&amp;lt;/forceJavacCompilerUse&amp;gt;
        &amp;lt;/configuration&amp;gt;
      &amp;lt;/plugin&amp;gt;
      &amp;lt;plugin&amp;gt;
        &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;maven-surefire-plugin&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;${surefire-version}&amp;lt;/version&amp;gt;
        &amp;lt;executions&amp;gt;
          &amp;lt;execution&amp;gt;
            &amp;lt;goals&amp;gt;
              &amp;lt;goal&amp;gt;test&amp;lt;/goal&amp;gt;
            &amp;lt;/goals&amp;gt;
          &amp;lt;/execution&amp;gt;
        &amp;lt;/executions&amp;gt;
        &amp;lt;configuration&amp;gt;
          &amp;lt;useSystemClassLoader&amp;gt;false&amp;lt;/useSystemClassLoader&amp;gt;
          &amp;lt;properties&amp;gt;
            &amp;lt;property&amp;gt;
              &amp;lt;name&amp;gt;usedefaultlisteners&amp;lt;/name&amp;gt;
              &amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;
            &amp;lt;/property&amp;gt;
          &amp;lt;/properties&amp;gt;
          &amp;lt;suiteXmlFiles&amp;gt;
            &amp;lt;suiteXmlFile&amp;gt;${suite-xml}&amp;lt;/suiteXmlFile&amp;gt;
          &amp;lt;/suiteXmlFiles&amp;gt;
          &amp;lt;argLine&amp;gt;${argLine}&amp;lt;/argLine&amp;gt;
        &amp;lt;/configuration&amp;gt;
      &amp;lt;/plugin&amp;gt;
    &amp;lt;/plugins&amp;gt;
  &amp;lt;/build&amp;gt;

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

&lt;/div&gt;


&lt;p&gt;ServiceNow mobile application supports the latest two versions of Apple iOS and the latest four versions of Google Android.&lt;/p&gt;

&lt;p&gt;In this ServiceNow with Appium blog, we will run the tests on LambdaTest Appium Grid on the Real Android device –&lt;em&gt;Samsung Galaxy S21 5G&lt;/em&gt; with Android 12 version as it is the latest Android device and version as of now.&lt;/p&gt;

&lt;p&gt;The first step is to create an &lt;em&gt;AndroidDriverManager&lt;/em&gt; class, which will be used to start the Android driver to run the &lt;a href="https://www.lambdatest.com/blog/how-to-automate-android-apps-using-appium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;tests on Android devices&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;@Builder
public class AndroidDriverManager {
    private static final ThreadLocal&amp;lt;AndroidDriver&amp;gt; DRIVER = new ThreadLocal&amp;lt;&amp;gt; ();
    public               Platform                   platform;
    public               String                     platformVersion;
    private              String                     buildName;
    private              String                     testName;

    private static final String LT_USERNAME   = System.getProperty ("LT_USERNAME");
    private static final String LT_ACCESS_KEY = System.getProperty ("LT_ACCESS_KEY");
    private static final String GRID_URL      = "@mobile-hub.lambdatest.com/wd/hub";
    private              String deviceName;
    private              String app;
    public AndroidDriverManager createAndroidDriver () {
        try {
            DRIVER.set (
                new AndroidDriver (new URL (format ("https://{0}:{1}{2}", LT_USERNAME, LT_ACCESS_KEY, GRID_URL)),
                    capabilities ()));
            setupDriverTimeouts ();

        } catch (MalformedURLException e) {
            throw new Error ("Error setting up android Driver", e);
        }
        return this;
    }

    public AndroidDriver getDriver () {
        return DRIVER.get ();
    }

    public void quitDriver () {
        if (null != getDriver ())
            getDriver ().quit ();
        DRIVER.remove ();
    }

    private void setupDriverTimeouts () {
        getDriver ().manage ()
            .timeouts ()
            .implicitlyWait (Duration.ofSeconds (30));
    }

    private DesiredCapabilities capabilities () {
        DesiredCapabilities capabilities = new DesiredCapabilities ();
        capabilities.setCapability ("lt:options", ltOptions ());
        return capabilities;
    }

    private HashMap&amp;lt;String, Object&amp;gt; ltOptions () {
        final HashMap&amp;lt;String, Object&amp;gt; ltOptions = new HashMap&amp;lt;&amp;gt; ();
        ltOptions.put (MobileCapabilityType.PLATFORM_NAME, platform);
        ltOptions.put (MobileCapabilityType.PLATFORM_VERSION, platformVersion);
        ltOptions.put (MobileCapabilityType.DEVICE_NAME, deviceName);
        ltOptions.put (MobileCapabilityType.APP, app);
        ltOptions.put (AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
        ltOptions.put ("username", LT_USERNAME);
        ltOptions.put ("accessKey", LT_ACCESS_KEY);
        ltOptions.put ("build", buildName);
        ltOptions.put ("name", testName);
        ltOptions.put ("w3c", true);
        ltOptions.put ("isRealMobile", true);
        ltOptions.put ("network", true);
        ltOptions.put ("visual", true);
        ltOptions.put ("console", true);
        ltOptions.put ("devicelog", true);
        return ltOptions;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;This&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/smoke-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;smoke testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial covers what smoke testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Walkthrough
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Static Variables in the DriverManager class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The use of &lt;em&gt;ThreadLocal&lt;/em&gt; class in this context enables the safe setting of drivers, especially when running tests in parallel. This is because ThreadLocal provides thread safety and effectively isolates two threads, even if they set different values on the same ThreadLocal object. The primary advantage of using ThreadLocal is ensuring threads run independently and in isolation.&lt;/p&gt;

&lt;p&gt;The following capabilities are necessary for running tests on the LambdaTest platform: &lt;em&gt;GRID_URL&lt;/em&gt;, which must be configured, and &lt;em&gt;LT_USERNAME&lt;/em&gt; and &lt;em&gt;LT_ACCESS_KEY&lt;/em&gt;, which are required for authentication and creating new sessions. These capabilities can be set using the &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Capabilities Generator.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest, a cloud-based testing platform, enables you to conduct comprehensive testing on a &lt;a href="https://www.lambdatest.com/real-device-cloud?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;real device cloud&lt;/a&gt; consisting of over 3000 different devices and operating systems. This platform provides a &lt;a href="https://www.lambdatest.com/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;cloud Appium Grid&lt;/a&gt;, which can be utilized to automate the testing of ServiceNow workflows, ensuring that your users receive a top-notch digital experience.&lt;/p&gt;

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

&lt;p&gt;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube" rel="noopener noreferrer"&gt;LambdaTest YouTube Channel&lt;/a&gt; and stay updated with the latest tutorial around &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Selenium testing&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, &lt;a href="https://www.lambdatest.com/playwright?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Playwright&lt;/a&gt; automation testing, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest Capabilities Generator&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A7NQe3os8P-3_Jt1o.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%2F640%2F0%2A7NQe3os8P-3_Jt1o.png" alt="image04" width="640" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;LambdaTest Capabilities Generator helps you set the capabilities by selecting the required configurations from the UI. Accordingly, it generates code that can be copy pasted easily into the project to start the &lt;a href="https://www.lambdatest.com/mobile-automation-test?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;mobile automation test&lt;/a&gt; hassle-free.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Setting the Desired Capabilities&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2Ajt1rn-J7I9aHNqVt.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%2F640%2F0%2Ajt1rn-J7I9aHNqVt.png" alt="image05" width="640" height="548"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Apart from the static variables, other variables are declared like &lt;em&gt;platform&lt;/em&gt;, &lt;em&gt;platform version&lt;/em&gt;, &lt;em&gt;devicename&lt;/em&gt;, &lt;em&gt;app&lt;/em&gt;, etc. The device will be assigned to run the test based on these configurations.&lt;/p&gt;

&lt;p&gt;The code mentioned above utilizes the &lt;a class="mentioned-user" href="https://dev.to/builder"&gt;@builder&lt;/a&gt; annotation from the Lombok library, which facilitates the runtime passing of variable values such as &lt;em&gt;platform&lt;/em&gt;, &lt;em&gt;platform name&lt;/em&gt;, &lt;em&gt;device name&lt;/em&gt;, and &lt;em&gt;app&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Check out the Base Test and the Test Execution section below, where the steps related to passing the values for these variables are discussed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up Android Driver to run tests on the cloud&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next important method to note is the &lt;em&gt;createAndroidDriver()&lt;/em&gt;. This method sets up the Android driver in the LamdaTest, a &lt;a href="https://www.lambdatest.com/testing-cloud/servicenow-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;ServiceNow cloud testing platform&lt;/a&gt; with the help of Desired Capabilities and runs the tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;createAndroidDriver() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AJ-fm3ma1NttkqOYN.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%2F640%2F0%2AJ-fm3ma1NttkqOYN.png" alt="image06" width="640" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;setupBrowserTimeouts()&lt;/em&gt; method is called for setting the timeouts after the driver is set. The &lt;a href="https://www.lambdatest.com/blog/implicit-wait-csharp-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Implicit wait&lt;/a&gt; is added, so while searching for a single element, the driver should poll the page until an element is found or the timeout expires. This wait applies to all the elements on the Screen.&lt;/p&gt;

&lt;p&gt;Likewise, &lt;a href="https://www.lambdatest.com/blog/explicit-fluent-wait-in-selenium-c/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Explicit wait&lt;/a&gt; can also be added for finding a specific element where we ask the driver instance to wait for a certain condition invoked through ExpectedConditions.&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%2F640%2F0%2AsMAcGx2qMAb_wVLy.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%2F640%2F0%2AsMAcGx2qMAb_wVLy.png" alt="image07" width="640" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All our configurations are now set. Let’s now jump on to writing the automated tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to write automated tests for the ServiceNow Demo Mobile application?
&lt;/h3&gt;

&lt;p&gt;First, let’s write the base tests where the common configuration will be set up, like starting and quitting the &lt;em&gt;Android driver.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This base test will be extended to the Test Class, where actual tests are implemented.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class BaseTest {
    protected AndroidDriverManager androidDriverManager;

    @Parameters ({ "buildName", "testName", "app", "platformName", "platformVersion", "deviceName" })
    @BeforeClass (alwaysRun = true)
    public void setupTest (String buildName, String testName, String app, Platform platform, String platformVersion,
        String deviceName) {

        androidDriverManager = AndroidDriverManager.builder ()
            .buildName (buildName)
            .testName (testName)
            .app (app)
            .platform (platform)
            .platformVersion (platformVersion)
            .deviceName (deviceName)
            .build ()
            .createAndroidDriver ();
    }

    @AfterClass (alwaysRun = true)
    public void tearDown () {
        androidDriverManager.quitDriver ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;@Parameters&lt;/em&gt; &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=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;annotation in TestNG&lt;/a&gt; enables the configuration of multiple parameters through &lt;em&gt;testng.xml&lt;/em&gt;, obviating the need to modify the code repeatedly. Consequently, tests can be executed on various devices, platforms, and specific platform versions without any code modification. The corresponding settings for &lt;em&gt;platforms&lt;/em&gt;, &lt;em&gt;platform versions&lt;/em&gt;, &lt;em&gt;devices&lt;/em&gt;, &lt;em&gt;apps&lt;/em&gt;, etc., can be updated in the &lt;em&gt;testng.xml&lt;/em&gt;, and the tests can be executed accordingly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation of Test Scenarios
&lt;/h3&gt;

&lt;p&gt;Here is the test that covers all three scenarios discussed in the test &lt;a href="https://www.lambdatest.com/blog/effective-test-automation-strategy/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation strategy&lt;/a&gt; in the earlier section of this blog on ServiceNow with Appium.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ServiceNowAppTests extends BaseTest {

    @BeforeClass
    public void launchApp () {
        LaunchPage launchPage = new LaunchPage (androidDriverManager);
        launchPage.launchDemoApp ();
    }

    @Test
    public void testIncident () {
        MainPage mainPage = new MainPage (androidDriverManager);
        mainPage.createNewIncident ("New incident created using appium automation");
        IncidentListPage incidentListPage = new IncidentListPage (androidDriverManager);

        incidentListPage.searchForIncident ("email");
        incidentListPage.openIncident ();

        assertEquals (incidentListPage.getSeverityText (), "2 - High");
        assertEquals (incidentListPage.getTitle (), "No email! I cant't send or receive anything");
        assertEquals (incidentListPage.getCallerName (), "Francis Soo");
        assertEquals (incidentListPage.getDescription (),
            "I am not able to send or receive any email for the last 24 hours");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;A comprehensive&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/exploratory-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Exploratory Testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial that covers what Exploratory Testing is, its importance, benefits, and how to perform it with real-time examples.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While writing tests, the &lt;a href="https://www.lambdatest.com/blog/selenium-java-testing-page-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Page Object Model&lt;/a&gt; is adhered to, which involves creating four separate Page Object classes for the four pages that require testing: &lt;em&gt;Launch Page&lt;/em&gt;, &lt;em&gt;Main Page&lt;/em&gt;, &lt;em&gt;New Incident Page&lt;/em&gt;, and &lt;em&gt;Incident List Page&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation (Test Scenario 1)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As discussed in the &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;automation testing&lt;/a&gt; strategy, let’s implement the first scenario where a demo instance of the application will be launched, and the &lt;em&gt;Service Agent&lt;/em&gt; persona will be selected.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;LaunchPage&lt;/em&gt; class has all the locators for the &lt;em&gt;Launch Screen&lt;/em&gt;, which has fields like the &lt;em&gt;Demo link&lt;/em&gt;, &lt;em&gt;Service Desk Agent option&lt;/em&gt;, and &lt;em&gt;Launch Demo button&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;public class LaunchPage {

    private final AndroidDriverManager androidDriverManager;
    private final WebDriverWait        wait;

    public LaunchPage (final AndroidDriverManager androidDriverManager) {
        this.androidDriverManager = androidDriverManager;
        wait = new WebDriverWait (androidDriverManager.getDriver (), Duration.ofSeconds (30));
    }

    private WebElement tryDemoLink () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.id ("com.servicenow.fulfiller:id/btn_demo_account"));
    }

    private void clickOnTryDemoLink () {
        tryDemoLink ().click ();
    }

    private WebElement serviceDeskOptionMenu () {
        return wait.until (ExpectedConditions.elementToBeClickable (By.id ("itsm")));
    }

    private void clickServiceDeskAgentOption () {
        switchToWebViewContext ();
        serviceDeskOptionMenu ().click ();
    }

    private WebElement launchDemoBtn () {
        return androidDriverManager.getDriver ()
            .findElement (By.id ("launchDemo"));
    }

    private void clickLaunchDemoBtn () {
        launchDemoBtn ().click ();
        switchToNativeAPP ();
    }

    private void switchToWebViewContext () {
        wait.until (d -&amp;gt; androidDriverManager.getDriver ()
            .getContextHandles ()
            .size () &amp;gt; 1);
        androidDriverManager.getDriver ()
            .context ("WEBVIEW_chrome");

    }

    private void switchToNativeAPP () {
        androidDriverManager.getDriver ()
            .context ("NATIVE_APP");
    }

    public void launchDemoApp () {
        clickOnTryDemoLink ();
        clickServiceDeskAgentOption ();
        clickLaunchDemoBtn ();

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

&lt;/div&gt;



&lt;p&gt;To locate the elements, the &lt;a href="https://www.lambdatest.com/blog/appium-inspector-for-apps/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Appium Inspector&lt;/a&gt; application is used, which helps us easily to locate all the elements.&lt;/p&gt;

&lt;p&gt;After opening Appium Inspector with all the required desired capabilities, locate the “TRY WITH DEMO ACCOUNT” link. We must locate and interact with this first element to start the demo application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the “TRY WITH A DEMO ACCOUNT” link&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AXub3EygvjtbzP_cS.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%2F640%2F0%2AXub3EygvjtbzP_cS.png" alt="image08" width="640" height="346"&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%2F640%2F0%2A1AbaOwarl6Pv3N6K.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%2F640%2F0%2A1AbaOwarl6Pv3N6K.png" alt="image09" width="528" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Appium Inspector shows that the link can be located using the &lt;a href="https://www.lambdatest.com/blog/locators-in-appium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;id locator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the code to locate the 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A2lxH1_RTW-mxXtsM.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%2F640%2F0%2A2lxH1_RTW-mxXtsM.png" alt="image10" width="640" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s now locate the &lt;em&gt;Service Desk Agent&lt;/em&gt; persona option and continue further to launch the demo app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Service Desk Agent Persona option&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A5s7Fsuu1pr79StzH.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%2F640%2F0%2A5s7Fsuu1pr79StzH.png" alt="image1" width="640" height="346"&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%2F640%2F0%2AHuyP-8kc-IK2ZxgM.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%2F640%2F0%2AHuyP-8kc-IK2ZxgM.png" alt="image2" width="529" height="595"&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%2F640%2F0%2AkKaw1EEaA6pm8ad3.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%2F640%2F0%2AkKaw1EEaA6pm8ad3.png" alt="image3" width="400" height="889"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you notice the Application screen, this page runs inside &lt;em&gt;WebView&lt;/em&gt; using Chrome. We can verify the different contexts in which the application runs using the &lt;em&gt;Commands&lt;/em&gt; tab in Appium Inspector.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Checking Context using Appium Inspector&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A-eIwN_uz2zKVTtix.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%2F640%2F0%2A-eIwN_uz2zKVTtix.png" alt="image4" width="640" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the &lt;em&gt;Context&lt;/em&gt; in the first and the second dropdown boxes and click the &lt;em&gt;Get Context List&lt;/em&gt; button. It will show all the available contexts for the application.&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%2F640%2F0%2APdfd3my9vvLfPbYb.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%2F640%2F0%2APdfd3my9vvLfPbYb.png" alt="image5" width="640" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://www.lambdatest.com/blog/what-is-a-webview-and-how-to-test-it/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;WebView&lt;/a&gt;, we can see that the context is “&lt;em&gt;WEBVIEW_chrome&lt;/em&gt;,” which we will be using to switch context so the elements on this page can be located. The elements will not be located until the context is switched, and Appium will 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=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;NoSuchElementException&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;test automation tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AY0KudFEDWK_laig5.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%2F640%2F0%2AY0KudFEDWK_laig5.png" alt="image7" width="640" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;serviceDeskOptionMenu()&lt;/em&gt; method locates the element for the Service &lt;em&gt;Desk Agent&lt;/em&gt; option.&lt;em&gt;switchToWebViewContext()&lt;/em&gt; method helps in switching to WebView context.&lt;/p&gt;

&lt;p&gt;To click on the Service Desk Agent option, first, we need to switch to &lt;em&gt;WebView&lt;/em&gt;, locate the &lt;em&gt;Service Desk Agent option&lt;/em&gt;, and click on it.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;clickServiceDeskAgentOption()&lt;/em&gt; method performs the mentioned steps.&lt;/p&gt;

&lt;p&gt;Next, we will locate the &lt;em&gt;Launch Demo&lt;/em&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Launch Demo button&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AXA2inhxim5hPOwc1.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%2F640%2F0%2AXA2inhxim5hPOwc1.png" alt="image8" width="640" height="345"&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%2F640%2F0%2AkztmH38tcK6EnExC.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%2F640%2F0%2AkztmH38tcK6EnExC.png" alt="image9" width="532" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Launch Demo&lt;/em&gt; button can be located using the id locator. The following code will help in locating the Launch Demo button and clicking on it.&lt;/p&gt;

&lt;p&gt;Next, we must switch back to the Native App context to move the focus back to the application.&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%2F640%2F0%2AE3lKWNt_FQp1XT7e.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%2F640%2F0%2AE3lKWNt_FQp1XT7e.png" alt="image11" width="640" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;launchDemoBtn()&lt;/em&gt; method returns the locator for Launch Demo button and &lt;em&gt;clickLaunchDemoBtn()&lt;/em&gt; will click on the button and switch to &lt;em&gt;NATIVE_APP&lt;/em&gt; context.&lt;/p&gt;

&lt;p&gt;Here is the &lt;em&gt;launchApp()&lt;/em&gt; method, which runs before the test and launches the app with a Service Desk Agent instance demo. This method has the TestNG’s &lt;em&gt;@BeforeClass&lt;/em&gt; annotation. &lt;em&gt;@BeforeClass&lt;/em&gt; annotated method runs before the first test method in the current class is invoked. Hence, this method will be invoked before any test is run and will help to start the application under test successfully, so all our tests run smoothly.&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%2F640%2F0%2APpYfVzVvIy-XW8KO.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%2F640%2F0%2APpYfVzVvIy-XW8KO.png" alt="image12" width="640" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation (Test Scenario 2)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Scenario 2, we discussed creating a new Incident by clicking on the “+” button on the Main Page.&lt;/p&gt;

&lt;p&gt;Here is the implementation code for 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; @Test
    public void testIncident () {

        MainPage mainPage = new MainPage (androidDriverManager);
        mainPage.createNewIncident ("New incident created using appium automation");
        IncidentListPage incidentListPage = new IncidentListPage (androidDriverManager);

        incidentListPage.searchForIncident ("email");
        incidentListPage.openIncident ();

        assertEquals (incidentListPage.getSeverityText (), "2 - High");
        assertEquals (incidentListPage.getTitle (), "No email! I cant't send or receive anything");
        assertEquals (incidentListPage.getCallerName (), "Francis Soo");
        assertEquals (incidentListPage.getDescription (),
            "I am not able to send or receive any email for the last 24 hours");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The following lines in the above method is used for creating a new incident:&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%2F640%2F0%2A4AaiAXwJ6tuTKF6P.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%2F640%2F0%2A4AaiAXwJ6tuTKF6P.png" alt="image13" width="640" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;NewIncidentPage&lt;/em&gt; class has been created to locate all the elements required for creating a new incident.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class NewIncidentPage {

    private final AndroidDriverManager androidDriverManager;
    private final WebDriverWait        wait;

    public NewIncidentPage (final AndroidDriverManager androidDriverManager) {
        this.androidDriverManager = androidDriverManager;
        this.wait = new WebDriverWait (androidDriverManager.getDriver (), Duration.ofSeconds (30));

    }

    private WebElement callerField () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.id ("com.servicenow.fulfiller:id/valueLayout"));
    }

    private void selectCallerName () {
        callerField ().click ();
        wait.until (ExpectedConditions.elementToBeClickable (AppiumBy.accessibilityId ("Abraham Lincoln")))
            .click ();

    }

    public void setCallerName () {
        selectCallerName ();
    }

    private WebElement shortDescriptionField () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("Short description"));
    }

    public void enterShortDescription (String shortDesc) {
        shortDescriptionField ().sendKeys (shortDesc);
    }

    private WebElement submitBtn () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("Submit"));
    }

    public void clickSubmitBtn () {
        submitBtn ().click ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This page is self-explanatory as it locates the web elements on the &lt;em&gt;New Incident&lt;/em&gt; screen and performs actions on it. However, before we come to this screen, there is a Main screen where we select the Create New Incident option. The MainPage class helps to locate the “&lt;em&gt;create a new incident&lt;/em&gt;” link and perform a click action on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MainPage {

    private final AndroidDriverManager androidDriverManager;

    public MainPage (final AndroidDriverManager androidDriverManager) {
        this.androidDriverManager = androidDriverManager;
    }

    private WebElement quickActionBtn () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("Quick Actions"));
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;createNewIncident()&lt;/em&gt; method is the main method, which takes care of all the steps required to create a new incident. It accepts a parameter called &lt;em&gt;short description&lt;/em&gt;, a mandatory field for creating an incident. This parameter is kept so any text can be supplied from the tests for setting “&lt;em&gt;short description&lt;/em&gt;” while creating a new incident.&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%2F640%2F0%2Ai3P6_9_c2TdqhUFI.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%2F640%2F0%2Ai3P6_9_c2TdqhUFI.png" alt="image14" width="640" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Test your native, hybrid, and web apps across all legacy and latest mobile operating systems on the most powerful&lt;/em&gt;&lt;/strong&gt; &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=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Android emulator&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;online.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For creating a new incident following steps needs to be taken care of:&lt;/p&gt;

&lt;p&gt;Click on the &lt;em&gt;Quick Actions&lt;/em&gt; button — This is done using the &lt;em&gt;clickQuickActionsBtn()&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AIiWPF6ud4bt1sssP.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%2F640%2F0%2AIiWPF6ud4bt1sssP.png" alt="image15" width="400" height="858"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating Quick Actions Button&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AcoHRFmZDE5wK5Tu3.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%2F640%2F0%2AcoHRFmZDE5wK5Tu3.png" alt="image16" width="512" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Quick Actions button&lt;/em&gt; can be located using the accessibility id “&lt;em&gt;Quick Actions&lt;/em&gt;.”&lt;/p&gt;

&lt;p&gt;Accessibility ID is the most preferred locator strategy in Appium. For Android, it is the content-desc property of the element, while for iOS, it’s the &lt;em&gt;accessibility-id&lt;/em&gt; property. It is also one of the fastest-performing locator strategies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;clickQuickActionsBtn() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ATzzx0tIw_-1YWUrv.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%2F640%2F0%2ATzzx0tIw_-1YWUrv.png" alt="image17" width="640" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the &lt;em&gt;Open an incident&lt;/em&gt; option. This is done using the &lt;em&gt;clickOpenAnIncidentOption()&lt;/em&gt; method, which returns a new instance of the &lt;em&gt;NewIncidentPage&lt;/em&gt; 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AHX5zvJojWUUN62K2.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%2F640%2F0%2AHX5zvJojWUUN62K2.png" alt="image18" width="400" height="858"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating Open an incident link&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AwEFVnOVStgLfSPwQ.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%2F640%2F0%2AwEFVnOVStgLfSPwQ.png" alt="image19" width="640" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The “&lt;em&gt;Open an incident&lt;/em&gt;” link can be located using the &lt;em&gt;accessibility id -”Open an incident”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;clickOpenAnIncidentOption() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ALOMJ7BR1esuelKTP.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%2F640%2F0%2ALOMJ7BR1esuelKTP.png" alt="image21" width="640" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the &lt;em&gt;Caller Name&lt;/em&gt; and Short Description to create a new incident — this is done using the &lt;em&gt;selectCallerName()&lt;/em&gt; method and &lt;em&gt;enterShortDescription()&lt;/em&gt; methods, respectively.&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%2F640%2F0%2A8KoVV_7Kh4ARFmDC.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%2F640%2F0%2A8KoVV_7Kh4ARFmDC.png" alt="image23" width="640" height="654"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating Caller Field and Caller Name&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ANEANDy_GaiOGGLfK.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%2F640%2F0%2ANEANDy_GaiOGGLfK.png" alt="image24" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Though the id locator for the &lt;em&gt;callerField&lt;/em&gt; is not listed in the &lt;em&gt;Selected Element&lt;/em&gt; part of the screen. However, in the &lt;a href="https://www.lambdatest.com/blog/document-object-model/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;DOM&lt;/a&gt;, we can see that there is an id corresponding to the field&lt;/p&gt;

&lt;p&gt;Let’s make use of this &lt;em&gt;id locator&lt;/em&gt; to locate the field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Caller Name&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ALMdctJDYesijfueN.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%2F640%2F0%2ALMdctJDYesijfueN.png" alt="image25" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, accessibility id “&lt;em&gt;Abraham Lincoln&lt;/em&gt;” can be used to locate the caller name. Here is the code implementation to select caller name&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Caller field() and selectCallerName() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A4EpTAGJpN3wL7Fmb.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%2F640%2F0%2A4EpTAGJpN3wL7Fmb.png" alt="image27" width="640" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating Short Description field&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AZ_jtS0PE0TU7778J.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%2F640%2F0%2AZ_jtS0PE0TU7778J.png" alt="image28" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accessibility id&lt;/em&gt; — Short description can be used to locate this field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;enterShortDescription() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A0QUGFUcFohpVhnYv.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%2F640%2F0%2A0QUGFUcFohpVhnYv.png" alt="image29" width="640" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As soon as we type the Short Description in the field, the Submit button gets displayed on the screen. On clicking it, we can successfully create a new incident.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating Submit button&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AdVdJjbRHiWws8fpd.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%2F640%2F0%2AdVdJjbRHiWws8fpd.png" alt="image31" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s use the &lt;em&gt;Accessibility id — Submit&lt;/em&gt; to locate the button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;clickSubmitBtn() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AGqn-0CxoYulvZzOO.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%2F640%2F0%2AGqn-0CxoYulvZzOO.png" alt="image32" width="640" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;clickSubmitBtn()&lt;/em&gt; method is created, which clicks on the &lt;em&gt;Submit&lt;/em&gt; button to create a new incident.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation (Test Scenario 3)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this scenario, as discussed in the test strategy, we will navigate to the &lt;em&gt;My All Incidents&lt;/em&gt; page, filter the incidents based on the short description, and verify the contents of the incident.&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%2F640%2F0%2ATmR6ZUeDBTxW3dio.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%2F640%2F0%2ATmR6ZUeDBTxW3dio.png" alt="image33" width="640" height="651"&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%2F640%2F0%2AINu942W6MPzxM4wi.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%2F640%2F0%2AINu942W6MPzxM4wi.png" alt="image34" width="640" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the implementation code for the test:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;testIncident() Test&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AFWtW4G0KpntxSM21.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%2F640%2F0%2AFWtW4G0KpntxSM21.png" alt="image35" width="640" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;IncidentListPage&lt;/em&gt; class is created to locate elements on this page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class IncidentListPage {
    private final AndroidDriverManager androidDriverManager;
    private final WebDriverWait        wait;

    public IncidentListPage (final AndroidDriverManager androidDriverManager) {
        this.androidDriverManager = androidDriverManager;
        this.wait = new WebDriverWait (androidDriverManager.getDriver (), Duration.ofSeconds (30));
    }

    private WebElement seeAllLink () {
        return wait.until (
            ExpectedConditions.visibilityOfElementLocated (AppiumBy.accessibilityId ("My incidents See all")));

    }

    private WebElement filterBtn () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("Filter button off"));
    }

    private WebElement shortDesc () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("Short description"));
    }

    private WebElement applyBtn () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.id ("com.servicenow.fulfiller:id/btn_apply"));
    }

    public void searchForIncident (String searchDesc) {
        seeAllLink ().click ();
        filterBtn ().click ();
        shortDesc ().click ();
        shortDesc ().sendKeys (searchDesc);
        applyBtn ().click ();
    }

    public void openIncident () {
        androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("2 - High"))
            .click ();
    }

    public String getSeverityText () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("2 - High"))
            .getText ();
    }

    public String getTitle () {
        return androidDriverManager.getDriver ()
            .findElement (AppiumBy.accessibilityId ("No email! I cant't send or receive anything"))
            .getText ();
    }

    public String getDescription () {
        return androidDriverManager.getDriver ()
            .findElements (AppiumBy.id ("com.servicenow.fulfiller:id/tv_value"))
            .get (0)
            .getText ();
    }

    public String getCallerName () {
        return androidDriverManager.getDriver ()
            .findElements (AppiumBy.id ("com.servicenow.fulfiller:id/tv_value"))
            .get (1)
            .getText ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;searchForIncident()&lt;/em&gt; method is created to search for an incident based on the text supplied in its method parameter. This method performs the steps to click on the “&lt;em&gt;See All&lt;/em&gt;” link using the seeAll link() method, which returns the WebElement for the link.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the seeAll link&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A_5vKRtJHlvQ32TdC.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%2F640%2F0%2A_5vKRtJHlvQ32TdC.png" alt="image35" width="640" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accessibility id — “My incident See All”&lt;/em&gt; is available to locate the &lt;em&gt;“See All”&lt;/em&gt; link.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;seeAllLink() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2Ali7aCR8kW0Bt3ryG.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%2F640%2F0%2Ali7aCR8kW0Bt3ryG.png" alt="image37" width="640" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, the Filter button is clicked using the &lt;em&gt;filterBtn()&lt;/em&gt; method, which returns the WebElement for the filter button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Filter button&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2APCFhXbr0slCYt_gv.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%2F640%2F0%2APCFhXbr0slCYt_gv.png" alt="image38" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accessibility id — “Filter button off”&lt;/em&gt; can be used to locate the filter button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;filterBtn() method&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ADdy1spZVf0i3r1t2.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%2F640%2F0%2ADdy1spZVf0i3r1t2.png" alt="image39" width="640" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we locate the &lt;em&gt;Short Description&lt;/em&gt; field to enter the respective value in it to create a new incident.&lt;/p&gt;

&lt;p&gt;This field can be located using the &lt;em&gt;Accessibility id- Short description.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the short description field&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AO7Qxozcfm6FtMXh5.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%2F640%2F0%2AO7Qxozcfm6FtMXh5.png" alt="image40" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the short description is entered, the &lt;em&gt;Apply button&lt;/em&gt; is displayed, clicking on it, the incidents with mentioned &lt;em&gt;short description&lt;/em&gt; will be fetched.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Locating the Apply button&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AwYDkIZOzIJaQ7Ngx.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%2F640%2F0%2AwYDkIZOzIJaQ7Ngx.png" alt="image41" width="640" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;shortDesc() and applyBtn() methods&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AMIfi4WQ_-TtWd-GW.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%2F640%2F0%2AMIfi4WQ_-TtWd-GW.png" alt="image" width="640" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the record is retrieved, we need to get the texts from the fields like &lt;em&gt;Caller Name, Title, Description, Severity, etc.&lt;/em&gt; The following methods will help us in getting all the required texts&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%2F640%2F0%2AKlY-WmN5fOApK0tN.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%2F640%2F0%2AKlY-WmN5fOApK0tN.png" alt="image" width="640" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the code from the tests, which will perform all the required assertions&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;IncidentList page assertions&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AHwYU__KMxhcXFNHQ.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%2F640%2F0%2AHwYU__KMxhcXFNHQ.png" alt="image" width="640" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the assertions, we have completed our tests and covered all the scenarios we discussed as per test automation strategy.&lt;/p&gt;

&lt;p&gt;Let’s now run the tests and check the result.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Execution
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;From the IDE using TestNG.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using Maven.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Using TestNG
&lt;/h4&gt;

&lt;p&gt;TestNG is used as a test runner; hence testng.xml has been created. Tests can be run by right-clicking on the file and selecting &lt;strong&gt;Run ‘…\testng.xml’&lt;/strong&gt;. As discussed earlier, we are running the tests on Android platform Version 11 and 12 respectively with devices &lt;em&gt;Samsung Galaxy Note 20 and Samsung Galaxy S21 5G&lt;/em&gt;. All these configurations are set using the &lt;em&gt;testng.xml file.&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;&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="Lambda tests Mobile automation test suite" parallel="tests"&amp;gt;
    &amp;lt;test name="ServiceNow app - Android Mobile Automation"&amp;gt;
        &amp;lt;parameter name="buildName" value="Android Automation with ServiceNow app"/&amp;gt;
        &amp;lt;parameter name="testName" value="ServiceNow App Tests"/&amp;gt;
        &amp;lt;parameter name="app" value="lt://APP10160531401676375222905553"/&amp;gt;
        &amp;lt;parameter name="platformName" value="ANDROID"/&amp;gt;
        &amp;lt;parameter name="platformVersion" value="11"/&amp;gt;
        &amp;lt;parameter name="deviceName" value="Galaxy Note20"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="io.github.mfaisalkhatri.tests.ServiceNowAppTests"&amp;gt;
                &amp;lt;methods&amp;gt;
                    &amp;lt;include name="testLaunchDemoApp"/&amp;gt;
                    &amp;lt;include name="testIncident"/&amp;gt;
                &amp;lt;/methods&amp;gt;
            &amp;lt;/class&amp;gt;
        &amp;lt;/classes&amp;gt;
    &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;
    &amp;lt;test name="ServiceNow app - Android Mobile Automation"&amp;gt;
        &amp;lt;parameter name="buildName" value="Android Automation with ServiceNow app"/&amp;gt;
        &amp;lt;parameter name="testName" value="ServiceNow App Tests"/&amp;gt;
        &amp;lt;parameter name="app" value="lt://APP10160531401676375222905553"/&amp;gt;
        &amp;lt;parameter name="platformName" value="ANDROID"/&amp;gt;
        &amp;lt;parameter name="platformVersion" value="12"/&amp;gt;
        &amp;lt;parameter name="deviceName" value="Galaxy S21 5G"/&amp;gt;
        &amp;lt;classes&amp;gt;
            &amp;lt;class name="io.github.mfaisalkhatri.tests.ServiceNowAppTests"&amp;gt;
                &amp;lt;methods&amp;gt;
                    &amp;lt;include name="testLaunchDemoApp"/&amp;gt;
                    &amp;lt;include name="testIncident"/&amp;gt;
                &amp;lt;/methods&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;The following four values need to be supplied as per the Test Configurations otherwise the tests won’t run:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Username&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LambdaTest Access Key&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These values can be passed as &lt;em&gt;“-DLT_USERNAME= -DLT_ACCESS_KEY=”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test run locally using IntelliJ IDE&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A6IUrj-auSix5rdmN.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%2F640%2F0%2A6IUrj-auSix5rdmN.png" alt="image" width="640" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parallel Execution of the Tests:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The recently performed tests with TestNG were executed concurrently, which means that all the tests were run simultaneously. In contrast, in sequential execution, we need to wait for one test to finish before the next one can begin. Parallel execution is a time-saving approach for test execution because all tests are performed concurrently.&lt;/p&gt;

&lt;p&gt;For performing &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=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;parallel testing in TestNG&lt;/a&gt;, we need to mention &lt;code&gt;parallel=”tests”&lt;/code&gt; in testng.xml. Here, all the test blocks updated in &lt;em&gt;testng.xml&lt;/em&gt; will be executed in parallel.&lt;/p&gt;

&lt;p&gt;Since we’ve incorporated the &lt;em&gt;ThreadLocal&lt;/em&gt; class into our code, our execution is now thread-safe. Consequently, there’s no need to be concerned about issues like overlapping test sessions.&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%2F640%2F0%2AUpxYBPShRzvzzVV4.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%2F640%2F0%2AUpxYBPShRzvzzVV4.png" alt="image" width="640" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Using Maven
&lt;/h4&gt;

&lt;p&gt;To run the tests using Maven, the following steps need to be run:&lt;/p&gt;

&lt;p&gt;From Command Line:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open command Prompt/Terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to the root folder of the project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type the command on the terminal:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;mvn clean test -DLT_USERNAME=&amp;lt; LambdaTest Username &amp;gt; -DLT_ACCESS_KEY=&amp;lt; LambdaTest Access Key &amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Screenshot of the test results run using Maven&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A77kt3Fry1bchxeew.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%2F640%2F0%2A77kt3Fry1bchxeew.png" alt="image" width="640" height="347"&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%2F640%2F0%2ALxD9uw8VHqxIo3k0.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%2F640%2F0%2ALxD9uw8VHqxIo3k0.png" alt="image" width="640" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the tests are run successfully, we can check out the &lt;a href="https://automation.lambdatest.com/build?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;LambdaTest Dashboard&lt;/a&gt; and view all the video recordings, screenshots, device logs, and step-by-step granular details of the test run in the &lt;a href="https://www.lambdatest.com/blog/lambdatest-analytics/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;LambdaTest Analytics&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Check out the screenshots below, which will give you a fair idea of the dashboard for &lt;a href="https://www.lambdatest.com/blog/appium-with-testng-tutorial/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar07_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automated app tests.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest Dashboard&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AZIh2LqYmawpaxMcu.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%2F640%2F0%2AZIh2LqYmawpaxMcu.png" alt="image" width="640" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The details of the build and the tests that were conducted are visible in the following screenshots. Each test includes the test name, browser name, browser version, OS name, respective OS version, and screen resolution, all of which are correctly displayed.&lt;/p&gt;

&lt;p&gt;It also has the video of the test that was run, giving a better idea about how tests were run on the device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;LambdaTest Build Details&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AFTaTN2ooloN5MX5e.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%2F640%2F0%2AFTaTN2ooloN5MX5e.png" alt="image" width="640" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Details with Appium logs&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A550RzolJzZnbX_nr.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%2F640%2F0%2A550RzolJzZnbX_nr.png" alt="image" width="640" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Execution on Samsung Note 20:&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Test Execution on Samsung Galaxy S21 5G:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this ServiceNow with Appium tutorial, we discussed ServiceNow and its related mobile application and how it is useful in the digitization process.&lt;/p&gt;

&lt;p&gt;We automated the ServiceNow mobile application using Service Desk Agent’s persona using Appium by running the tests on the LambdaTest Cloud platform’s Real Android Device. If you liked this blog, don’t forget to share it with your network, who may also benefit from it and help them learn.&lt;/p&gt;

</description>
      <category>appium</category>
      <category>automation</category>
      <category>automationtesing</category>
      <category>cloudtesting</category>
    </item>
    <item>
      <title>Selenium 4 WebDriver Hierarchy: A Detailed Explanation</title>
      <dc:creator>Faisalkhatri123</dc:creator>
      <pubDate>Mon, 06 Mar 2023 09:33:56 +0000</pubDate>
      <link>https://dev.to/testmuai/selenium-4-webdriver-hierarchy-a-detailed-explanation-5fmp</link>
      <guid>https://dev.to/testmuai/selenium-4-webdriver-hierarchy-a-detailed-explanation-5fmp</guid>
      <description>&lt;p&gt;The inception of Selenium can be traced back to a web application that required frequent testing. This prompted Jason Huggins to create a program using JavaScript, which he named JavaScriptTestRunner and released in 2004.&lt;/p&gt;

&lt;p&gt;However, he realized that the program was much more powerful and could be helpful to the community in testing; hence, he decided to open-source it and renamed it to Selenium Core.&lt;/p&gt;

&lt;p&gt;Paul Hammant created Selenium Remote Control (Selenium RC) or Selenium 1, an upgraded version of Selenium Core. It fixed the issue where testers had to install Selenium Core and the web servers containing the web applications. Hence, they belong to the same domain as the Same-origin policy prohibits JavaScript from being used from a different domain name from which it was launched.&lt;/p&gt;

&lt;p&gt;Patrick Lightbody developed &lt;a href="https://www.lambdatest.com/blog/why-selenium-grid-is-ideal-for-automated-browser-testing/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium Grid&lt;/a&gt; for running the tests in parallel to reduce the &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06_ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; time to minimal. Shinya Kasatani from Japan contributed to the creation of &lt;a href="https://www.lambdatest.com/blog/selenium-ide-what-is-it-why-is-it-must-for-every-qa/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06_ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium IDE&lt;/a&gt; in 2006, which helps to automate the browser using record and playback features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/learning-hub/webdriver" rel="noopener noreferrer"&gt;Selenium WebDriver&lt;/a&gt; was created in 2006 by Simon Stewart. Selenium WebDriver is an open-source, cross-platform library designed to help &lt;a href="https://www.lambdatest.com/learning-hub/webdriver?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;automate browser testing&lt;/a&gt;. It is designed to provide a simple and consistent interface for interacting with web browsers and different elements on the web page to simulate user actions on the websites. Over the years, &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webinar" rel="noopener noreferrer"&gt;Selenium&lt;/a&gt; has undergone many changes and improvements and introduced new features per the latest software industry trend.&lt;/p&gt;

&lt;p&gt;It is composed of three main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Language Bindings&lt;/strong&gt; — Language bindings are a set of classes and methods that allow you to use a specific programming language with Selenium WebDriver for writing automated tests for the website. Currently, WebDriver supports multiple programming languages, including Java, C#, Python, Ruby, JavaScript, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WebDriver API&lt;/strong&gt; — The API is a set of classes and methods that allow you to interact with the browser through code. The API allows running the tests on different browsers like Chrome, Firefox, MS Edge, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WebDriver Implementation&lt;/strong&gt; — WebDriver is an interface to access web browsers programmatically. It manages the communication between the language bindings and the browser. It lets you automate and interact with the elements in the DOM.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/learning-hub/data-driven-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Data driven testing&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, let us deep dive into what data driven testing is, its pros &amp;amp; cons, its types, data driven testing in an agile environment, benefits, and their best practices.&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AeipQKmFa8QfBMwtv.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%2F640%2F0%2AeipQKmFa8QfBMwtv.png" alt="image1" width="640" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, &lt;a href="https://www.lambdatest.com/blog/selenium4-w3c-webdriver-protocol/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;Selenium 4 is now W3C Compliant&lt;/a&gt; with &lt;a href="https://www.lambdatest.com/learning-hub/selenium-4?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;Selenium 4.&lt;/a&gt; You may no longer be required to add ‘tweaks’ in the test script to make it work across different browsers, as everything (i.e., browsers &amp;amp; WebDriver APIs) runs in the W3C standard protocol.&lt;/p&gt;

&lt;p&gt;If you are using Selenium 3 and want to get your hands dirty with Selenium 4, please check our detailed guide on &lt;a href="https://www.lambdatest.com/blog/upgrade-from-selenium3-to-selenium4/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;upgrading from Selenium 3 to Selenium 4.&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%2F640%2F0%2AneRedPvtTyBQBvYZ.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%2F640%2F0%2AneRedPvtTyBQBvYZ.png" alt="image2" width="640" height="376"&gt;&lt;/a&gt;&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;p&gt;The introduction of Selenium Manager in Selenium version 4.6.0 is a big relief for the automation test engineers as it is not required to provide the executable driver path, nor do we need to use third-party libraries like &lt;a href="https://www.lambdatest.com/blog/webdrivermanager-in-selenium/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;WebDriverManager&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; to start the browsers. Selenium Manager takes care of these browser drivers. We just need to have the respective driver installed in our machine on which we need to run the tests.&lt;/p&gt;

&lt;p&gt;With WebDriver becoming completely W3C standardized, you can use it across different frameworks without any compatibility issues.&lt;/p&gt;

&lt;p&gt;Though many of us would have used Selenium WebDriver for &lt;a href="https://www.lambdatest.com/automation-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpgae" rel="noopener noreferrer"&gt;automation testing,&lt;/a&gt; there is a lower probability of each of us knowing the internals of architecture. The integral question is, &lt;strong&gt;&lt;em&gt;“Does knowing the internal workings of Selenium and to what extent?.”&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In my experience with Selenium, &lt;a href="https://www.lambdatest.com/appium-mobile-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpgae" rel="noopener noreferrer"&gt;Appium&lt;/a&gt;, and 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=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;automation testing frameworks&lt;/a&gt;, understanding the internals of any framework helps in making the best possible use of the interfaces, classes, and methods provided by the same. We have witnessed how far Selenium has changed from its inception in 2002!&lt;/p&gt;

&lt;p&gt;In this blog on Selenium 4 WebDriver Hierarchy, we will delve into the Selenium 4 WebDriver framework, specifically focusing on the hierarchy of the Selenium WebDriver and the abstract methods and nested interfaces within the WebDriver Interface. Additionally, we will also explore the hierarchy of the WebElement Interface and the abstract methods used within it.&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;Test your&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/puppeteer-testing?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Puppeteer test&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;scripts online. Deploy a quality build faster by running automated checks across over 3000+ browsers and OS combinations with the LambdaTest cloud. Try for free.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selenium WebDriver Hierarchy
&lt;/h3&gt;

&lt;p&gt;As an automation test engineer, we have been using Selenium WebDriver. Currently, while writing this blog on Selenium 4 WebDriver Hierarchy, Selenium’s latest version is 4.7.0. We know that by running the following line of code, the Chrome browser will be started, and we will be able to test the web page further using WebDriver methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebDriver driver = new ChromeDriver();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, very few automation test engineers know about the internal working of the WebDriver Interface. So, let’s dive deep into this and understand how Selenium WebDriver works.&lt;/p&gt;

&lt;p&gt;Here is the pictorial representation of the Selenium WebDriver hierarchy.&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%2F640%2F0%2ASkqteiNRftKJhKJQ.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%2F640%2F0%2ASkqteiNRftKJhKJQ.png" alt="image3" width="640" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  RemoteWebDriver Class
&lt;/h3&gt;

&lt;p&gt;Let’s start with the &lt;a href="https://www.lambdatest.com/blog/selenium-remotewebdriver/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;RemoteWebDriver&lt;/a&gt; class because it is a fully implemented WebDriver Interface class extended by every BrowserDriver class within the Selenium 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ASPTSTETeXFBWEs74.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%2F640%2F0%2ASPTSTETeXFBWEs74.png" alt="image4" width="640" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;RemoteWebDriver class has the following nested classes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RemoteTargetLocator&lt;/strong&gt; — This is a fully implemented class of &lt;em&gt;WebDriver&lt;/em&gt;.&lt;em&gt;TargetLocator&lt;/em&gt; interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RemoteWebDriverOptions&lt;/strong&gt; — This is a fully implemented class of &lt;em&gt;WebDriver&lt;/em&gt;.&lt;em&gt;Options&lt;/em&gt; interface. This class has the following nested classes:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RemoteTimeouts&lt;/strong&gt; — This class implements &lt;em&gt;WebDriver&lt;/em&gt;.&lt;em&gt;Timeouts&lt;/em&gt; interface and provides the full implementation of all its abstract methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RemoteWindow&lt;/strong&gt; — This class implements &lt;em&gt;WebDriver&lt;/em&gt;.&lt;em&gt;Window&lt;/em&gt; interface and provides the full implementation of all its abstract methods.&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A3_Ko0B8NlYFSbmxi.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%2F640%2F0%2A3_Ko0B8NlYFSbmxi.png" alt="image5" width="640" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;In this&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/xcuitest?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;XCUITest&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;tutorial, learn about XCUITest framework and its benefits for mobile automation testing. Take a look at how XCUITest works and see how to use it to test your mobile applications.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use the RemoteWebDriver class?
&lt;/h3&gt;

&lt;p&gt;This class is important for running tests on cloud testing platforms like LambdaTest. As on the cloud platform, we may need to run the tests on multiple browsers and different platforms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cloud Selenium Grid&lt;/a&gt; like LambdaTest offers many benefits, including scalability, reliability, and security, which can be challenging to achieve with a local Selenium Grid. By performing Selenium automation testing on the cloud, it allows for a wider range of browser coverage, &lt;a href="https://www.lambdatest.com/learning-hub/test-coverage?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test coverage&lt;/a&gt;, and &lt;a href="https://www.lambdatest.com/learning-hub/test-execution?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=learning_hub" rel="noopener noreferrer"&gt;test execution&lt;/a&gt; in parallel, which is not possible in a local 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;Subscribe to the &lt;a href="https://www.youtube.com/c/LambdaTest?sub_confirmation=1?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=youtube" 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=mar06ap&amp;amp;utm_term=ap&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=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;Cypress testing&lt;/a&gt;, and more.&lt;/p&gt;

&lt;p&gt;Since we are running on remote machines, we need to provide the remote URL, so the tests get executed correctly on the desired platforms and browsers.&lt;/p&gt;

&lt;p&gt;RemoteWebDriver Class has the following constructors, which can be used to instantiate an instance of the class:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RemoteWebDriver(ICapabilities)&lt;br&gt;&lt;br&gt;
RemoteWebDriver(Uri, ICapabilities)&lt;br&gt;&lt;br&gt;
RemoteWebDriver(ICommandExecutor, ICapabilities)&lt;br&gt;&lt;br&gt;
RemoteWebDriver(Uri, ICapabilities, TimeSpan)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will be using the &lt;em&gt;RemoteWebDriver(Uri, ICapabilities)&lt;/em&gt; to run the tests on the LambdaTest platform. The capabilities shown in this example may differ from platform to platform as per their configuration settings. However, the usage of the RemoteWebDriver class remains the same.&lt;/p&gt;

&lt;p&gt;Here is the screenshot of a method showing how we can use the RemoteWebDriver class to run the tests on the LambdaTest platform.&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%2F640%2F0%2AGScRcgnDawTOpktb.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%2F640%2F0%2AGScRcgnDawTOpktb.png" alt="image6" width="640" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;RemoteWebdriver class implements the following interfaces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;WebDriver&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScriptExecutor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TakesScreenshot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HasVirtualAuthenticator&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PrintsPage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HasCapabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interactive&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s talk about each of the interfaces implemented by RemoteWebDriver class in detail, starting with the WebDriver Interface first.&lt;/p&gt;

&lt;h3&gt;
  
  
  WebDriver Interface
&lt;/h3&gt;

&lt;p&gt;WebDriver Interface is the core of the Selenium WebDriver as it has all the required methods and respective nested interfaces defined within it, which helps in simulating user actions inside the browser.&lt;/p&gt;

&lt;p&gt;Following is the UML diagram of WebDriver Interface (Selenium WebDriver 4):&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%2F640%2F0%2AvMHrIhhlVmoIB4zy.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%2F640%2F0%2AvMHrIhhlVmoIB4zy.png" alt="image7" width="640" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get started with this complete&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/selenium?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Selenium guide&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;of automation testing. Learn what Selenium is, its architecture, advantages and more for automated cross browser testing. Read more.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;WebDriver Interface has the following abstract methods defined in it, which has no body, and these methods are fully implemented by &lt;strong&gt;&lt;em&gt;RemoteWebDriver class&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  How to use the WebDriver Interface?
&lt;/h3&gt;

&lt;p&gt;The WebDriver interface defines methods for interacting with a web page through a web browser. To use the WebDriver interface, you must first import the appropriate libraries and instantiate a WebDriver object.&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%2F640%2F0%2Ad9oia2DdbYQcIUP_.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%2F640%2F0%2Ad9oia2DdbYQcIUP_.png" alt="image8" width="565" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, let’s move toward the nested interfaces within the WebDriver Interface and discuss them in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nested Interfaces within WebDriver Interface
&lt;/h3&gt;

&lt;p&gt;The following are the nested interfaces within the WebDriver Interface. Let’s discuss each nested interface in detail.&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%2F640%2F0%2AICs1Jn0S4DXuSy6V.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%2F640%2F0%2AICs1Jn0S4DXuSy6V.png" alt="image45" width="640" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Window Interface
&lt;/h4&gt;

&lt;p&gt;This interface has all the methods that help manage the current window. Currently, at the time of writing this blog on Selenium 4 WebDriver Hierarchy, Selenium’s latest version is 4.7.0, and in this current version, this Window interface is in &lt;strong&gt;Beta&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A07-N4zFxykH3tyeu.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%2F640%2F0%2A07-N4zFxykH3tyeu.png" alt="image9" width="640" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This interface has the following abstract methods, which are fully implemented by the &lt;strong&gt;&lt;em&gt;RemoteWebDriver Class&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to use the Window Interface with WebDriver?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to instantiate the WebDriver interface by creating a new object by calling its implementing class. Once the object is created, we can simply use the &lt;em&gt;Window interface&lt;/em&gt; as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AgNwxIzuLIhBB_qVn.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%2F640%2F0%2AgNwxIzuLIhBB_qVn.png" alt="image10" width="512" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Options Interface
&lt;/h4&gt;

&lt;p&gt;This interface has all the methods to help manage the stuff in a browser menu. With the help of this interface, we perform the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Add, get, and delete a cookie&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set timeouts in the browser&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Manage window&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fetch different types of logs. &lt;em&gt;(This is in beta as per the latest Selenium WebDriver version 4.7.0)&lt;/em&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AcvPp-lOcoohZN0CS.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%2F640%2F0%2AcvPp-lOcoohZN0CS.png" alt="image11" width="640" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Online&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/selenium-grid-online?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=webpage" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;Selenium Grid&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;to run your browser automation testing scripts on cloud infrastructure containing 3000+ desktop and mobile browser environments. Perform Selenium Testing on a cloud automation testing grid that scales along with your tests.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This interface has the following abstract methods, fully implemented by the &lt;strong&gt;&lt;em&gt;RemoteWebDriver Class&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to use Options Interface with WebDriver?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to instantiate the WebDriver interface by creating a new object by calling its implementing class. Once the object is created, we can simply use the Options interface, as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AnxVOsIOVUs6YK09P.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%2F640%2F0%2AnxVOsIOVUs6YK09P.png" alt="image12" width="512" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Navigation Interface
&lt;/h4&gt;

&lt;p&gt;This interface has all the methods to access the browser’s history and navigate to a URL. With the help of this interface, we perform the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Navigate Back, Forward in the browser&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to a URL in the browser&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Refresh the WebPage&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AUE2LZ0Yytjq0VJi8.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%2F640%2F0%2AUE2LZ0Yytjq0VJi8.png" alt="image13" width="512" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This interface has the following abstract methods, which are fully implemented by the &lt;strong&gt;&lt;em&gt;RemoteWebDriver Class:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to use Navigations Interface with WebDriver?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to instantiate the WebDriver interface by creating a new object by calling its implementing class. Once the object is created we can simply use the &lt;em&gt;Window interface&lt;/em&gt; as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A9SIXkuh7gep7ceWu.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%2F640%2F0%2A9SIXkuh7gep7ceWu.png" alt="image14" width="532" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  TargetLocator Interface
&lt;/h4&gt;

&lt;p&gt;This interface has all the methods to send future commands to different frames and windows. With the help of this interface, we perform the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Working with different Frames.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Working with different windows or Tabs in the browser.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Working with different Alerts in the browser.&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2ArNUETUhApb_Cjb7Z.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%2F640%2F0%2ArNUETUhApb_Cjb7Z.png" alt="image15" width="640" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This interface has the following abstract methods, fully implemented by the &lt;strong&gt;&lt;em&gt;RemoteTargetLocator class&lt;/em&gt;&lt;/strong&gt;, which is a nested class in the &lt;strong&gt;&lt;em&gt;RemoteWebDriver class:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to use TargetLocator Interface with WebDriver?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to instantiate the WebDriver interface by creating a new object by calling its implementing class. Once the object is created, we can simply use the TargetLocator interface, as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AqQEkfeo8Drh2EDTH.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%2F640%2F0%2AqQEkfeo8Drh2EDTH.png" alt="image17" width="558" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Timeouts Interface
&lt;/h4&gt;

&lt;p&gt;This interface has all the methods to manage the timeout behavior for WebDriver instances. With the help of this interface, we perform the following &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=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;wait actions in Selenium:&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Implicit Wait&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Script timeout&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Page load timeout&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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2A9ZeAW44oOb8Q54dE.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%2F640%2F0%2A9ZeAW44oOb8Q54dE.png" alt="image18" width="640" height="578"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This interface has the following abstract methods, which are fully implemented by the &lt;strong&gt;&lt;em&gt;RemoteTimeouts class&lt;/em&gt;&lt;/strong&gt;, which is a nested class in the &lt;strong&gt;&lt;em&gt;RemoteWebDriver class&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How to use Timeouts Interface with WebDriver?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to instantiate the WebDriver interface by creating a new object by calling its implementing class. Once the object is created, we can simply use the Timeouts interface as shown in 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%2Fcdn-images-1.medium.com%2Fmax%2F640%2F0%2AUjnLM4pZd3fhPI42.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%2F640%2F0%2AUjnLM4pZd3fhPI42.png" alt="image19" width="567" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following methods are deprecated as per the current Selenium Version 4.7.0:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;implicitlyWait(long time, TimeUnit unit)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;setScriptTimeout(long time, TimeUnit unit)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;pageLoadTimeout(long time, TimeUnit unit)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;setScriptTimeout()&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s now move towards the next interface that is implemented by RemoteWebDriver class.&lt;/p&gt;

&lt;h4&gt;
  
  
  JavaScriptExecutor Interface
&lt;/h4&gt;

&lt;p&gt;JavaScriptExecutor Interface provides the mechanism to WebDriver so that it can execute JavaScript code snippets. This interface has the following two abstract methods, which are fully implemented in the &lt;em&gt;RemoteWebDriver class&lt;/em&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  TakesScreenshot Interface
&lt;/h4&gt;

&lt;p&gt;This interface helps the WebDriver take screenshots of the web page or WebElement as required and store them in different ways. The screenshot captured is returned to the WebDriver endpoint in Base64 format.&lt;/p&gt;

&lt;p&gt;This interface has the following abstract method, which is implemented in the &lt;strong&gt;&lt;em&gt;RemoteWebDriver class&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  HasVirtualAuthenticator Interface
&lt;/h4&gt;

&lt;p&gt;This interface helps in allowing the WebDriver to access the virtual authenticator API.&lt;/p&gt;

&lt;p&gt;A user’s public-key credentials can be stored in a hardware device, or a software entity called an authenticator. Authenticators help enable the key-based authentication mechanism in a passwordless manner. Virtual Authenticator emulates such authenticators for testing.This interface has the following abstract methods, which are fully implemented by the &lt;strong&gt;&lt;em&gt;RemoteWebDriver class&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  PrintsPage Interface
&lt;/h4&gt;

&lt;p&gt;This interface allows the printing of the current page within the browser. It has the following abstract method, which is fully implemented in RemoteWebDriver class:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  HasCapabilities Interface
&lt;/h4&gt;

&lt;p&gt;This interface can be used for run-time detection of features by classes to indicate that they can describe their capabilities.&lt;br&gt;&lt;br&gt;
This interface is fully implemented by the RemoteWebDriver class and has the following abstract method:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With this, we come to the end of the discussion on the WebDriver interface. Let’s now jump on to another important topic around Selenium WebDriver, which is about WebElements and understanding its hierarchy.&lt;/p&gt;

&lt;h3&gt;
  
  
  WebElement Hierarchy
&lt;/h3&gt;

&lt;p&gt;Knowing about WebElement hierarchy is also required. We can not run the &lt;a href="https://www.lambdatest.com/learning-hub/web-automation" rel="noopener noreferrer"&gt;web automation&lt;/a&gt; tests unless we locate the WebElements on the page to perform the required user simulation steps.&lt;/p&gt;

&lt;p&gt;WebElement is an interface that extends the SearchContext and TakesScreenshot interfaces.&lt;br&gt;&lt;br&gt;
RemoteWebElement class is the fully implemented class of the WebElement interface.&lt;/p&gt;

&lt;p&gt;The following image shows the WebElement in pictorial representation:&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%2F640%2F0%2A-BwhXaTUKI3sQ9gI.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%2F640%2F0%2A-BwhXaTUKI3sQ9gI.png" alt="image25" width="640" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Which are the most wanted&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/automation-testing-tools/?utm_source=devto&amp;amp;utm_medium=organic&amp;amp;utm_campaign=mar06ap&amp;amp;utm_term=ap&amp;amp;utm_content=blog" rel="noopener noreferrer"&gt;&lt;strong&gt;&lt;em&gt;test automation tools&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;&lt;em&gt;that have climbed the top of the ladder so far? Let’s take a look.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Abstract methods declared within the WebElement Interface
&lt;/h3&gt;

&lt;p&gt;As you can check in the UML diagram below, abstract methods are declared, which are implemented by the RemoteWebElement and EventFiringWebElement classes:&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%2F640%2F0%2AbRDLn_LJ-hjwuWZw.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%2F640%2F0%2AbRDLn_LJ-hjwuWZw.png" alt="image27" width="640" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;get(String url)&lt;/td&gt;
        &lt;td&gt;This method will return void and help us to navigate to the URL we provide in the method parameter. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getCurrentUrl()&lt;/td&gt;
        &lt;td&gt;This method will return the current URL of the web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getTitle()&lt;/td&gt;
        &lt;td&gt;This method will return the title of the current web page. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElements(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a list of webelements per the locator strategy called using Selenium’s By class which is an abstract class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;findElement(By by)&lt;/td&gt;
        &lt;td&gt;This method will return a webelement as per the locator strategy called using Selenium’s By class. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getPageSource()&lt;/td&gt;
        &lt;td&gt;This method will return the source of the last loaded page in the representation of DOM. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;close()&lt;/td&gt;
        &lt;td&gt;This method will close the current window and quit the browser if it is the last window currently open. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;quit()&lt;/td&gt;
        &lt;td&gt;This method quits the driver session, closing every associated window. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandles()&lt;/td&gt;
        &lt;td&gt;This method will return a set of window handles that can be used to iterate over all open windows of this WebDriver instance. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;getWindowHandle()&lt;/td&gt;
        &lt;td&gt;This method returns the current window handle, which is in focus within the current WebDriver instance. This can be used to switch to this window at a later stage. &lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;With this, we come to the end of this blog on Selenium 4 WebDriver Hierarchy explaining the Selenium WebDriver’s architecture. Let’s summarize the points that we discussed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;With this blog on Selenium 4 WebDriver Hierarchy, I hope you are now fully aware and better understand the Selenium WebDriver architecture. I hope you will be able to utilize this knowledge in your project and make efficient use of the Selenium WebDriver framework. Some key takeaways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;RemoteWebDriver class is the fully implemented class of the WebDriver interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteWebDriver class implements the following interfaces:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebDriver&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScriptExecutor&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HasCapabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HasVirtualAuthenticator&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interactive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PrintsPage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TakesScreenshot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Each BrowserDriver (ChromeDriver, FirefoxDriver, etc.) class extends the RemoteWebDriver class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteWebDriver class has the following nested classes:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteTargetLocator&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteWebDriverOptions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteTargetLocator class which is a nested class within RemoteWebDriver class that implements the WebDriver.TargetLocator interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteWebDriverOptions which is a nested class of RemoteWebDriver class, implements the WebDriverOptions interface, and it has the following nested classes within it:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteTimeout — This class implements the WebDriver.Timeouts interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteWindow — This class implements the WebDriver.Window interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebDriver interface extends SearchContext interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebDriver interface has the following nested interfaces:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Options&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Window&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Timeouts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TargetLocator&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WebElement interface implements the SearchContext and TakeScreenshot interfaces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RemoteWebElement and EventFiringWebElement classes are fully implemented classes of the WebElement interface.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

</description>
      <category>selenium</category>
      <category>webdriver</category>
      <category>automationtesting</category>
      <category>cloudtesting</category>
    </item>
  </channel>
</rss>
