<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: ramitd1995</title>
    <description>The latest articles on Forem by ramitd1995 (@ramitd1995).</description>
    <link>https://forem.com/ramitd1995</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%2F200227%2F1125c360-a260-45cc-884d-c06b9936fce3.png</url>
      <title>Forem: ramitd1995</title>
      <link>https://forem.com/ramitd1995</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ramitd1995"/>
    <language>en</language>
    <item>
      <title>Nightwatch.js Tutorial For Test Automation Beginners – With Examples</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Mon, 09 Mar 2020 17:27:52 +0000</pubDate>
      <link>https://forem.com/ramitd1995/nightwatch-js-tutorial-for-test-automation-beginners-with-examples-1dml</link>
      <guid>https://forem.com/ramitd1995/nightwatch-js-tutorial-for-test-automation-beginners-with-examples-1dml</guid>
      <description>&lt;p&gt;Selenium is a widely used tool for automated browser testing. Being an open-source framework allowed Selenium to be compatible with multiple test automation frameworks for different programming languages and if we talk about &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;Automation testing with Selenium&lt;/a&gt; and JavaScript, there is a particular framework that never fails to take the spotlight and that is the Nightwatch.js. This is why I decided to come up with Nightwatch.js tutorial for beginners.&lt;/p&gt;

&lt;p&gt;In this blog post, we will deep dive into a step by step Nightwatch JS tutorial to perform testing with Selenium and JavaScript for &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;automated browser testing&lt;/a&gt;. We will explore how we can install and setup Nightwatch JS and look into details about its configuration and the important files and folder structure. Later we will also look at executing our first Nightwatch.js test automation script and what are some of the issues that we might encounter, along with their resolutions. Let’s kickstart this Nightwatch.js tutorial for beginners with a basic introduction.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Nightwatch.js?
&lt;/h2&gt;

&lt;p&gt;Powered by Node.js, Nightwatch.js is an open-source automated testing framework that aims at providing complete E2E (end to end) solutions to automate testing with Selenium Javascript for web-based applications, browser applications, and websites. This framework relies on Selenium and provides several commands and assertions within the framework to perform operations on the DOM elements. It internally uses the powerful W3C WebDriver API or the Selenium WebDriver and simplifies writing end to end &lt;a href="https://www.lambdatest.com/blog/19-best-practices-for-automation-testing-with-node-js/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;automated tests in Node.js&lt;/a&gt; and effortlessly sets up for Continuous Integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Nightwatch.js Is So Popular?
&lt;/h2&gt;

&lt;p&gt;Before we deep dive to executing test scripts in this Nightwatch.js tutorial for beginners. It is important to understand the reasons behind the popularity of Nightwatch.js. Nightwatch.js facilitates an end to end functional browser testing in a pure node.js environment which enables testing of web applications independent from third party software. The key purpose of lightweight and robust automated testing frameworks such as Nightwatch.js is to enable a single integrated solution for application testing. Since Nightwatch JS is built on Node.js, it has some major advantages over any other &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;Selenium automation testing tool&lt;/a&gt;. This automated browser testing powered by Nightwatch.js eliminates the dependency factor upon third party software consequently enhancing data integrity among diverse system components.&lt;/p&gt;

&lt;p&gt;Nightwatch JS provides the following out of the box features:&lt;/p&gt;

&lt;p&gt;➝   &lt;strong&gt;In Built Test Runner:&lt;/strong&gt; It comes with an inbuilt command-line test runner suite with Grunt support for executing the automated tests.&lt;/p&gt;

&lt;p&gt;➝   &lt;strong&gt;Test Strategy:&lt;/strong&gt; It has the feature to execute the tests efficiently and can be performed in many ways such as parallelly, sequentially or in groups, and tags.&lt;/p&gt;

&lt;p&gt;➝   &lt;strong&gt;Cloud Services:&lt;/strong&gt; A good support for Cross Browser Testing with Selenium JavaScript by providing integration with the cloud-based Selenium testing providers like LambdaTest.&lt;/p&gt;

&lt;p&gt;➝   &lt;strong&gt;Selenium Server:&lt;/strong&gt; Ability to automatically control the standalone Selenium server with JUnit XML reporting built in.&lt;/p&gt;

&lt;p&gt;➝   &lt;strong&gt;Assertions, CSS, and XPath:&lt;/strong&gt; Several commands and assertions for DOM operations, CSS and XPath selectors and can be used to identify the elements on the page. This makes the framework flexible and easy to extend especially while implementing the application-specific commands and assertions.&lt;/p&gt;

&lt;p&gt;➝   &lt;strong&gt;Continuous Integration:&lt;/strong&gt; It offers good support for Continuous Integration and hence can be used to integrate the tests with the continuous build processing systems such as Jenkins, TeamCity, etc. and assist developers in building and testing software continuously.&lt;/p&gt;

&lt;p&gt;Apart from all the above features that it provides, it is popular for having a clean and easy syntax, making it easier to write the tests efficiently and quickly by only making use of Node.js &lt;a href="https://www.lambdatest.com/blog/how-pro-testers-use-css-selectors-in-selenium-automation-scripts/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;CSS selectors&lt;/a&gt; and XPath locator in Selenium&lt;/p&gt;

&lt;h2&gt;
  
  
  How does Nightwatch JS works?
&lt;/h2&gt;

&lt;p&gt;Nightwatch communicates over a restful API protocol that is defined by the W3C WebDriver API. It needs a restful HTTP API with a Selenium JavaScript WebDriver server.&lt;/p&gt;

&lt;p&gt;In order to perform any operation i.e. either a command or assertion, Nightwatch usually requires sending a minimum of two requests. It works as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first request locates the required element with the given XPath expression or CSS selector.&lt;/li&gt;
&lt;li&gt;The second request takes the element and performs the actual operation of command or assertion.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation and Prerequisites For Nightwatch.js
&lt;/h2&gt;

&lt;p&gt;There are some basic prerequisites that are required to get started with this Nightwatch JS tutorial for testing with Selenium and JavaScript.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js:&lt;/strong&gt; Nightwatch module is built on top of a Node.js, it indicates that Node.js is required to be installed on the system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node Package Manager (npm):&lt;/strong&gt; Once Node.js installed , the node’s package manager i.e. npm can be leveraged to install the package which is the largest ecosystem of packages.
Now, to install the latest version using the npm command line tool, the below command is executed (here ‘g’ is for installing globally):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -g nightwatch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The below command will place the Nightwatch executable (‘–save-dev’) in our ./node_modules/.bin folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install --save-dev nightwatch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Java – SDK:&lt;/strong&gt; Selenium requires Java for its remote Selenium Server. Since Nightwatch relies upon the Selenium WebDriver API and also requires a Selenium WebDriver Server, hence there is also a need to install the Java Development Kit (JDK 7+) on the system and configure the JAVA environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Selenium Server:&lt;/strong&gt; It requires a Selenium standalone server package JAR which can be downloaded from the Selenium downloads page. Once downloaded, it needs to be placed in the bin folder of the project and the selenium server can be started using the command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
selenium-server-standalone-{version}.jar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chrome Driver:&lt;/strong&gt; Lastly, it requires a Chrome Driver, which is a standalone server that implements the W3C Web Driver wire protocol for Chromium. This executable also needs to be placed inside the same bin folder.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install --save-dev chromedriver&amp;lt;/pre&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuring and Setting up Nightwatch.js
&lt;/h2&gt;

&lt;p&gt;Now, that we have covered the basics in detail, it is now time to deep dive in automation testing with Selenium and JavaScript through this Nightwatch.js tutorial for beginners. Nightwatch.js offers an in-built test runner which expects a JSON configuration file to be passed. The default configuration file is &lt;strong&gt;nightwatch.json&lt;/strong&gt; which should be present in the project’s root directory. Alternatively, the &lt;strong&gt;nightwatch.conf.js&lt;/strong&gt; configuration file can also be used and will be loaded from the root directory of the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If both the configuration files are present in the directory, the nightwatch.conf.js is given precedence as it provides us with a little more flexibility and can have comments in the file.&lt;/p&gt;

&lt;p&gt;You can even declare specific test details under this configuration file such as test environments, Selenium specific settings, etc. This is how a &lt;strong&gt;nightwatch.json&lt;/strong&gt; configuration file looks like for testing with Selenium and JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "src_folders" : ["tests"],
  "output_folder" : "reports",
  "custom_commands_path" : "",
  "custom_assertions_path" : "",
  "page_objects_path" : "",
  "globals_path" : "",
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  },
  "selenium" : {
    "start_process" : true,
    "server_path" : "node_modules/selenium-standalone/.selenium/selenium-server/",
    "log_path" : "./reports",
    "host": "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "",
      "webdriver.gecko.driver" : "",
      "webdriver.edge.driver" : ""
    }
  },

  "test_settings" : {
    "default" : {
      "launch_url" : "http://localhost",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "marionette": true,
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },

    "chrome" : {
      "desiredCapabilities": {
        "browserName": "chrome"
      }
    },

    "edge" : {
      "desiredCapabilities": {
        "browserName": "MicrosoftEdge"
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let us have a close look at the structure of the nightwatch.json configuration file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;src_folders:&lt;/strong&gt; This is directory indicates the location that contains the test suites&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;output_folder:&lt;/strong&gt; This is directory indicates the location that contains and saves the test reports i.e. JUnit report files, XML reports, test logs, selenium log, screenshots, video logs, network logs, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;globals_path:&lt;/strong&gt; This indicates the file path where all the global parameters used in the test suite are initialized. These are loaded and presented to the tests as a global property and can also be modified inside a test_settings environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;test_workers:&lt;/strong&gt; This property defines whether or not we want to run the test suites in parallel. If enabled is set to true it indicates that parallelization is allowed for the testing strategy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;page_objects_path:&lt;/strong&gt; This indicates the location where the page object file is supposed to be loaded from.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;selenium:&lt;/strong&gt; This contains all the information and customization related to Selenium Server configuration. It additionally contains the server_path and webdriver.chrome.driver which indicates the path to the selenium server and the chrome driver respectively. Also, if the start_process parameter is set to true it points out the Selenium Server to start automatically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;test_settings:&lt;/strong&gt; This contains all the important information related to tests and options to configure them. It allows us to define and customize the test environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Execution of The First Script on A Local Selenium WebDriver Setup
&lt;/h2&gt;

&lt;p&gt;We will start the automation testing in Nightwatch.js tutorial for beginners with an example where the test script that we are going to execute will search Nightwatch on Google and then check the Nightwatch JS documentation on the website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  'NW test on Google' : function (client) {
    client
      .url('http://www.google.com')
      .waitForElementVisible('body', 1000)
      .assert.title('Google')
      .assert.visible('input[type=text]')
      .setValue('input[type=text]', 'Nightwatch JS')
      .waitForElementVisible('button[name=btnG]', 1000)
      .click('button[name=btnG]')
      .pause(1000)
      .assert.containsText('ol#rso li:first-child',
        'Nightwatch.js | Node.js powered End-to-End testing framework')
      .end()
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We are free to modify the &lt;strong&gt;nightwatch.json&lt;/strong&gt; configuration file and the global module file i.e &lt;strong&gt;nightwatch.globals.js&lt;/strong&gt; as per our needs but it should look something similar to the below file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "src_folders" : ["./tests"],
  "output_folder" : "./reports",
  "globals_path" : "nightwatch.globals.js",
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  },
  "selenium" : {
    "start_process" : true,
    "server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.59.jar",
    "log_path" : "nw/logs",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./node_modules/chromedriver/bin/chromedriver",
      "webdriver.ie.driver" : ""
    }
  },
  "test_settings" : {
    "default" : {
      "launch_url" : "http://google.com",
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "path" : ""
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },
    "french" : {
      "launch_url" : "http://google.fr",
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It is important to add the below section in the package.json file to execute the tests folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scripts": {
    "test": "./node_modules/.bin/nightwatch -e firefox,edge,safari test"
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The final thing we are required to do is to execute the tests from the base directory of the project using the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command with validate the tests and dependencies and then execute the test suite, which will open up Chrome and then Google the given search string. Below is a screenshot of the test execution that shows up the search result on Google.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j3luqxqy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/nightwatch_js.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j3luqxqy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/nightwatch_js.png" alt="nightwatch_js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallel Testing With Nightwatch.js In Local Selenium WebDriver
&lt;/h2&gt;

&lt;p&gt;We have made our configuration to execute the tests in parallel by enabling the test_workers to true. So, we are just required to add one new test in the test folder and the framework will execute both the test in parallel.&lt;/p&gt;

&lt;p&gt;The second test will search Node.js on google and check out the Node.js documentation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  'NJS test on Google' : function (client) {
    client
      .url('http://www.google.com')
      .waitForElementVisible('body', 1000)
      .assert.title('Google')
      .assert.visible('input[type=text]')
      .setValue('input[type=text]', 'node.js')
      .waitForElementVisible('button[name=btnG]', 1000)
      .click('button[name=btnG]')
      .pause(1000)
      .assert.containsText('ol#rso li:first-child',
        'Node.js')
      .end()
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we will observe that two different tests will be executed at the same time in two different Chrome browsers. Below is a screenshot of the test execution that shows up the search result on Google.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UQYPdJXu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/Picture1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UQYPdJXu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/Picture1.png" alt="Picture1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges Around Infrastructure Structure Setup for Automated Testing
&lt;/h2&gt;

&lt;p&gt;Selenium leads the market in web automation testing by offering great support for testing frameworks and automated browser testing. On the contrary, there are some pain points that an automation tester may encounter while leveraging &lt;a href="https://www.lambdatest.com/support/docs/javascript-with-selenium-running-javascript-automation-scripts-on-lambdatest-selenium-grid/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;Selenium JavaScript testing&lt;/a&gt; using an in-house Selenium infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Coverage During Cross Browser Testing
&lt;/h3&gt;

&lt;p&gt;When we &lt;a href="https://www.lambdatest.com/blog/performing-cross-browser-testing-with-lambdatest/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;perform cross browser testing&lt;/a&gt; on our in-house hosted web application setup, we tend to eliminate any of the issues with the user interface and are able to make certain changes if required and then migrate the code in live setup for web traffic. All this is fine, but one concern that arises is the test coverage. This is mainly because the testing can only be performed on the browsers that are installed locally in the system. There is a need to perform the test on all the important browsers for successful &lt;a href="https://www.lambdatest.com/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;cross browser testing&lt;/a&gt;. Sometimes, testing on some old browsers or browser versions is also required for a specific set of users and operating systems. So you need to test over different combinations of browsers and operating systems, and that is not feasible with a local inhouse Selenium infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cost Incurred During Local Infrastructure Setup
&lt;/h3&gt;

&lt;p&gt;There is always an infrastructure cost when performing certain automated tests and when having a local in-house selenium setup.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is a need to configure a separate test environment to execute all the test cases.&lt;/li&gt;
&lt;li&gt;Different types of devices such as desktop, mobile, tablets, etc. are required and should be a part of the test strategy.&lt;/li&gt;
&lt;li&gt;A device lab setup with has all the required devices can also be invested in but this is not a good choice for startups or small scale organizations as they may refrain from huge invested initially.&lt;/li&gt;
&lt;li&gt;As an automated test may increase in number during the testing phase, hence it requires the system to be scalable enough to handle this scenario.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alternatively, a virtual machine or simulator can be used to perform automation testing in a local setup for hosted web-applications, but these again require proper maintenance, impacts system performance and are time-consuming.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cloud-Based Selenium Grid Is A Good Call to Make?
&lt;/h2&gt;

&lt;p&gt;When it comes to automated browser testing then cloud-based Selenium Grid is a good call. A cloud-based infrastructure will help you with access to hundreds of browsers + operating system combinations, hosted on the provider’s cloud server. That way, you can be free from the hassle of maintaining your Selenium Grid as you get to run your test with zero-downtime. Another benefit of using a testing cloud is that it provides an adaptive environment that is already set up with frameworks so that the users can execute the tests using any framework of their choice as per the requirement.&lt;/p&gt;

&lt;p&gt;Also, The testing cloud is highly scalable and provides us the privilege to use the infrastructure as per needed to run any number of tests in parallel or at the same time. Hence, when adopting a cloud testing strategy there is just a need to modify your test scripts, but the infrastructure setup used to execute the tests remains the same.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which Cloud-Based Selenium Grid Should You Go For?
&lt;/h3&gt;

&lt;p&gt;LambdaTest is trusted by 100,000 companies throughout the globe as a reliable &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;online Selenium Grid&lt;/a&gt; provider to fulfill their cross browser testing needs.Using LambdaTest, you can perform both automated browser testing with a cloud-based Selenium Grid of 2000+ real browsers for both mobile and desktop to help you gain the maximum test coverage during the automated browser testing.&lt;/p&gt;

&lt;p&gt;Our Selenium Grid allows you to execute automation test scripts in Selenium on various programming platforms such as Java, JavaScript, PHP, Python, Ruby, C# and other languages that provide bindings with Selenium.&lt;/p&gt;

&lt;p&gt;You can also choose to integrate with a variety of CI/CD tools such as Jenkins, Travis CI, and more for &lt;a href="https://www.lambdatest.com/blog/how-to-implement-continuous-testing-in-devops-like-a-pro/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;continuous testing in DevOps&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can even leverage &lt;a href="https://www.lambdatest.com/blog/speed-up-automated-parallel-testing-in-selenium-with-testng/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;parallel testing with Selenium&lt;/a&gt; automation testing, along with our open Selenium API to help you extract test reports of your Selenium script execution over LambdaTest, in an effortless manner. Let us try and execute the above test case using the remote WebDriver for LambdaTest Selenium Grid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Execute Nightwatch.js Script Using Remote Selenium Grid
&lt;/h2&gt;

&lt;p&gt;Executing test scripts on the LambdaTest Selenium Grid with Nightwatch.js is pretty simple and straightforward and will be the focus of further sections in this Nightwatch.js tutorial for automation testing with Selenium and JavaScript. we can use our existing local test script and configuration files by changing a few lines of code. To begin first we would need to invoke Selenium remote Webdriver instead of our previous local browser web driver. Also, since now we are using a remote web driver with LambdaTest, we have the flexibility to define the browser environment where we would want to execute our tests. We can do that by passing browser and environment details to the LambdaTest Selenium grid via the desired capabilities class. LambdaTest provides us with the Capabilities Generator to select and pass the browser details and environment specifications with various combinations to choose from.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--79O-U4te--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/lambdatest_desired_capability.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--79O-U4te--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/lambdatest_desired_capability.png" alt="lambdatest_desired_capability"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;Visit LambdaTest Selenium Desired Capabilities Generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, in our case the desiredCapabilities class in nightwatch.json configuration file will look similar as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
"desiredCapabilities": {
        "build" : "Nightwatch-Selenium-Test",
        "name" : "Nightwatch-Selenium-Test",
        "platform" : "Windows 10",
        "browserName" : "Firefox",
        "version" : "71.0",
        "selenium_version" : "3.4.0",
        "geoLocation" : "IN"
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, we would also need to generate our access key token which is like a secret key to connect to our platform and execute the tests on LambdaTest. This access key is unique and can be copied or regenerated from the profile section of our account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x1T-REx1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/Picture2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x1T-REx1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/Picture2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, we can also get the access key, username and hub details from the &lt;a href="https://automation.lambdatest.com/"&gt;Automation dashboard&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8wS5XMrF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/pasted-image-0-9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8wS5XMrF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/pasted-image-0-9.png" alt="lambdatest-tunnel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the nightwatch.conf.js file where we need to declare the user configuration for an access key, username, host, and port for the test.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = (function(settings) {
  console.log(settings["test_settings"]["default"]["username"])
  if (process.env.LT_USERNAME) {
    settings["test_settings"]["default"]["username"] = process.env.LT_USERNAME;
  }
  if (process.env.LT_ACCESS_KEY) {
    settings["test_settings"]["default"]["access_key"] = process.env.LT_ACCESS_KEY;
  }
  if (process.env.SELENIUM_HOST) {
    settings.selenium.host = process.env.SELENIUM_HOST;
  }
  if (process.env.SELENIUM_PORT) {
    settings.selenium.host = process.env.SELENIUM_PORT;
  }
  return settings;
})(require('./nightwatch.json'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, since we are using LambdaTest, we would like to leverage it and execute our tests on different browsers and operating systems. Here, we would be using three different browsers i.e, &lt;strong&gt;Microsoft Edge, Mozilla Firefox and Apple Safari&lt;/strong&gt; and operating systems like &lt;strong&gt;Windows 10 and macOS 10.13&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So after making the required changes our final configuration files will look like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "src_folders" : ["./tests"],
  "output_folder" : "./reports",
  "globals_path" : "nightwatch.globals.js",
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  },
  "selenium" : {
    "start_process" : false,
    "server_path" : "",
    "log_path" : "",
    "host" : "hub.lambdatest.com",
    "port" : 80,
    "cli_args" : {
    "webdriver.chrome.driver" : "",
    "webdriver.ie.driver" : "",
    "webdriver.firefox.profile" : ""
    }
  },
  "test_settings" : {
    "default" : {
    "launch_url" : "http://google.com",
    "selenium_port"  : 80,
    "selenium_host"  : "https://lambdatest.com",
    "silent": false,
    "screenshots" : {
        "enabled" : true,
        "path" : ""
    },
    "username" : "irohitgoyal",
    "access_key" : "UZwDAcLTJQpE1Bl23n2CxBspq4NEoLouBXlORVUS3ilzinRt4k",

    "skip_testcases_on_fail": false,

    "desiredCapabilities": {
       "build":"Nightwatch-Selenium--Test",
    "platform" : "Windows 10",
    "browserName" : "Chrome",
        "version" : "78.0",
        "selenium_version" : "3.13.0",
    "visual":true,
        "video":true,
        "console":true,
        "geoLocation" : "IN",
        "chrome.driver" : "78.0",
        "network":true
    }
    },
    "chrome": {
    "desiredCapabilities": {
        "platform": "Windows 10",
        "browserName": "chrome",
        "version": "78.0"
    }
    },
    "safari" : {
    "desiredCapabilities": {
        "platform": "macos 10.13",
        "browserName": "safari",
        "version": "11.0"
    }
    },
    "firefox" : {
    "desiredCapabilities": {
        "platform": "win10",
        "browserName": "firefox",
        "version": "60"
    }
    },
    "edge" : {
    "desiredCapabilities": {
        "platform": "Windows 10",
        "browserName": "MicrosoftEdge",
        "version": "17.0"
    }
    },
    "french" : {
    "launch_url" : "http://google.fr",
    "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true
    }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, it is important to add the below section in the scripts class as arguments in package.json file to specify the desired capabilities environments we would want our tests to execute on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scripts": {
    "test": "./node_modules/.bin/nightwatch -e firefox,edge,safari test"
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The final thing we are required to do is to execute the tests from the base directory of the project using the command:&lt;br&gt;&lt;br&gt;
&lt;code&gt;npm test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command with validate the tests and dependencies and then execute the test suite, which will run our tests and open the Edge, Firefox and Safari browsers on the environment specified and then Google the given search string. Below we have a screenshot that shows our Nightwatch code running over different browsers using LambdaTest Selenium Grid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UTvmPXBB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/Nightwatch_3-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UTvmPXBB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/12/Nightwatch_3-1.png" alt="Nightwatch_3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can notice, the script was run in parallel across Mozilla Firefox, Safari, Google Chrome, and Edge browsers. The results will be displayed on the command line interface that we used to execute the test and also will be captured in detail on the interactive LambdaTest automation dashboard. LambdaTest dashboard will help us consolidate all the details of the test and we can view all our text logs, screenshots and video recording for all our Selenium tests performed.&lt;/p&gt;

&lt;h2&gt;
  
  
  That Is All For This Nightwatch.js Tutorial
&lt;/h2&gt;

&lt;p&gt;In this Nightwatch.js tutorial for beginners, we have covered various aspects of automation testing with Selenium Javascript. We are now clear about the approach for an end to end automation testing with Selenium JavaScript using Nightwatch.js. We are aware of all the prerequisites required for setting up Nightwatch.js. It automates the entire test suite quickly with minimal configuration and is readable as well as easy to update. The best feature provided by Nightwatch.js framework is the parallel testing of cases that proves to be time-efficient. The test results can directly be read from the terminal and also stored at a specified output folder.&lt;/p&gt;

&lt;p&gt;At an initial stage, adopting a new approach for automated browser testing becomes stumbling blocks for many but using cloud platforms such as LambdaTest makes the process easier and allows us to leverage the full benefits of Selenium automation testing. How was this Nightwatch.js tutorial for you? Let me know in the comment section below. Happy testing!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=Dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-9032020&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0j-luKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>learning</category>
      <category>cloud</category>
      <category>javascript</category>
    </item>
    <item>
      <title>13 Ways For Your Functional Testers To Do More Than Just ‘Testing’</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Fri, 06 Mar 2020 13:30:50 +0000</pubDate>
      <link>https://forem.com/ramitd1995/13-ways-for-your-functional-testers-to-do-more-than-just-testing-33ic</link>
      <guid>https://forem.com/ramitd1995/13-ways-for-your-functional-testers-to-do-more-than-just-testing-33ic</guid>
      <description>&lt;p&gt;Functional testing of a web application or a website is one of the most essential phases of SDLC(Software Development Life Cycle) and who would know it better than we do. Providing a scalable infrastructure for cross browser testing on the cloud, we realize that offering a SaaS platform to our audience with even with a minor bug, may lead to a devastating outcome, and not only for us but also for our customers.&lt;/p&gt;

&lt;p&gt;Which is why we always emphasized the entire LambdaTest team to indulge in testing activities. After all, we want to make sure that you perform seamless &lt;a href="https://www.lambdatest.com/feature?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;browser compatibility testing&lt;/a&gt; over 2000+ real browsers that are always ready to fire up according to your needs. Developers, testers, project managers, marketers, and even the co-founders have functional testing incorporated as a regular drill for their daily to-do list. The testing efforts are distributed by our testing department who are have been pivotal behind the stability of our web services. During the establishment of this work culture, I as a tester realized that there were more ways for me to contribute towards our product than just functional testing it.&lt;/p&gt;

&lt;p&gt;Don’t get me wrong! I don’t intend to criticize UI functional testing. It is vital to spot bugs and fix them before an application is in front of the user. The success of a business lies in customer satisfaction and If the application’s interface is filled with errors and bugs, it will result in a compromised UX.&lt;/p&gt;

&lt;p&gt;I am sure you most of you may already be familiar with the ways in which testers add value to the SDLC. Usually, it’s through functional testing, it attracts the maximum focus of a web testers schedule. However, there are other ways through which you can add more value to your product’s SDLC, ways other than performing functional testing. And the moment I realized these ways, I would be honest with you, I was a little bit upset about everything I could have done from the very start of my testing career.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YEi-J_2x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/11/giphy-3-1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YEi-J_2x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/11/giphy-3-1.gif" alt="i could have done more"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I thought of noting these ways down for you so that you as a tester, could help your team accelerate faster with a rigid &lt;a href="https://www.lambdatest.com/blog/automation-testing-in-ci-cd-pipeline/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;CI CD pipeline&lt;/a&gt; of your web application. Here are 13 ways in which functional testers can add more value to a web product, apart from functional testing. Let’s take a look.&lt;/p&gt;

&lt;h2&gt;
  
  
  Have An Insight Into Your Stakeholder’s Mindset
&lt;/h2&gt;

&lt;p&gt;Every team member has their own perspective on a project. But when the customer is the one who ends up using the product, don’t you think it’s the stakeholder’s mindset that matters the most? Eliminating personal bias and thinking from the stakeholder’s point of view can greatly improve the testing procedure and enhance the robustness of your web application or website. List out people who have expressed interest in your deliverables. Document stakeholder expectations in a mapped form and lay a foundation according to the stakeholders’ mindset to avoid getting in the scenario as the below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EC2u6GHv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/11/want.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EC2u6GHv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/11/want.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Src:&lt;a href="http://bit.ly/37R3YD4"&gt;http://bit.ly/37R3YD4&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So to deliver more than just functional testing, you need to work according to the stakeholder map. Communicate efficiently with stakeholders and grasp the depth of the situation. When testers encounter a bug, they usually report it and be done with it. However, to add more value, you need to report a discrepancy with the impacts of actions on stuff that matters to stakeholders. Also, check how the scenario you have prepared fits into the big picture instead of getting engrossed in a single feature. In the end, leaving the decision on to the decision-makers.&lt;/p&gt;

&lt;p&gt;A good way to go about this is to adapt to shift-left testing. Shift-left testing is about performing testing as soon as possible, even before the product is prepared. You can sit along with stakeholders and learn what they are expecting to think of potential test cases and problems in advance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transition From a QA to QAOps
&lt;/h2&gt;

&lt;p&gt;QAOps refers to maintaining the software quality of your product by coordinating well with your DevOps teams. The goal is to deliver a robust web application or website with a faster CI/CD pipeline. QAOps focuses on performing scalable test automation in parallel to achieve continuous testing in DevOps by collaborating the development and operations team with the QA department.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/guide-to-implement-qaops-framework/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;What Is QAOps? And Why It Matters For Your Web Application?&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Acknowledge The Hindrances That Your Customers Are Facing
&lt;/h2&gt;

&lt;p&gt;We all know that no matter how the entire team feels about the product, the customer’s opinions gain the highest priority. It’s important to know how customers feel about a product and the usefulness of features. I have seen that in some cases, a particular feature is perfectly in line with the tester’s expectations. But it can turn out to be a burden for the users.&lt;/p&gt;

&lt;p&gt;Testers should report bugs that can bother customers. And who gives a better insight into what the customers are thinking other than the customer support team? After all, they are the ones in close contact with the users. Use the customer’s voice as the most valuable data and make a huge difference in the organization.&lt;/p&gt;

&lt;p&gt;At LambdaTest, we provide 24/7 in-app &lt;a href="https://dev.tojavascript:void(0)"&gt;&lt;strong&gt;Custumer chat support&lt;/strong&gt;&lt;/a&gt; to help eradicate any issue faced by our customers, as soon as possible. As a tester, I was able to come up with better and more valuable test scenarios regarding our product once I interacted with the customer support team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding and Estimating User Stories
&lt;/h2&gt;

&lt;p&gt;In an agile framework, user stories are laid out for functional testers to understand and estimate the effort required for a release cycle. It is a description of a feature on a website or web application from the perspective of the end-user. It describes the kind of users, their needs and wants, and why they want a particular feature. The main purpose of user stories is to determine the value a project delivers to customers. The product owner and the testers understand the user stories and prioritize tasks according to the requirement.&lt;/p&gt;

&lt;p&gt;Understanding user stories come in handy in developing acceptance criteria and covering different test scenarios. If the stories are huge, it becomes mandatory to break them down into chunks. Using the testing perspective to estimate user stories results in providing a clear idea on time taken by each story. There are many online collaboration tools available in the market to help you keep your entire team on a single dashboard, where you can assign user stories and see how they are being progressed by the team. You can gather reports from such tools and share it across the stakeholders too!&lt;/p&gt;

&lt;h2&gt;
  
  
  Explore New Testing Tools In The Market
&lt;/h2&gt;

&lt;p&gt;I have seen testers getting threatened by the use of too many automated testing tools in the industry. They try to resist the change and feel that the technology is out there to replace them. Unfortunately, most of us are unaware that tools are a boon once we know how to leverage them. As a tester, you should have at least basic knowledge about the testing tools and the related opportunities in your field.&lt;/p&gt;

&lt;p&gt;Using automated tools, testers can keep a backup of user actions and use the logs at the appropriate time. Some other uses include detecting different patterns in logs, mimicking functions, making copies of production data, etc. There are instances as a tester, where you might need to show others how a tool can come in handy to solve a problem.&lt;/p&gt;

&lt;p&gt;For instance, if we consider manual cross browser testing then we know that the drill is very time-consuming and exhausting. Initially, I was reluctant about Selenium only because I wasn’t aware of the programming language. Being a manual tester I was hesitant and insecure about &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;Selenium automation testing&lt;/a&gt; but once I got the hang of it, I realized the sudden increase in pace at which my test cycles delivered.&lt;/p&gt;

&lt;p&gt;So always look out for the new tools in the market. Keep looking for opportunities and you’re good to go!&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Reviewing
&lt;/h2&gt;

&lt;p&gt;Don’t devote all your time to functional testing. You need to be more vigilant regarding code changes and code reviewing presents a good opportunity to do so. In every release cycle, there comes a period where the development team sits to review the code changes required to meet the release demands. To groom as a QA, you need to be active in the code review process and understand the changes that may happen in the web application. You should not only participate, but you should contribute your inputs regarding the changes as well.&lt;/p&gt;

&lt;p&gt;As a functional tester, you are interacting with the web application on a daily basis. You have scene multiple test scenarios, unexpected outcomes, regression defects. It is only natural for you to come up with a few valuable suggestions or two.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure The User Experience
&lt;/h2&gt;

&lt;p&gt;One of the biggest mistakes that I have come across in software companies in a hurry to release an application. The hastiness to release a feature or a product sometimes takes precedence over the correctness of the same. Performing an in-depth UX review is a must before you launch the product hoping to get the bugs sorted out by beta testing. Take the necessary data, business metrics, and insights to assess the quality of a product from the user’s point of view. Record the shreds of evidence and give recommendations to instigate improvement.&lt;/p&gt;

&lt;p&gt;In cases of a super quick release, inconsistencies start building up. In my experience, the involvement of multiple developers and outsourcing a part of the development process to a different team results in instability. User touchpoints, icons, actions, text, features, performance, and key flows are some of the important elements of a UX review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Focus On Every Customer Tickets That Gets Assigned To The Team
&lt;/h2&gt;

&lt;p&gt;Not all scenarios are covered in test cases. No matter how hard the development team tries to cover it all, take it from me, there are always going to be surprises! This makes reviewing error, information, and warning messages all the more important for the testing team. There was this one time when I got a list of strings to review, I noticed a complete section that the testing team had never seen before.&lt;/p&gt;

&lt;p&gt;After review, our team noticed that the code was for a feature no longer in use. It’s removal was vital as it had no impact on the product anymore. When a list of messages is ready, it results in a more efficient and valuable testing process. It’s the best way to subject a product to a reality check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Being On Time
&lt;/h2&gt;

&lt;p&gt;I have witnessed testers loaded with so many tasks that the entire process can sometimes be a little chaotic. But, as a matter of fact, you have to adhere to the deadlines. The end goal has to be saving time by avoiding messy testing. Maintaining an optimum speed, yet being efficient, does it sound like you’re in a pickle? Well, if you keep your important details and communication organized in one place, I bet it will solve half of your timing problems.&lt;/p&gt;

&lt;p&gt;Writing effective test cases and detailed bug reports is another way you can be quick in executing your tasks. Wait, did I use the word ‘detailed’ and ‘quick’ in the same sentence? It might sound contradictory but a detailed report requires a one-time-effort. Maintain a high level of clarity and you can revisit your information log any time you want. Now, do you see how much wastage of time this prevents for the long haul? Also, you get to be rid of the regular excuses. Talking about excuses!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XQEMHZO1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/11/giphy-2-1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XQEMHZO1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/11/giphy-2-1.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Think Of Potential Disasters
&lt;/h2&gt;

&lt;p&gt;Imagine waking up in the morning and seeing a nerve-wracking headline about your product in the news. Severely negative headlines can prove to be a disaster for your project and organization. Thus, it is vital to think of possible disastrous scenarios before releasing a product. And did you know that testers are extremely good at predicting what can possibly go wrong with a product? It is all about maintaining &lt;a href="https://www.lambdatest.com/blog/why-to-choose-quality-over-quantity-in-software-testing/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;quality over quantity in software testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When this approach becomes a regular practice for a firm, it can save a lot of time and effort. And of course, this methodology helps in preventing errors in the long haul. The prediction of these possible headlines acts as a nudge to the testing team. By providing a different perspective on product development, it helps in building better websites and applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Be A Problem Solver
&lt;/h2&gt;

&lt;p&gt;I have seen testers feel that their job can be a little cut and dry. Running test scripts like a robot can become a bit tedious after a while. Executing a test case, writing a test report, passing on the issue to the developer, and verifying the fix sounds pretty simple. To some extent it is. But what if you are a person with a knack for problem-solving? Well, then be a problem solver and break the monotony! Do you know how you can add value to the organization by being a problem solver? Take a look.&lt;/p&gt;

&lt;p&gt;Unlike one of the most common misconceptions, a tester’s job doesn’t end at reporting bugs. If you find the needle in the haystack by narrowing down the search, you are one step closer to solving a problem. For instance, along with pointing out the bug, you can provide an easier way to fix for the developer. This way, you get to collaborate with the developer and help the organization save time. When you look at the big picture, a problem-solving tester can be a gem for an enterprise! Thinking of critical scenarios and designing their problem solutions is especially pivotal if you are a QA Manager.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/top-13-skills-of-a-proficient-qa-manager-in-2019/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;Top 13 Skills Of A Proficient QA Manager In 2019&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn Data Science
&lt;/h2&gt;

&lt;p&gt;Complications can do no good to a company unless someone simplifies them. With a plethora of raw data, it is important to pick the most relevant information and use it skillfully. Here, we are talking about data science, which is mining the massive information pool stored in data warehouses. Even with progressive delivery and deployment, it’s not possible to test everything, not even with the best &lt;a href="https://www.lambdatest.com/blog/13-reasons-why-staging-environment-is-failing-for-your-organization/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;staging environments&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;As far as production use is concerned, thanks to modern technology, you can get access to detailed information. But as a tester, you need to learn how to put all that data to good use. Data science can help testers concentrate their testing efforts. This, in turn, will aid the organization as a whole in providing better deliverables. So, did you see how the knowledge of one important concept for testers benefits the enterprise on a large scale?&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep An Active Eye Out For Competition
&lt;/h2&gt;

&lt;p&gt;In today’s world of fast-paced technology, competitors are just a few taps and clicks away. With entrepreneurship gaining a boost, the competition among businesses is just going to get fiercer. The most common hell hole that’s holding a lot of companies back is testers getting stuck in silos. It results in a severe lack of information about how the competitors are holding up.&lt;/p&gt;

&lt;p&gt;Testers need to sift through fact sheets, websites, and other sources to compare the strengths and weaknesses of your competitor’s products against your own. In addition to functional testing, some other criteria to take into account include usability testing, security testing, performance testing, and accessibility testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/unboxing-the-concept-of-cross-browser-accessibility/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;Unboxing the Concept of Cross Browser Accessibility&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Always Remember!
&lt;/h2&gt;

&lt;p&gt;While it’s true that functional testing holds incredible importance, that doesn’t mean testers can confine themselves to it! Most testers fear the unknown and lack coding skills. But there are ways to add value to the organization other than functional testing as well. These were some of the departments in which functional testers are making real strides, apart from functional testing.&lt;/p&gt;

&lt;p&gt;Testers are the ones ensuring the impeccability of a product before it reaches the end-user. In some organizations, the contribution of testers is often overlooked. I have seen many testers wonder when they can sit on the table with the DevOps. However, QAOps is about to change that with its focus on continuous testing in DevOps.&lt;/p&gt;

&lt;p&gt;So, if you are a tester and are wondering about your contribution to the development of the website or web application, you can now see how much value you add to it! Even though the decision making power lies among the product owner and manager, the tester’s role in the SDLC is hard to ignore. They lay the groundwork for making sound choices, thus, helping an organization thrive to its full potential. Cheers!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-6032020&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0j-luKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>performance</category>
      <category>development</category>
      <category>testing</category>
    </item>
    <item>
      <title>Desired Capabilities in Selenium Testing With Examples
</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Mon, 23 Dec 2019 13:54:54 +0000</pubDate>
      <link>https://forem.com/ramitd1995/desired-capabilities-in-selenium-testing-with-examples-4a2g</link>
      <guid>https://forem.com/ramitd1995/desired-capabilities-in-selenium-testing-with-examples-4a2g</guid>
      <description>&lt;p&gt;Desired Capabilities is a class used to declare a set of basic requirements such as combinations of browsers, operating systems, browser versions, etc. to perform automated cross browser testing of a web application.&lt;/p&gt;

&lt;p&gt;When we try to automate our test scripts through &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;Selenium automation testing&lt;/a&gt;, we need to consider these combinations to declare a specific test environment over which our website or web application should render seamlessly.&lt;/p&gt;

&lt;p&gt;These environments can be mobile devices, mobile browsers, desktop devices, desktop browsers, screen resolutions, etc. To declare these environments in our Selenium automation testing script, we make use of the Desired Capabilities in Selenium testing or Appium testing and this is exactly what we will be discussing in this article.&lt;/p&gt;

&lt;p&gt;I will help you become familiar with the Desired Capabilities in Selenium testing and Desired Capabilities for Appium too. I will show you what they are, how they are used for Selenium automation testing and Appium testing with examples. Without further ado, let’s get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Desired Capabilities?
&lt;/h2&gt;

&lt;p&gt;Desired Capabilities class is a component of the &lt;code&gt;org.openqa.selenium.remote.DesiredCapabilities&lt;/code&gt; package. It helps Selenium WebDriver set the properties for the browsers. So using different capabilities from Desired Capabilities class we can set the properties of browsers. For example, the name of the browser, the version of the browser, etc. We use these capabilities as key-value pairs to set them for browsers.&lt;/p&gt;

&lt;p&gt;You can refer to the &lt;a href="https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities" rel="noopener noreferrer"&gt;github library for the Desired Capabilities&lt;/a&gt; for all the detailed methods and etc.&lt;/p&gt;

&lt;p&gt;While working with Selenium automation testing, we always have different requirements while execution specifically about which browser to execute, which operating system and version to use for test execution, this where Desired Capabilities helps us a lot on Selenium Grid.&lt;/p&gt;

&lt;p&gt;To declare Desired Capabilities in Selenium automation testing using Grid, we can use the &lt;strong&gt;setCapability method&lt;/strong&gt; from the DesiredCapabilities class to set the different types of capabilities of the browser (Ex. Chrome, IE, Firefox, Edge) platform name (Ex. Windows, macOS, etc.).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/setup-selenium-grid-for-parallel-execution/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;strong&gt;Setup Selenium Grid For Parallel Execution In Different Browsers&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Desired Capabilities in Appium is useful in the case of mobile application automation, where we have to execute test automation on different browser properties and device properties, which we can set using Desired Capabilities class. To &lt;a href="https://www.lambdatest.com/blog/17-key-benefits-of-automation-testing-for-a-successful-release/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;leverage automation testing&lt;/a&gt; for different types of mobile devices, the different kinds of mobile platforms like iOS, Android, etc. Also, there can be different platform (operating system) versions like for Android 9.x, 10.x and for iOS 12.x, 13.x, etc, we can set these properties using Desired Capabilities in Appium for Android or iOS as per our requirement.&lt;/p&gt;

&lt;h2&gt;
  
  
  There Is More To Desired Capabilities In Selenium And Appium
&lt;/h2&gt;

&lt;p&gt;Using Desired Capabilities class, we instruct the WebDriver about the environment like browser name, browser version, platform, etc. over which we perform &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;automated browser testing&lt;/a&gt; using our automation scripts. But that is not all we can do using the Desired Capabilities class. We can also configure browser-specific preferences such as enabling chrome options, firefox options, testing with incognito mode or even disabling javascript, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/selenium-automation-testing-with-disabled-javascript/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;strong&gt;Selenium Automation Testing with Disabled JavaScript Settings&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are using a cloud-based online Selenium grid, then the Desired Capabilities class can also be used to perform parallel testing with Selenium or Appium, &lt;a href="https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;testing locally hosted web applications with Selenium&lt;/a&gt;, generating command-by-command screenshots, or even a video recording of the entire test automation execution over different browsers + OS configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types Of Desired Capabilities Methods
&lt;/h2&gt;

&lt;p&gt;Now, let us discuss the different methods available in Desired Capabilities class to set the different properties in test automation.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;getCapability():&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public java.lang.Object getCapability(java.lang.String capabilityName)

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;getCapability()&lt;/strong&gt; from the class Desired Capabilities, which can be used to get the capabilities of the current system which we are using.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;setCapability()&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public java.lang.Object getCapability(java.lang.String capabilityName)

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;setCapability()&lt;/strong&gt; from the class Desired Capabilities, can be used to set the name of device, name of platform, version of platform, absolute path of the application which is under test, application activity (in Mobile automation), application Package (in Java) and etc.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;getBrowserName():&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public java.lang.String getBrowserName()

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;getBrowserName()&lt;/strong&gt; from the class Desired Capabilities, can be used to get the name of the Browser.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;setBrowserName()&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public void setBrowserName(java.lang.String browserName)

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;setBrowserName()&lt;/strong&gt; from the class Desired Capabilities, can be used to set the name of the Browser.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;getVersion()&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public java.lang.String getVersion()

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;getVersion()&lt;/strong&gt; from the class Desired Capabilities, can be used to get the version of the browser or platform.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;setVersion()&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void setVersion(java.lang.String version)

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;setVersion()&lt;/strong&gt; from the class Desired Capabilities, can be used to set the version of the browser or platform.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;getPlatform()&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Platform getPlatform()

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;getPlatform()&lt;/strong&gt; from the class Desired Capabilities, can be used to get the details of the platform.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;setPlatform()&lt;/strong&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Platform setPlatform()

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

&lt;/div&gt;



&lt;p&gt;This method &lt;strong&gt;setPlatform()&lt;/strong&gt; from the class Desired Capabilities, can be used to set the details of the platform.&lt;/p&gt;

&lt;p&gt;For more information, you can refer to &lt;a href="https://selenium.dev/selenium/docs/api/java/org/openqa/selenium/remote/DesiredCapabilities.html?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;Selenium documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Desired Capabilities In Selenium Testing For Different Browsers
&lt;/h2&gt;

&lt;p&gt;In the above section, we have seen different methods of Desired Capabilities class. Now, let us discuss how we can set different capabilities for different browsers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Desired Capabilities in Selenium WebDriver for Chrome
&lt;/h3&gt;

&lt;p&gt;When we want to customize and configure the Desired Capabilities in Selenium WebDriver for Chrome, we need to invoke the ChromeDriver session to leverage these capabilities. So let us discuss capabilities that are supported by ChromeDriver and how we can use them to set those desired capabilities in Selenium Webdriver for Chrome.&lt;/p&gt;

&lt;p&gt;There are two ways to set the capabilities for ChromeDriver.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ChromeOptions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Desired Capabilities&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ChromeOptions is another class that can be used in conjunction with Desired Capabilities in Selenium WebDriver for Chrome to customize or manipulate the various properties of Chrome browser.&lt;br&gt;&lt;br&gt;
Following are the commonly used arguments from ChromeOptions class&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disable-infobars:&lt;/strong&gt; It is used to prevent chrome browser from displaying notifications like “Chrome is being controlled by automated software”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make-default-browser:&lt;/strong&gt; It is used to make the chrome browser as default browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disable-popup-blocking:&lt;/strong&gt; It is used to disable the pop-ups which are displayed on chrome browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Incognito:&lt;/strong&gt; It opens chrome browser in incognito mode&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;start -maximized:&lt;/strong&gt; It opens chrome browser in maximized mode&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Headless:&lt;/strong&gt; It is used to open the chrome browser in headless mode.&lt;/p&gt;

&lt;p&gt;Now, let us discuss an example of an ad blocker where Chrome Option is used in conjunction with Desired Capabilities class. We will use an adblocker extension for this purpose.&lt;br&gt;&lt;br&gt;
Prerequisite for that a &lt;strong&gt;crx file&lt;/strong&gt; of the extension should be downloaded.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Setting up capabilities to run our test script
ChromeOptions opt = new ChromeOptions();

opt.addExtensions(new File(“path for crx file of the extension”));

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(ChromeOptions.CAPABILITY, options);

ChromeDriver driver = new ChromeDriver(capabilities);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Desired Capabilities in Selenium WebDriver for Firefox
&lt;/h3&gt;

&lt;p&gt;Like we have seen in the case of the Chrome browser, there are also ways to customize the Desired Capabilities in Selenium WebDriver for Firefox browsers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;moz:firefoxOptions&lt;/strong&gt; capability is available specifically for Firefox browser. We can use &lt;strong&gt;moz:firefoxOptions&lt;/strong&gt; to customize or manipulate different properties of the Firefox browser, which helps us to control the behavior of the Firefox browser. It is usually invoked as a member in either of the two, one is from &lt;strong&gt;alwaysMatch&lt;/strong&gt; and the other is from &lt;strong&gt;firstMatch&lt;/strong&gt; entries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;moz:firefoxOptions&lt;/strong&gt; can contain the following things that can control how Firefox browser starts or runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) binary(String):&lt;/strong&gt; We provide absolute path for the custom Firefox binary to use. Normally, GeckoDriver which is driver that we use for Firefox tries to find the location of Firefox on the current system if it is not defined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b) args(array of strings):&lt;/strong&gt; This argument is used to pass the command line arguments to the Firefox binary. While using this syntax should contain, hyphen/dash like [“-profile”]. So to pick up the existing profile by GeckoDriver, we should use syntax like&lt;/p&gt;

&lt;p&gt;[“-profile”, “path to the profile”]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c) profile(string):&lt;/strong&gt; We can provide the path for the directory so that Firefox instance can be used. For installing some firefox extensions or some custom certificates, we can use this. While it is recommended to use prefs while we want to set the custom preferences, instead of directly passing the profile. You can find the example of prefs below along with others.&lt;/p&gt;

&lt;p&gt;Here is an example of declaring Desired Capabilities in Selenium WebDriver for Firefox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 {
      "capabilities": {
        "alwaysMatch": {
          "moz:firefoxOptions": {
            "binary": "/usr/local/firefox/bin/firefox",
            "args": ["-headless", "-profile", "/path/to/my/profile"],
            "prefs": {
              "dom.ipc.processCount": 9,
              "javascript.options.showInConsole": true
            },
            "log": {"level": "trace"}
          }
        }
      }
    }
if(driverParameter == null || driverParameter.equalsIgnoreCase(FIREFOX))
{
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    FirefoxOptions options = new FirefoxOptions();
    options.setHeadless(headless);
    capabilities.merge(options);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Desired Capabilities in Selenium WebDriver for IE(Internet Explorer)
&lt;/h3&gt;

&lt;p&gt;Now, let us proceed with Desired Capabilities in Selenium WebDriver for IE(Internet Explorer). For IE, we make use of &lt;strong&gt;InternetExplorerOptions&lt;/strong&gt; with &lt;strong&gt;Desired Capabilities in Selenium WebDriver&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is an example of declaring Desired Capabilities in Selenium WebDriver for IE.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
if(driverParameter == null || driverParameter.equalsIgnoreCase(IE))
{
    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    InternetExplorerOptions option = new InternetExplorerOptions();
    option.setHeadless(headless);
    capabilities.merge(option);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are few Internet Explorer specific capabilities which we can use, let us discuss some of them one by one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) ignoreZoomSetting(boolean):&lt;/strong&gt; This capability can be used to ignore checking of the browser’s zoom level to 100%. By default, it is set as false. It takes a boolean value as input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b) initialBrowserUrl(string):&lt;/strong&gt; Using this capability we can decide initial URL, website to which it should redirect while internet explorer browser starts. It takes a string as input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c) enableElementCacheCleanup(boolean):&lt;/strong&gt; This capability provides a check over the obsolete elements from element cache. If they are found then the capability instructs the WebDriver to clean up. It takes a boolean value as input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d) requireWindowFocus(boolean):&lt;/strong&gt; This capability is used for instructing the driver to check that the internet explorer window has the focus before performing any operations like a mouse or keyboard events etc. It takes a boolean value as input and by default, it is set as false.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e) ignoreProtectedModeSettings(boolean):&lt;/strong&gt; If you wish to skip past the protected mode check while performing Selenium automation testing then you can leverage this capability. It takes a boolean value as input.&lt;/p&gt;

&lt;p&gt;So these are some of the Internet Explorer specific capabilities which we can use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples Of Desired Capabilities In Selenium Testing With Different Languages
&lt;/h2&gt;

&lt;p&gt;Now, I will demonstrate to you how to leverage Desired Capabilities in Selenium testing with different languages. As you may already know, Selenium automation testing is supported by multiple programming languages. It offers bindings for every major programming language i.e. JavaScript, C#, Python, Java, Ruby, PHP. To give you a gist of how you can leverage the desired capabilities in Selenium testing, I will be giving examples for Java, C#, and Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  Desired Capabilities in Selenium WebDriver for Java
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Setting up capabilities to run our test script
    @BeforeClass
        public void setUp() throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", "chrome");
        capabilities.setCapability("version", "77.0");
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get any available one
        capabilities.setCapability("build", "LambdaTestSampleApp");
        capabilities.setCapability("name", "LambdaTestJavaSample");
        capabilities.setCapability("network", true); // To enable network logs
        capabilities.setCapability("visual", true); // To enable step by step screenshot
        capabilities.setCapability("video", true); // To enable video recording
        capabilities.setCapability("console", true); // To capture console logs

 capabilities.setCapability("selenium_version","4.0.0-alpha-2");
         capabilities.setCapability("timezone","UTC+05:30");
         capabilities.setCapability("geoLocation","IN");
         capabilities.setCapability("chrome.driver","78.0");
        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Desired Capabilities in Selenium WebDriver for C
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Accept all certificates Chrome 
DesiredCapabilities capability = DesiredCapabilities.Chrome();
Environment.SetEnvironmentVariable("webdriver.chrome.driver", "Path to ChromeDriver.exe");
capability.SetCapability(CapabilityType.AcceptSslCertificates, true);
IWebDriver driver = new RemoteWebDriver(capability);

//Set Chrome options.
ChromeOptions options = new ChromeOptions();
DesiredCapabilities dc = DesiredCapabilities.Chrome();
dc.SetCapability(ChromeOptions.Capability, options);
IWebDriver driver = new RemoteWebDriver(dc);

//Turn off the JavaScript Firefox
FirefoxProfileManager profileManager = new FirefoxProfileManager();
FirefoxProfile profile = profileManager.GetProfile("TestProfile");
profile.SetPreference("javascript.enabled", false);
IWebDriver driver = new FirefoxDriver(profile);

//Set the default page load timeout
driver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(10));

//Start Firefox with plugins
FirefoxProfile prof = new FirefoxProfile();
profile.AddExtension(@"C:Location of extension.xpi");
IWebDriver driver = new FirefoxDriver(prof);

//Start Chrome with an unpacked extension
ChromeOptions options = new ChromeOptions();
options.AddArguments("load-extension=/pathTo/extension");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(ChromeOptions.Capability, options);
DesiredCapabilities dc = DesiredCapabilities.Chrome();
dc.SetCapability(ChromeOptions.Capability, options);
IWebDriver driver = new RemoteWebDriver(dc);

//Start Chrome with a packed extension
ChromeOptions options = new ChromeOptions();
options.AddExtension(Path.GetFullPath("localpathto/extension.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(ChromeOptions.Capability, options);
DesiredCapabilities dc = DesiredCapabilities.Chrome();
dc.SetCapability(ChromeOptions.Capability, options);
IWebDriver driver = new RemoteWebDriver(dc);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Desired Capabilities in Selenium WebDriver for Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def _get_desired_capabilities():
    """
    """
    platform = _TEST_SETTINGS['PLATFORM']
    browser = _TEST_SETTINGS['BROWSER']
    version = _TEST_SETTINGS['VERSION']

    if platform and browser:
        capabilities = {
            'platform': platform,
            'browserName': browser,
            'version': version,
        }
    elif browser.lower() == 'firefox':
        capabilities = DesiredCapabilities.FIREFOX
    else:
        capabilities = DesiredCapabilities.CHROME

    return _add_travis_info(capabilities)


def run_browser(self,os_name,os_version,browser,browser_version):

        USERNAME = ‘test.lambdatest@gmail.com’
        PASSWORD = ‘Test123’
        if browser.lower() == 'ff' or browser.lower() == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX            
        elif browser.lower() == 'ie':
            desired_capabilities = DesiredCapabilities.INTERNETEXPLORER
        elif browser.lower() == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME            
        elif browser.lower() == 'opera':
            desired_capabilities = DesiredCapabilities.OPERA        
        elif browser.lower() == 'safari':
            desired_capabilities = DesiredCapabilities.SAFARI

        desired_capabilities['os'] = os_name
        desired_capabilities['os_version'] = os_version
        desired_capabilities['browser_version'] = browser_version

     return webdriver.Remote(RemoteConnection("http://%s:%s@hub-cloud.browser.com/wd/hub"%(USERNAME,PASSWORD),resolve_ip= False),
            desired_capabilities=desired_capabilities)

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting Selenium Capabilities with LambdaTest Capabilities Generator
&lt;/h3&gt;

&lt;p&gt;Lambdatest is a cloud-based cross browser testing tool, which allows you to execute Selenium automation testing on an online Selenium Grid of 2000+ real browsers. All the languages and frameworks supported by Selenium are compatible with LambdaTest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/integrations?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;strong&gt;You also get integrations with numerous third-party CI/CD tools, project management tools, collaboration tools and more&lt;/strong&gt;.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being an online Selenium Grid as a Service provider we understand the importance of DesiredCapabilities in your Selenium automation testing experience. We also understand that it can take a considerable amount of time to write down your Desired Capabilities every time to run your tests on hundreds of browsers + OS combinations. This is why we have come up with an online &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;Desired Capabilities Generator&lt;/a&gt; which provides you the DesiredCapabilities class for multiple programming languages based upon your point-and-click selection.&lt;/p&gt;

&lt;p&gt;So, when we navigate to the capabilities generator from LambdaTest using the above URL you can see a screen as below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fselenium_webdriver.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fselenium_webdriver.png" alt="selenium_webdriver"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see in the above screenshot, we can select the properties which we want to use in our test script and after selecting the required information it generates respective desired capabilities.&lt;br&gt;&lt;br&gt;
The following screen shows the generated capabilities which we can directly use in our test script.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2FLambdatest_capability_generator.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2FLambdatest_capability_generator.png" alt="Lambdatest_capability_generator"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;strong&gt;Check Out the Desired Capabilities For Selenium On LambdaTest&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you notice that we used the Desired Capabilities in Selenium 4? If you look at the above image you will find that the point-and-click selections from drop-downs are made under the tab for Selenium 4.&lt;/p&gt;
&lt;h3&gt;
  
  
  Selenium 4 Desired Capabilities On LambdaTest Capabilities Generator
&lt;/h3&gt;

&lt;p&gt;That is another great benefit of using LambdaTest as an online Selenium Grid. You get the latest browsers, browser versions, operating systems pre-installed on machines hosted on our cloud servers. That is not all! You also get the latest Selenium 4 desired capabilities all ready to fire up in your automated browser testing scripts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fdesired_capability.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fdesired_capability.png" alt="desired_capability"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Example Script Incorporating Desired Capabilities In Selenium Testing
&lt;/h3&gt;

&lt;p&gt;Now, let’s take a quick example to demonstrate how to fit in these desired capabilities in Selenium automation testing scripts. So as we are ready with generating desired capabilities that we want, we have used that in the following test script which we can execute on multiple browsers to perform cross browser testing on 2000+ real browsers using Selenium Grid offered by LambdaTest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example automation script:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.lambdatest;


//TestNG Todo : Sample App
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.testng.asserts.Assertion;

import com.beust.jcommander.Parameter;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public class Test2{

    public String username = "Your_LambdaTest_Username";
    public String accesskey = "Your_LambdaTest_Access_Key";
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";
    boolean status = false;


    //Setting up capabilities to run our test script
    @Parameters(value= {"browser","version"})
    @BeforeClass
    public void setUp(String browser, String version) throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", browser);
        capabilities.setCapability("version", version);
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
        capabilities.setCapability("build", "LambdaTestSampleApp");
        capabilities.setCapability("name", "LambdaTestJavaSample");
        capabilities.setCapability("network", true); // To enable network logs
        capabilities.setCapability("visual", true); // To enable step by step screenshot
        capabilities.setCapability("video", true); // To enable video recording
        capabilities.setCapability("console", true); // To capture console logs

         capabilities.setCapability("selenium_version","4.0.0-alpha-2");
         capabilities.setCapability("timezone","UTC+05:30");
         capabilities.setCapability("geoLocation","IN");
         capabilities.setCapability("chrome.driver","78.0");


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

    }

    //Opening browser with the given URL and navigate to Registration Page
    @BeforeMethod
    public void openBrowser()
    {
 //     driver.manage().deleteAllCookies();

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

        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);

        WebElement signUpButton = driver.findElement(By.xpath("//a[contains(text(),'Start Free Testing')]"));
        signUpButton.click(); 

    }

    //Verifying elements on Registration page
    @Test
    public void verifyElementsOnPageTest()
    {
        WebElement lambdaTestLogo = driver.findElement(By.xpath("//p[@class='signup-titel']"));
        lambdaTestLogo.isDisplayed();

        WebElement signUpTitle = driver.findElement(By.xpath("//p[@class='signup-titel']"));
        signUpTitle.isDisplayed();

        WebElement termsText = driver.findElement(By.xpath("//label[@class='woo']"));
        termsText.isDisplayed();

        WebElement loginLinkText = driver.findElement(By.xpath("//p[@class='login-in-link test-left']"));
        loginLinkText.isDisplayed();

    }  

    // Closing the browser session after completing each test case
    @AfterClass
    public void tearDown() throws Exception {
       if (driver != null) {
            ((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
            driver.quit();
        }
    }
}
view rawseleniumtesting_automation_script.java hosted with ❤ by GitHub


&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite thread-count="3" name="LambaTestSuite" parallel="tests"&amp;gt;

  &amp;lt;test name="ChromeTest"&amp;gt;
  &amp;lt;parameter name="browser" value="chrome"/&amp;gt;
  &amp;lt;parameter name="version" value="77.0"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="com.lambdatest.Test2"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;


&amp;lt;/suite&amp;gt; &amp;lt;!-- Suite --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output On The LambdaTest Automation Dashboard&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After executing the above script on the online Selenium Grid of LambdaTest, we get the below automation logs over the automation dashboard at LambdaTest. You get different types of logs under the automation dashboard i.e. Network logs, Command logs, Metadata, Video recording, Screenshots, etc. In the below screenshot I want you to focus on the raw Selenium Logs offered by LambdaTest.&lt;/p&gt;

&lt;p&gt;You can notice that the capabilities declared in the automation scripts are displayed there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fautomation_dashboard.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fautomation_dashboard.png" alt="automation_dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Desired Capabilities In Appium For Mobile Automation
&lt;/h2&gt;

&lt;p&gt;Till now we have seen desired capabilities with different languages, browsers and different methods available for capabilities. And I hope by far, you have had a good idea on how to use Desired Capabilities in Selenium automation testing. However, Selenium automation testing can only ensure your web application for desktop devices but your customers may be using their mobiles for accessing your web application or website, especially your blog page.&lt;/p&gt;

&lt;p&gt;We are living in a mobile-first era. The automated browser testing over &lt;strong&gt;desktops only&lt;/strong&gt; cannot ensure you that your &lt;a href="https://www.lambdatest.com/blog/how-to-make-a-cross-browser-compatible-website/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;website is cross browser compatible&lt;/a&gt;. Almost every business is going digital, so it requires a website or a web application to be both desktop and mobile-ready. This means that you may have to perform automated browser testing over mobile browsers too!&lt;/p&gt;

&lt;p&gt;How can we perform automated browser testing for mobile browsers then? The good news is that there is another spectacular open-source framework to help you out with that purpose and it is called Appium.&lt;/p&gt;

&lt;p&gt;Now, we will discuss the Appium testing, how we can use desired capabilities in Appium.&lt;/p&gt;

&lt;p&gt;So there can be different requirements for platform or operating system (like Android, iOS), platform version, device, etc. which are similar to what we do in case of web application automation. This is where the desired capabilities in Appium come into play for automated browser testing for mobile web-applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example For Desired Capabilities In Appium Testing
&lt;/h2&gt;

&lt;p&gt;When a new automation session is requested, Appium client sends request to server with JSON object which includes Desired Capabilities in the form of key and value pairs.&lt;/p&gt;

&lt;p&gt;Using these key and values from JSON object, we provide decide and instruct appium drivers about how we want our mobile automation test to work.&lt;/p&gt;

&lt;p&gt;Desired Capabilities can then be set within a server of Appium or we can also add it in our Webdriver test script.&lt;/p&gt;

&lt;p&gt;Following is an example for desired capabilities in Appium testing using a JSON object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   “platformName”: “Android”,
    “platformVersion”: “10.0”,
    “deviceName”:  “Samsung Galaxy s10”,
    “automationName”: “Appium”,
    “app”: “path for the app under test”
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So using above desired capabilities in Appium testing through a JSON object, we are instructing drivers to start our mobile automation session on device Samsung Galaxy s10 with Android version 10.0 using Appium and for the app with the given file location.&lt;/p&gt;

&lt;p&gt;There are different desired capabilities Appium supports, out of which some capabilities are common for all the platform or drivers, while some are driver or platform-specific. Let us discuss some of them as we proceed further.&lt;/p&gt;

&lt;h3&gt;
  
  
  General or Standard Desired Capabilities in Appium Testing
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;automationName:&lt;/strong&gt; Using this capability we can instruct driver about which automation engine it should use. By default, it is set as Appium. Other available engines like Appium, Espresso (both are for android), XCUITest (for iOS)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;platformName:&lt;/strong&gt; We can use this to instruct about the mobile operating system platform like iOS, Android, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;platformVersion&lt;/strong&gt; : We can use this for mentioning the mobile operating system version on which test expect to execute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;deviceName:&lt;/strong&gt; We can use this to specify the particular mobile device over which we wish to perform automated browser testing. Like we have used Samsung Galaxy s10 in the above example.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;app:&lt;/strong&gt; This capability is used to provide the path of our application which needs to be tested with script. Here we provide an absolute local path or remote path with HTTP URL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;browserName:&lt;/strong&gt; This can be used when we want to execute a test on mobile web browser. We can provide the name of the browser like Safari for iOS, Chrome for Android, etc. It can be left empty when we want to automate app and not using browser.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;language:&lt;/strong&gt; This can be used to set the language of Android or iOS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;newCommandTimeout:&lt;/strong&gt; This capability helps to instruct driver for the time it has to wait for a new command from client before ending the idle session.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are few more general capabilities like noReset, fullReset,eventTimings, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Desired Capabilities In Appium For Android
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;appActivity:&lt;/strong&gt; Use this capability to declare a name for an Android activity which you wish to launch from the package. E.g. .MainActivity, .Settings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;appPackage:&lt;/strong&gt; Using this capability, we decide the JAva package of the Android app which we want to execute. By default package manifest provides this capability.
E.g. com.example.android.testApp&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;appWaitActity:&lt;/strong&gt; This capability provides name of android activity we want to wait.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;appWaitPackage:&lt;/strong&gt; This provides java package for android app which we want to wait for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;appWaitDuration:&lt;/strong&gt; This capability used to instruct the wait in milliseconds for the appWaitActivity to launch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;deviceReadyTimeout:&lt;/strong&gt; This capability instructs about timeout in seconds while driver is waiting for device under test to become ready.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apart from the above android capabilities, there are few more like adbPort, systemPort, remoteAdbHost, androidInstallPath, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Desired Capabilities In Appium For iOS
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;calendarFormat:&lt;/strong&gt; This capability can be used to set the calendar format for the iOS simulator. E.g. Gregorian&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;launchTimeout:&lt;/strong&gt; This capability instructs about the time in milliseconds upto which driver has to wait and after that it considers session as failed or hung.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;autoAcceptAlerts;&lt;/strong&gt; This capability is used to accept all the iOS alerts, if they popup while performing automated browser testing. Examples: privacy access permission alerts like location, contacts, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;autoDismissAlerts:&lt;/strong&gt; This capability is used to decline/dismiss all the iOS alerts when they popup while performing automated browser testing. Examples: privacy access permission alerts like location, contacts, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;safariInitialUrl:&lt;/strong&gt; Using this capability we can set the initial URL for safari browser, so it works as welcome page when browser launches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;appName:&lt;/strong&gt; This capability used to display the name of application which is under test.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apart from the above iOS capabilities, there are few more like safariAllowPopups, &lt;strong&gt;customSSLCert&lt;/strong&gt; , etc.&lt;/p&gt;

&lt;p&gt;So we have seen desired capabilities that we can use while creating a test with examples for different browsers, with different languages and we also discussed it for Appium with different platforms/operating systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  LambdaTest Capabilities Generator Offers Desired Capabilities In Appium
&lt;/h3&gt;

&lt;p&gt;LambdaTest Desired Capabilities Generator now provides the Appium capabilities as well. They can be found under the tab which says Appium. You can test over both Android and iOS browsers to ensure that your web application is working as perfectly as it should.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/capabilities-generator/" rel="noopener noreferrer"&gt;Check Out the Desired Capabilities For Appium On LambdaTest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fpasted-image-0-4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F11%2Fpasted-image-0-4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Have We Learned
&lt;/h2&gt;

&lt;p&gt;As we perform Selenium automation testing we need to declare a set of basic requirements regarding the test environment such as specific browsers, operating systems, and more. This is achieved using the Desired Capabilities class for Selenium testing and Appium testing.&lt;/p&gt;

&lt;p&gt;We can also specify the conditions over which we need to perform the test such as locally hosted testing, parallel testing, testing with javascript disabled and more.&lt;/p&gt;

&lt;p&gt;This Desired Capabilities class is generated with ease if you are already using LambdaTest through our Desired Capabilities Generator which offers you the class on the basis of your testing requirements from the drop-down menus.&lt;/p&gt;

&lt;p&gt;If you wish to perform Selenium automation testing for ensuring a wider browser compatibility testing then LambdaTest is your go-to store with all the latest browsers, operating systems, Selenium versions. Happy testing! 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23122019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0e5vtqzcoqm2zr3cb7la.jpg" alt=" cross browser testing"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>csharp</category>
      <category>java</category>
    </item>
    <item>
      <title>Selenium Java Tutorial: Automation Testing Of User Signup Form
</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Wed, 20 Nov 2019 12:28:36 +0000</pubDate>
      <link>https://forem.com/ramitd1995/selenium-java-tutorial-automation-testing-of-user-signup-form-3kmg</link>
      <guid>https://forem.com/ramitd1995/selenium-java-tutorial-automation-testing-of-user-signup-form-3kmg</guid>
      <description>&lt;p&gt;If you are just starting with Selenium automation testing of your product, the first page you would probably want to automate would be the SignUp or Login Page. If you have an online platform like an ecommerce company or a Software-as-a-Service product, the Signup page acts as the door to welcome your web application visitors. It is one of the simplest yet one of the most important pages of your platform, and comes at the start of every possible user journey that you may want to test. Hence, it is also one of the most important web pages for your web application.&lt;/p&gt;

&lt;p&gt;So today, we are going deeper into how you can &lt;a href="https://www.lambdatest.com/feature?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;perform Selenium automation testing&lt;/a&gt; of Signup form page. We are going to execute automation testing with Selenium and Java. In one of our previous &lt;a href="https://www.lambdatest.com/blog/selenium-java-tutorial-how-to-test-login-process/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;Selenium Java tutorials&lt;/a&gt;, we demonstrated how to automate the login process using Selenium automation testing.&lt;/p&gt;

&lt;p&gt;Today, we will take an example of a Registration Page / Sign Up Page from LambdaTest. We will start our discussion with the test cases and process for the registration page of LambdaTest and then move to the Automation part to see how we can increase our browser coverage for efficient &lt;a href="https://www.lambdatest.com/"&gt;cross browser testing&lt;/a&gt; and accelerate automation testing through &lt;a href="https://www.lambdatest.com/blog/setup-selenium-grid-for-parallel-execution/"&gt;parallel testing on Selenium Grid&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Before moving forward, let’s look at the workflow in a bit more detail and see how &lt;a href="https://accounts.lambdatest.com/register?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;Sign Up page of LambdaTest&lt;/a&gt; works.&lt;/p&gt;

&lt;p&gt;As a first step, we enter URL &lt;a href="https://www.lambdatest.com?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;https://www.lambdatest.com&lt;/a&gt; in any browser to reach the landing page of the LambdaTest website. You can refer following screenshot for the landing page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q2DTCWh3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q2DTCWh3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java.png" alt="LambdaTest"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From there we are going to click on &lt;strong&gt;‘Free Signup’&lt;/strong&gt; button and reach to the &lt;a href="https://accounts.lambdatest.com/register"&gt;Registration page&lt;/a&gt; of the LambdaTest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mc9B1MtI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mc9B1MtI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java1.png" alt="Registration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let us check the Functional fields on this Registration page and list them down.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Organization&lt;/strong&gt; / &lt;strong&gt;Company Name&lt;/strong&gt; (Text field)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full Name&lt;/strong&gt; of the user (Text field)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Work Email&lt;/strong&gt; Id (Text field)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Desired Password&lt;/strong&gt; (Text field)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Phone&lt;/strong&gt; number of the user (Text field)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terms and Privacy Policy&lt;/strong&gt; (checkbox)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free Signup&lt;/strong&gt; (button)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  WorkFlow Of The Sign Up Page
&lt;/h2&gt;

&lt;p&gt;Enter all the required fields: Full Name, Work Email, Desired Password, Phone number, Terms and Privacy policy checkbox.&lt;/p&gt;

&lt;p&gt;Validate the fields:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Work email : Should not be an existing user, valid email.&lt;/li&gt;
&lt;li&gt;Password : Should provide minimum required length for password.&lt;/li&gt;
&lt;li&gt;Phone Number&lt;/li&gt;
&lt;li&gt;Terms and Privacy policy checkbox&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Till now, we have discussed all the basic things about the registration page, specifically related to the &lt;a href="https://accounts.lambdatest.com/register?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;registration page of LambdaTest&lt;/a&gt;. So let us proceed with &lt;a href="https://www.lambdatest.com/blog/17-lessons-i-learned-for-writing-effective-test-cases/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;writing test cases&lt;/a&gt; for this page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Possible Test Scenarios of the Sign Up Page
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/webinar/cross-browser-testing-with-Selenified-and-LambdaTest?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u9BGLwTE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/webinar/blog-cta/webinar-image.png" alt="Web UI Testing with Python and LambdaTest"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Elements
&lt;/h3&gt;

&lt;p&gt;Check if all buttons, title, checkboxes are present on the page and if those are working by clicking on all buttons and checkboxes. In case of LambdaTest registration page, we should check the following buttons, text fields, terms and privacy policy checkbox, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Links
&lt;/h3&gt;

&lt;p&gt;Check if all the links present on the page are redirects to the expected pages.&lt;br&gt;&lt;br&gt;
We also need to check if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LambdaTest&lt;/strong&gt; link redirects to LambdaTest are launching the correct page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terms of Service&lt;/strong&gt; link opens a new tab with redirection to the Terms of service page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy Policy&lt;/strong&gt; link opens a new tab with redirection to the Privacy Policy page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Login&lt;/strong&gt; link redirects from registration page to login page.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Optional Fields
&lt;/h3&gt;

&lt;p&gt;In case of LambdaTest registration page, only optional is Organization or Company Name. So we shall try to register with and without providing Organization or Company name, and it should be possible to complete the registration in both the cases (considering user has provided all other information correctly).&lt;/p&gt;
&lt;h3&gt;
  
  
  Required Fields
&lt;/h3&gt;

&lt;p&gt;In case of LambdaTest registration page, we have the following required fields , so let us discuss about the cases related to each field.&lt;br&gt;&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nHQJgrk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nHQJgrk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java2.png" alt="Required Fields"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Full Name&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;→ Verify without providing Full name, it should give the respective error and it should not be possible to proceed further the registration page.&lt;/p&gt;

&lt;p&gt;→ verify with providing Full name, it should be possible to complete the registration (considering user has provided all other information correctly).&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Work Email&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;→ Verify with valid email ID, but have an existing account on LambdaTest platform with that email ID, then in that case, it should not be allowed to register with that email ID and should give a respective error message (considering user has provided all other information correctly).&lt;/p&gt;

&lt;p&gt;→ Verify without providing any details in the Work Email field, it should not be allowed to register without any email ID and should give a respective error message.&lt;/p&gt;

&lt;p&gt;→ Verify with valid email ID, which does not have any account on LambdaTest platform with that email ID, so the user should be able to proceed and register successfully (considering user has provided all other information correctly).&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Desired Password&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;→ Verify without providing any password in the Desired Password field, it should give the respected error message to provide the password.&lt;/p&gt;

&lt;p&gt;→ As we can see that there is a minimum length of characters for the password is required, which is at least 8 characters are required. So we can make use of test design technique Boundary Value Analysis (BVA), as we have minimum criteria of 8 characters so we can test with lengths 7, 8 and 9 characters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When it is less than 7 then it should give the error to the user and user can proceed to complete the registration process.&lt;/li&gt;
&lt;li&gt;When it is 8 then it should be possible for the user to complete the registration process successfully without any error. (considering user has provided all other information correctly).&lt;/li&gt;
&lt;li&gt;When it is 9 then also it should be possible for the user to complete the registration process successfully without any error. (considering user has provided all other information correctly).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Phone&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;→ Verify without providing any phone number in the field, as it is also mandatory field so user should not be able to proceed and complete the registration without providing phone number.&lt;/p&gt;

&lt;p&gt;→ Verify with providing invalid phone number ( phone number with 2-3 digit), in this case also user should not be able to proceed and complete the registration with invalid providing phone number.&lt;/p&gt;

&lt;p&gt;→ Verify with providing valid phone number in the field, in this case the user should be able to register successfully with valid phone number (considering user has provided all other information correctly).&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Terms of Service checkbox:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;→ Verify without checking Terms of Services checkbox, as it is required field in the registration process user can not proceed to complete the registration process without checking this checkbox.&lt;/p&gt;

&lt;p&gt;→ Verify with Terms of services checkbox is selected, then user can complete the registration successfully without any error (considering user has provided all other information correctly).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So we have seen till now&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the fields generally present on the Registration Page, along with the example of registration page of LambdaTest.&lt;/li&gt;
&lt;li&gt;Expected workflow of the registration page.&lt;/li&gt;
&lt;li&gt;Test cases/scenarios for the Registration page&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Automating User SignUp Form Using Selenium and Java
&lt;/h2&gt;

&lt;p&gt;So far in this Selenium Java tutorial, you have established a fair understanding of what you need to test on the Signup page. With that in mind, let us roll into action and automate this Signup page by performing Selenium automation testing with Java and TestNG.&lt;/p&gt;

&lt;p&gt;We will now come up with a Selenium automation scripts and execute it on an online Selenium Grid. We will also leverage the power of parallel testing to fast track our automated cross browser testing. But before all that, you should be ready with the below prerequisites.&lt;/p&gt;
&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before moving to the script, let us go through some basic prerequisites to write and execute Selenium Automation test script.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;JDK and JRE&lt;/strong&gt; – This is required to execute any Java program in our system. You can download it from the official website of Oracle.
&lt;a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html"&gt;https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d26P25oU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d26P25oU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java3.png" alt="Java"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Eclipse IDE&lt;/strong&gt; – We have used Eclipse to write our program or test script. You can download it from the &lt;a href="https://www.eclipse.org/downloads/"&gt;official website of Eclipse&lt;/a&gt; or you can use any other IDE as per your choice.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--42LTyK6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--42LTyK6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java4.png" alt="Eclipse"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Selenium Jars&lt;/strong&gt; – To write any Selenium automation testing script, it is required to have Selenium Jars in the project. You can download Selenium Jars from the &lt;a href="https://www.seleniumhq.org/download/"&gt;official website of Selenium&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TestNG Framework&lt;/strong&gt; – In the following test script we have used TestNG framework for Selenium automation testing which will help us in generating test reports, prioritizing test cases, grouping the test cases and also for parallel execution on different browsers.
You can either download TestNG Jars or you can directly add it inside Eclipse from Eclipse Marketplace using the &lt;a href="http://beust.com/eclipse"&gt;TestNG Eclipse URL&lt;/a&gt; or you may refer to &lt;a href="https://testng.org/doc/download.html"&gt;TestNG to download&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the below example, we have integrated our test script with LambdaTest, a cross browser testing tool. Wondering why we are running our Selenium automation tests on cloud-based Selenium testing tool such as LambdaTest?&lt;/p&gt;

&lt;p&gt;Although, Selenium empowers you to automate your web application testing across different browsers. You can only perform Selenium automation testing on browsers installed on your machine where the local webdriver is running. Now, installing hundreds of browsers and maintaining the library for your inhouse Selenium infrastructure can be very strenous, not to forget, time-consuming too.&lt;/p&gt;

&lt;p&gt;This is why it is recommended to run Selenium automation testing on an online &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;Selenium testing tool&lt;/a&gt; such as LambdaTest but that is not the only reason to it. LambdaTest is a lot more!&lt;/p&gt;
&lt;h3&gt;
  
  
  What is LambdaTest?
&lt;/h3&gt;

&lt;p&gt;LambdaTest is a cross browser testing tool on cloud which offers both manual and automated browser compatibility testing on a Selenium Grid consisting 2000+ real browsers on cloud. LambdaTest allows you to execute parallel testing, generate detailed test reports of Selenium automation testing, provides you with recorded video of the entire test script execution, along with the ability to seamlessly integrate your Selenium automation testing suite with your favourite CI/CD tools. It also offers native plugins for Jenkins, and more.&lt;/p&gt;
&lt;h2&gt;
  
  
  Selenium Automation Testing For SignUp Page With LambdaTest
&lt;/h2&gt;

&lt;p&gt;So, now let’s discuss the process of how we can integrate our test script with LambdaTest and execute it to see the results.In our selenium test script we initialize the WebDriver as,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebDriver driver = new ChromeDriver();
Or 
WebDriver driver = new FirefoxDriver();
Or 
WebDriver driver = new EdgeDriver();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;While to start with, when we want to run test script on LambdaTest Selenium grid we have to initialize the WebDriver as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WebDriver driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub"),
DesiredCapabilities.firefox()); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now few questions will arise like what are these username and accesskey is for? So we can generate these username and accesskey from &lt;a href="https://lambdatest.com/capabilities-generator/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;LambdaTest Capabilities Generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Qo09KZx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Qo09KZx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java5.png" alt="LambdaTest Capabilities Generator."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here once we select the OS, Browser, Selenium WebDriver version etc., we can get the username and accesskey for our users which we can use in the test script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; To generate this username and accesskey, you should be registered and logged in your LambdaTest account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a8XwNCWX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a8XwNCWX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/selenium-java6.png" alt="Registeration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after we generate those username and accesskey, we can use those in our test script in integration with LambdaTest. We have created the following test script for the LambdaTest registration page/ Sign Up page, we have covered the test scenarios which we have discussed above as manual test cases and scenarios.&lt;/p&gt;

&lt;p&gt;While executing any automation test cases, there are few steps which are common and required to perform at the start of the test suite while few needs to perform before every test case which we can call as pre conditions for the test case.&lt;br&gt;&lt;br&gt;
For example: While executing every test case, we need to open the browser and navigate to the target URL before starting to execute the actual test case, delete cookies, etc..&lt;/p&gt;

&lt;p&gt;For this purpose we use @BeforeClass and @BeforeMethod annotations from Test NG, so in our case we will need&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;to set few capabilities (browser, platform etc.)&lt;/li&gt;
&lt;li&gt;Open the browser&lt;/li&gt;
&lt;li&gt;Delete cookies&lt;/li&gt;
&lt;li&gt;Open LambdaTest platform and navigate to Signup page
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public String username = "yadneshshah91";  //your LambdaTest username
    public String accesskey = "1234ABCD";      //your LambdaTest access key
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub"; //LambdaTest Hub URL
    boolean status = false;


    //Setting up capabilities to run our test script
    @Parameters(value= {"browser","version"})
    @BeforeClass
    public void setUp(String browser, String version) throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", browser);
        capabilities.setCapability("version", version);
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
        capabilities.setCapability("build", "LambdaTestSampleApp");
        capabilities.setCapability("name", "LambdaTestJavaSample");
        capabilities.setCapability("network", true); // To enable network logs
        capabilities.setCapability("visual", true); // To enable step by step screenshot
        capabilities.setCapability("video", true); // To enable video recording
        capabilities.setCapability("console", true); // To capture console logs
        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

    }

    //Opening browser with the given URL and navigate to Registration Page
    @BeforeMethod
    public void openBrowser()
    {
        driver.manage().deleteAllCookies();

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

        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);

        WebElement signUpButton = driver.findElement(By.xpath("//a[contains(text(),'Free Signup')]"));
        signUpButton.click(); 

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


&lt;p&gt;In the above part of code, notice the DesiredCapabilities object. This object is used to set capabilities like browser, version, operating system etc, and instructs LambdaTest grid to run tests on the desired configurations. If you want to run tests locally, then you would not necessarily need this object. , then we opened the browser, deleted cookies, navigate to default page of the LambdaTest and then click on the Sign Up button to redirect to our target page which is Sign Up page.&lt;/p&gt;

&lt;p&gt;Same is the case for the operations/tasks which are required to perform at the end or after the execution of test cases.&lt;br&gt;&lt;br&gt;
For Example: Closing the browser session, etc.&lt;/p&gt;

&lt;p&gt;For this we have used @AfterMethod or @AfterMethod annotations from TestNG. If you are new to TestNG, then I suggest you read our detailed article on &lt;a href="https://www.lambdatest.com/blog/complete-guide-on-testng-annotations-for-selenium-webdriver/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;TestNG annotations&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Closing the browser session after completing each test case
    @AfterClass
    public void tearDown() throws Exception {
       if (driver != null) {
            ((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
            driver.quit();
        }
    } 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above part of the code, you can see that we have closed the browser session which we need to do after every test case.&lt;/p&gt;

&lt;p&gt;As we have seen, what and how it works before and after every test case now let us execute Selenium automation testing for the test cases, discussed above. In any Selenium automation test script, to perform any actions on the elements of the web page, we need to locate them first. For this, we make use of &lt;a href="https://www.lambdatest.com/blog/locators-in-selenium-webdriver-with-examples/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;Selenium Locators&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Diving Deep Into Test Cases
&lt;/h2&gt;

&lt;p&gt;Let’s look into our test cases to comprehend our test scenarios that we need to automate with Selenium testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Case 1
&lt;/h3&gt;

&lt;p&gt;To verify if the expected elements are available on the Sign Up page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Verifying elements on Registration page
    @Test
    public void verifyElemntsOnPageTest()
    {
        WebElement lambdaTestLogo = driver.findElement(By.xpath("//p[@class='signup-titel']"));
        lambdaTestLogo.isDisplayed();

        WebElement signUpTitle = driver.findElement(By.xpath("//p[@class='signup-titel']"));
        signUpTitle.isDisplayed();

        WebElement termsText = driver.findElement(By.xpath("//label[@class='woo']"));
        termsText.isDisplayed();

        WebElement loginLinkText = driver.findElement(By.xpath("//p[@class='login-in-link test-left']"));
        loginLinkText.isDisplayed();

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



&lt;p&gt;In the above test case function verifyElemntsOnPageTest, we have located a few elements like LambdaTest logo, Sign up title, terms of services text, etc. To locate the web elements we can use different locating strategies like ID, XPath, CSS Selector, ClassName, etc.. In the above case, we have located those elements using XPath.&lt;/p&gt;

&lt;p&gt;Once those elements are located, we have verified each of them if those are displayed using method isDisplayed().&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Case 2
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To verify the redirections with the links present on the pages.

//Verifying redirection to the terms and conditions page
    @Test
    public void termsRedirectionTest()
    {
        WebElement termsLink = driver.findElement(By.xpath("//a[contains(text(),'Terms')]"));
        termsLink.click();      

        Set &amp;lt;String&amp;gt; allWindows = driver.getWindowHandles();

        for(String handle : allWindows)
        {
            driver.switchTo().window(handle);
        }                   

        String expectedURL = "https://www.lambdatest.com/terms-of-service";
        String actualURL = driver.getCurrentUrl();
        //System.out.println(actualURL);
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Terms of Service - LambdaTest";
        String actualTitle = driver.getTitle();
        //System.out.println(actualTitle);
        Assert.assertEquals(actualTitle, expectedTitle);        
    }

//Verifying Privacy policy page redirection
    @Test
    public void privacyPolicyRedirectionTest()
    {
        WebElement privacyPolicyLink = driver.findElement(By.xpath("//a[contains(text(),'Privacy')]"));
        privacyPolicyLink.click();

        Set &amp;lt;String&amp;gt; allWindows = driver.getWindowHandles();

        for(String handle : allWindows)
        {
            driver.switchTo().window(handle);
        }                   

        String expectedURL = "https://www.lambdatest.com/privacy";
        String actualURL = driver.getCurrentUrl();
        //System.out.println(actualURL);
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Privacy Policy | LambdaTest";
        String actualTitle = driver.getTitle();
        //System.out.println(actualTitle);
        Assert.assertEquals(actualTitle, expectedTitle);
    }    

    //Verifying redirection to the Login page from Registration page
    @Test
    public void loginRedirectionTest()
    {
        WebElement loginLink = driver.findElement(By.xpath("//a[contains(text(),'Login')]"));
        loginLink.click();

        String expectedURL = "https://accounts.lambdatest.com/login";
        String actualURL = driver.getCurrentUrl();
        //System.out.println(actualURL);
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Login - LambdaTest";
        String actualTitle = driver.getTitle();
        //System.out.println(actualTitle);
        Assert.assertEquals(actualTitle, expectedTitle);        
    }

    //Verifying redirection to the landing page
    @Test
    public void landingPageRedirectionTest()
    {
        WebElement lambdaTestLogo = driver.findElement(By.xpath("//p[@class='logo-home']//a//img"));
        lambdaTestLogo.click();

        String expectedURL = "https://www.lambdatest.com/";
        String actualURL = driver.getCurrentUrl();
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "";
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So here, you can see we have added 4 methods for different links present on the Sign Up page and we have verified after clicking those links user is redirected to the correct URL and page or not. In the above methods, we have also added assertions to verify if the redirection is done as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Case 3
&lt;/h3&gt;

&lt;p&gt;To verify Registration process with providing valid input data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Registration with all valid data
    @Test
    public void validRegistrationTest(){            

        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test6.lambdatest@gmail.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@12345");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedURL = "https://accounts.lambdatest.com/email/verify";
        String actualURL = driver.getCurrentUrl();
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Verify Your Email Address - LambdaTest";
        String actualTitle = driver.getTitle();
        Assert.assertEquals(actualTitle, expectedTitle);

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



&lt;h3&gt;
  
  
  Test Case 4
&lt;/h3&gt;

&lt;p&gt;To verify registration process with different invalid input data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Registration without providing Company Name field
    @Test
    public void emptyCompanyNameTest()
    {
         WebElement companyName = driver.findElement(By.name("organization_name"));
         companyName.sendKeys("");

         WebElement fullName = driver.findElement(By.name("name"));
         fullName.sendKeys("TestName");

         WebElement email = driver.findElement(By.name("email"));
         email.sendKeys("test7.lambdatest@gmail.com");

         WebElement password = driver.findElement(By.name("password"));
         password.sendKeys("Test@12345");

         WebElement phone = driver.findElement(By.name("phone"));
         phone.sendKeys("9876543210");

         WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
         termsOfServices.click();

         WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
         signUp.click();         

        /*
         * Set &amp;lt;String&amp;gt; allWindows = driver.getWindowHandles();
         * 
         * for(String handle : allWindows) { driver.switchTo().window(handle); }
         */ 

         String expectedURL = "https://accounts.lambdatest.com/email/verify";
         String actualURL = driver.getCurrentUrl();
         Assert.assertEquals(actualURL, expectedURL);

         String expectedTitle = "Verify Your Email Address - LambdaTest";
         String actualTitle = driver.getTitle();
         Assert.assertEquals(actualTitle, expectedTitle);
    }

    // Registration without providing Name field
    @Test
    public void emptyNameTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter your Name";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter your Name')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);

    }

    // Registration without providing user email field
    @Test
    public void emptyEmailTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("test");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter your Email Address";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter your Email Address')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration with email id which already have account
    @Test
    public void invalidEmailTest()
    {

        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "This email is already registered";

        WebElement exp = driver.findElement(By.xpath("//p[@class='error-mass']"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration without providing password field
    @Test
    public void emptyPasswordTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter a desired password";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter a desired password')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration with invalid password
    @Test
    public void inValidPasswordTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("T");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Password should be at least 8 characters long";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Password should be at least 8 characters long')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
        //Password should be at least 8 characters long
    }

    // Registration without providing user phone number field
    @Test
    public void emptyPhoneTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "The phone field is required.";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'The phone field is required.')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration with providing invalid user phone number field
    @Test
    public void inValidPhoneTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("98");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter a valid Phone number";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter a valid Phone number')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);

        //Please enter a valid Phone number
    }

    // Registration without accepting terms and condition tickbox
    @Test
    public void uncheckedTerms()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        //WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        //termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedTermsErrorMessage = "To proceed further you must agree to our Terms of Service and Privacy Policy";
        WebElement uncheckedTermCheckbox = driver.findElement(By.xpath("//p[@class='error-mass mt-2']"));
        String actualTermsErrorMessage = uncheckedTermCheckbox.getText();
        //To proceed further you must agree to our Terms of Service and Privacy Policy

        Assert.assertEquals(actualTermsErrorMessage, expectedTermsErrorMessage);
    }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above part of code, you can see that we have covered different cases in which one or other field is provided with invalid input data. Also, at the end of every method we have added assertion along with expected error messages for the invalid input we have provided.&lt;/p&gt;

&lt;h2&gt;
  
  
  Entire Test Script To Automate Sign Up Using Selenium And Java
&lt;/h2&gt;

&lt;p&gt;As we have seen the Selenium automation testing script and different test cases in bits and pieces, now, let us combine this code to present the entire test script which we can be executed on multiple browsers which we provide as parameter.&lt;br&gt;&lt;br&gt;
So please also refer the testng.xml file which is provided at the end, which is very important to execute Selenium automation testing in parallel across different browsers.&lt;/p&gt;

&lt;p&gt;Automation test script for LambdaTest Registration Page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.lambdatest;


//TestNG Todo : Sample App
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import org.testng.asserts.Assertion;

import com.beust.jcommander.Parameter;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public class SignUpTest{

    public String username = "yadneshshah91";
    public String accesskey = "iD4oCZKyC8R2kwH1kLhTxAGgXZFANGoyzGDzY9RTqDTx9jskZo";
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";
    boolean status = false;


    //Setting up capabilities to run our test script
    @Parameters(value= {"browser","version"})
    @BeforeClass
    public void setUp(String browser, String version) throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("browserName", browser);
        capabilities.setCapability("version", version);
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get any available one
        capabilities.setCapability("build", "LambdaTestSampleApp");
        capabilities.setCapability("name", "LambdaTestJavaSample");
        capabilities.setCapability("network", true); // To enable network logs
        capabilities.setCapability("visual", true); // To enable step by step screenshot
        capabilities.setCapability("video", true); // To enable video recording
        capabilities.setCapability("console", true); // To capture console logs
        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

    }

    //Opening browser with the given URL and navigate to Registration Page
    @BeforeMethod
    public void openBrowser()
    {
        driver.manage().deleteAllCookies();

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

        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);

        WebElement signUpButton = driver.findElement(By.xpath("//a[contains(text(),'Start Free Testing')]"));
        signUpButton.click(); 

    }

    //Verifying elements on Registration page
    @Test
    public void verifyElemntsOnPageTest()
    {
        WebElement lambdaTestLogo = driver.findElement(By.xpath("//p[@class='signup-titel']"));
        lambdaTestLogo.isDisplayed();

        WebElement signUpTitle = driver.findElement(By.xpath("//p[@class='signup-titel']"));
        signUpTitle.isDisplayed();

        WebElement termsText = driver.findElement(By.xpath("//label[@class='woo']"));
        termsText.isDisplayed();

        WebElement loginLinkText = driver.findElement(By.xpath("//p[@class='login-in-link test-left']"));
        loginLinkText.isDisplayed();

    }

    //Verifying redirection to the terms and conditions page
    @Test
    public void termsRedirectionTest()
    {
        WebElement termsLink = driver.findElement(By.xpath("//a[contains(text(),'Terms')]"));
        termsLink.click();      

        Set &amp;lt;String&amp;gt; allWindows = driver.getWindowHandles();

        for(String handle : allWindows)
        {
            driver.switchTo().window(handle);
        }                   

        String expectedURL = "https://www.lambdatest.com/terms-of-service";
        String actualURL = driver.getCurrentUrl();
        //System.out.println(actualURL);
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Terms of Service - LambdaTest";
        String actualTitle = driver.getTitle();
        //System.out.println(actualTitle);
        Assert.assertEquals(actualTitle, expectedTitle);        
    }

    //Verifying Privacy policy page redirection
    @Test
    public void privacyPolicyRedirectionTest()
    {
        WebElement privacyPolicyLink = driver.findElement(By.xpath("//a[contains(text(),'Privacy')]"));
        privacyPolicyLink.click();

        Set &amp;lt;String&amp;gt; allWindows = driver.getWindowHandles();

        for(String handle : allWindows)
        {
            driver.switchTo().window(handle);
        }                   

        String expectedURL = "https://www.lambdatest.com/privacy";
        String actualURL = driver.getCurrentUrl();
        //System.out.println(actualURL);
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Privacy Policy | LambdaTest";
        String actualTitle = driver.getTitle();
        //System.out.println(actualTitle);
        Assert.assertEquals(actualTitle, expectedTitle);
    }    

    //Verifying redirection to the Login page from Registration page
    @Test
    public void loginRedirectionTest()
    {
        WebElement loginLink = driver.findElement(By.xpath("//a[contains(text(),'Login')]"));
        loginLink.click();

        String expectedURL = "https://accounts.lambdatest.com/login";
        String actualURL = driver.getCurrentUrl();
        //System.out.println(actualURL);
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Login - LambdaTest";
        String actualTitle = driver.getTitle();
        //System.out.println(actualTitle);
        Assert.assertEquals(actualTitle, expectedTitle);        
    }

    //Verifying redirection to the landing page
    @Test
    public void landingPageRedirectionTest()
    {
        WebElement lambdaTestLogo = driver.findElement(By.xpath("//p[@class='logo-home']//a//img"));
        lambdaTestLogo.click();

        String expectedURL = "https://www.lambdatest.com/";
        String actualURL = driver.getCurrentUrl();
        Assert.assertEquals(actualURL, expectedURL);


    }

    // Registration with all valid data
    @Test
    public void validRegistrationTest(){            

        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test6.lambdatest@gmail.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@12345");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedURL = "https://accounts.lambdatest.com/email/verify";
        String actualURL = driver.getCurrentUrl();
        Assert.assertEquals(actualURL, expectedURL);

        String expectedTitle = "Verify Your Email Address - LambdaTest";
        String actualTitle = driver.getTitle();
        Assert.assertEquals(actualTitle, expectedTitle);


    }

    // Registration without providing Company Name field
    @Test
    public void emptyCompanyNameTest()
    {
         WebElement companyName = driver.findElement(By.name("organization_name"));
         companyName.sendKeys("");

         WebElement fullName = driver.findElement(By.name("name"));
         fullName.sendKeys("TestName");

         WebElement email = driver.findElement(By.name("email"));
         email.sendKeys("test7.lambdatest@gmail.com");

         WebElement password = driver.findElement(By.name("password"));
         password.sendKeys("Test@12345");

         WebElement phone = driver.findElement(By.name("phone"));
         phone.sendKeys("9876543210");

         WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
         termsOfServices.click();

         WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
         signUp.click();


        /*
         * Set &amp;lt;String&amp;gt; allWindows = driver.getWindowHandles();
         * 
         * for(String handle : allWindows) { driver.switchTo().window(handle); }
         */ 

         String expectedURL = "https://accounts.lambdatest.com/email/verify";
         String actualURL = driver.getCurrentUrl();
         Assert.assertEquals(actualURL, expectedURL);

         String expectedTitle = "Verify Your Email Address - LambdaTest";
         String actualTitle = driver.getTitle();
         Assert.assertEquals(actualTitle, expectedTitle);
    }

    // Registration without providing Name field
    @Test
    public void emptyNameTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter your Name";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter your Name')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);

    }

    // Registration without providing user email field
    @Test
    public void emptyEmailTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("test");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter your Email Address";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter your Email Address')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration with email id which already have account
    @Test
    public void invalidEmailTest()
    {

        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "This email is already registered";

        WebElement exp = driver.findElement(By.xpath("//p[@class='error-mass']"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration without providing password field
    @Test
    public void emptyPasswordTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter a desired password";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter a desired password')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration with invalid password
    @Test
    public void inValidPasswordTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("T");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Password should be at least 8 characters long";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Password should be at least 8 characters long')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
        //Password should be at least 8 characters long
    }

    // Registration without providing user phone number field
    @Test
    public void emptyPhoneTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "The phone field is required.";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'The phone field is required.')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);
    }

    // Registration with providing invalid user phone number field
    @Test
    public void inValidPhoneTest()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("98");

        WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedErrorMsg = "Please enter a valid Phone number";

        WebElement exp = driver.findElement(By.xpath("//p[contains(text(),'Please enter a valid Phone number')]"));
        String actualErrorMsg = exp.getText();

        Assert.assertEquals(actualErrorMsg, expectedErrorMsg);

        //Please enter a valid Phone number
    }

    // Registration without accepting terms and condition tickbox
    @Test
    public void uncheckedTerms()
    {
        WebElement companyName = driver.findElement(By.name("organization_name"));
        companyName.sendKeys("TestCompany");

        WebElement fullName = driver.findElement(By.name("name"));
        fullName.sendKeys("TestName");

        WebElement email = driver.findElement(By.name("email"));
        email.sendKeys("test@test.com");

        WebElement password = driver.findElement(By.name("password"));
        password.sendKeys("Test@123");

        WebElement phone = driver.findElement(By.name("phone"));
        phone.sendKeys("9876543210");

        //WebElement termsOfServices = driver.findElement(By.id("terms_of_service"));
        //termsOfServices.click();

        WebElement signUp = driver.findElement(By.xpath("//button[contains(@class,'btn sign-up-btn-2 btn-block')]"));
        signUp.click();

        String expectedTermsErrorMessage = "To proceed further you must agree to our Terms of Service and Privacy Policy";
        WebElement uncheckedTermCheckbox = driver.findElement(By.xpath("//p[@class='error-mass mt-2']"));
        String actualTermsErrorMessage = uncheckedTermCheckbox.getText();
        //To proceed further you must agree to our Terms of Service and Privacy Policy

        Assert.assertEquals(actualTermsErrorMessage, expectedTermsErrorMessage);
    }

    // Closing the browser session after completing each test case
    @AfterClass
    public void tearDown() throws Exception {
       if (driver != null) {
            ((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
            driver.quit();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In above test script example you can observe that we have used parameterized option to provide browser name and browser version, so that we can provide the browser and browser version as per our requirement on which we need to test above test script. We can also provide multiple browsers and version to execute our test script parallely.&lt;/p&gt;

&lt;p&gt;And to achieve this we need to provide these value of browser name and version from testng.xml file, which we use with every TestNG script.&lt;br&gt;&lt;br&gt;
For example, you can refer following testng.xml in which we have provided 2 browsers (Chrome and Firefox) with their respective versions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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 "https://testng.org/testng-1.0.dtd"&amp;gt;
&amp;lt;suite thread-count="3" name="LambaTestSuite" parallel="tests"&amp;gt;

  &amp;lt;test name="FirefoxTest"&amp;gt;
  &amp;lt;parameter name="browser" value="firefox"/&amp;gt;
  &amp;lt;parameter name="version" value="69.0"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="com.lambdatest.SignUpTest"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;

  &amp;lt;test name="ChromeTest"&amp;gt;
  &amp;lt;parameter name="browser" value="chrome"/&amp;gt;
  &amp;lt;parameter name="version" value="77.0"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="com.lambdatest.SignUpTest"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; &amp;lt;!-- Test --&amp;gt;

    &amp;lt;test name="EdgeTest"&amp;gt;
  &amp;lt;parameter name="browser" value="edge"/&amp;gt;
  &amp;lt;parameter name="version" value="44.0"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="com.lambdatest.SignUpTest"/&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;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lyqqj1BO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/pasted-image-0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lyqqj1BO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/pasted-image-0.png" alt="test_cases"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TIY2RymE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/test-cases-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TIY2RymE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/test-cases-2.png" alt="test cases 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is a snapshot of the final execution that was triggered over the LambdaTest platform. We have executed the cross browser testing automation script over two browsers i.e. Google Chrome 77 and Mozilla Firefox 69.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nzemksNL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/lambdatest_testing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nzemksNL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/lambdatest_testing.png" alt="lambdatest dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you gaze over the LambdaTest &lt;a href="https://automation.lambdatest.com/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;automation dashboard&lt;/a&gt;, you will be able to notice multiple tabs representing different types of logs for your test automation script. You get tabs to analyze command logs, network logs, raw Selenium logs, metadata, and more. You also get a full video-recording of your cross browser testing script over the LambdaTest cloud servers, along with command-by-command screenshot.&lt;/p&gt;

&lt;h2&gt;
  
  
  That Was All
&lt;/h2&gt;

&lt;p&gt;Now, you are good to go with automation for Signup page using Selenium and Java. In this Selenium Java tutorial, we gazed upon the registration process of LambdaTest. We thought of different test cases, compiled a test script to have them executed and the &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;Selenium Automation testing&lt;/a&gt; script was then analyzed to run for different browsers in parallel.&lt;/p&gt;

&lt;p&gt;The Selenium automation test scripts were executed using Selenium and Java, with the help of TestNG framework. In case you feel I missed out on a peculiar test cases regarding the LambdaTest registration page then feel free to let me know. I am all ears! Happy testing. 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-20112019&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--huJVywGY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/d28b6b28-2b25-4262-917b-357613768dc1/" alt="Adword  Dark Blue.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>csharp</category>
      <category>java</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Mastering Selenium Testing: JUnit Asserts With Examples
</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Mon, 18 Nov 2019 11:54:22 +0000</pubDate>
      <link>https://forem.com/ramitd1995/mastering-selenium-testing-junit-asserts-with-examples-4ei8</link>
      <guid>https://forem.com/ramitd1995/mastering-selenium-testing-junit-asserts-with-examples-4ei8</guid>
      <description>&lt;p&gt;Automation testing helps to ease the life of software testers by allowing them to automate their repetitive tasks, and open-source &lt;a href="https://www.lambdatest.com/blog/top-5-java-test-frameworks-for-automation-in-2019/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;test automation frameworks&lt;/a&gt; like Selenium have enabled users to automate web testing experience, at scale. However, what good is automation testing if you are not able to verify whether a test case has passed or failed?&lt;/p&gt;

&lt;p&gt;This is where assertions come into the picture, so you can keep a track of how many test failures or successes were encountered after the execution of your automation script for&lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;Selenium testing&lt;/a&gt;. Today, I am going to show you how to assert in JUnit, different types of assert in JUnit by examples.&lt;/p&gt;

&lt;p&gt;We will be starting off with a basic introduction to assertions and JUnit. If you are already experiencing you may want to skip these headings. We would be talking in detail about the&lt;br&gt;&lt;br&gt;
following assert method for JUnit:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#1?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertEquals()&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#111?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;Floating Point assertion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#2?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertTrue()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#3?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertFalse()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#4?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertNull()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#5?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertNotNull()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#6?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertSame()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#7?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertNotSame()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#8?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertArrayEquals()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#9?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertAll()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#10?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;assertThrows()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lambdatest.com/blog/junit-assertions-example-for-selenium-testing/#11?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;Third-Party Assertions in JUnit&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We would also glance upon the difference between JUnit4 and JUnit5 in terms of assertions in JUnit. Without further ado, here we go!&lt;/p&gt;
&lt;h2&gt;
  
  
  What Are Assertions? Why Are They Used?
&lt;/h2&gt;

&lt;p&gt;Assertions are an integral part of the automation testing irrespective of the tools and frameworks put to use in Selenium testing. Assertions are used in the testing to verify or check that the result of the action/functionality is the same as what is expected after the execution of tests. Simply put, they are used to verify the status of a test case as either passed or failed.&lt;/p&gt;

&lt;p&gt;When we run the test case/ scenario which we are automating, then figuring out the scenarios that passed or failed is pivotal to realize whether the execution of our automation script is as expected or not?&lt;/p&gt;

&lt;p&gt;We have to provide some kind of assertions to do that, so at the end of the action, our code will compare and assert in JUnit or any other test automation framework, to evaluate If the result which we are getting is as expected.&lt;/p&gt;

&lt;p&gt;If the actual results are the same as an expected result then we can mark that assertion as passed and if it does not meet then we can mark that assertion as failed.&lt;/p&gt;

&lt;p&gt;When all the assertions in the test script are met, only then a test case is considered as passed. Assertions in Selenium Java can be handled with the predefined methods of JUnit framework.&lt;/p&gt;

&lt;p&gt;There are 2 broad types of assertions for Selenium testing i.e. Hard Assertions, and Soft Assertions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hard Assertions –&lt;/strong&gt; Hard assertions are used when we want out test script to halt immediately if the assertion conditions do not match the expected result. An Assertion Error will be encountered as the assertion condition failed to meet the expected outcome and the test case under execution will be marked as Failed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Soft Assertions –&lt;/strong&gt; The test script execution is not put to halt even if the assertion condition is not met. Also, in case of soft assertions, there will be no error thrown, when the assertion condition would fail to meet the expected result, and execution of test scripts will continue to the next test case step.&lt;/p&gt;

&lt;p&gt;With that said, it is time to deep dive into various types of asserts in JUnit by examples.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/webinar/cross-browser-testing-with-Selenified-and-LambdaTest?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u9BGLwTE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/webinar/blog-cta/webinar-image.png" alt="Web UI Testing with Python and LambdaTest"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Types Of Assertion In JUnit For Selenium Testing
&lt;/h2&gt;

&lt;p&gt;Assert methods in JUnit are provided by the class “ &lt;strong&gt;org.junit.Assert&lt;/strong&gt; ” which extends “ &lt;strong&gt;java.lang.Object&lt;/strong&gt; ” class. Now, we will look into different methods to assert in JUnit by examples. If you are not familiar with JUnit you can refer to our blog: &lt;a href="https://www.lambdatest.com/blog/automated-testing-with-junit-and-selenium-for-browser-compatibility/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;Automated Testing with JUnit and Selenium for Browser Compatibility&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  assertEquals()
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;JUnit assertEquals()&lt;/strong&gt; method compares equality of the expected result with the actual result. When the expected result provided by us does not match with the actual result of the Selenium testing script which we get after the action performed then it throws an assertion error. This leads to the termination of the execution of the test script, at that line itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertEquals(String expected, String actual);
      Assert.assertEquals(String message, String expected, String actual); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is a JUnit assertEquals example to help you understand the process better.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.test;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AssertionDemoClass {


    public static WebDriver driver;

    @BeforeClass
    public static void openBrowser()
    {
        System. setProperty("webdriver.chrome.driver", "D:\\AutomationPractice\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void assertURL() {
        // TODO Auto-generated method stub
        driver.get("https://www.lambdatest.com/");

        String actualURL = driver.getCurrentUrl();
        System.out.println(actualURL);

        Assert.assertEquals("https://www.lambdatest.com/",actualURL);
        System.out.println("Test Passed");
    }

    @AfterClass
    public static void closeBrowser()
    {
        driver.close();
    }

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



&lt;p&gt;In the above code, we can see that we have provided two parameters in the JUnit assertEquals() method, which is an expected result and actual result. If the value of actualURL does not match with the expected URL mentioned in the Selenium testing script then the assertion error will be thrown and execution of the program will get terminated at this same line i.e. assertion statement itself.&lt;/p&gt;

&lt;p&gt;We can also pass assertion error message as a parameter which is shown in syntax.&lt;/p&gt;

&lt;h4&gt;
  
  
  JUnit assertEquals for Floating Point Assertion
&lt;/h4&gt;

&lt;p&gt;If we require to compare floating point types (eg. double or float), in that case, to avoid errors of rounding we have to provide additional parameter which can be known as &lt;strong&gt;delta&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
The value for delta can be evaluated as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Math.abs(expected – actual) = delta&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If there is any marginal difference in the expected and actual values due to rounding off, those can be considered as same and assertion should be marked as pass. So value of delta given by the user decides which margin value should be considered as fine to pass that assertion.&lt;/p&gt;

&lt;p&gt;This can be used with float and double data types, please refer syntax below&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void assertEquals(float expected,float actual,float delta)
public static void assertEquals(double expected,double actual,double delta) 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Assert JUnit Example for Floating Point Assertion&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Test
    public void assertURL() {
        // TODO Auto-generated method stub      

        double actualDoubleValue= 2.999;
        double expectedDoubleValue = 3.000;

        Assert.assertEquals(expectedDoubleValue, actualDoubleValue, 0.001);

        System.out.println("Test Passed");      

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



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

&lt;p&gt;If you wish to pass the parameter value as True for a specific condition invoked in a method, then you can make use of the.JUnit assertTrue(). You can make use of JUnit assertTrue() in two practical scenarios.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;By passing condition as a boolean parameter used to assert in JUnit with the assertTrue method. It throws an AssertionError (without message) if the condition given in the method isn’t True.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertTrue(boolean assertCondition); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;By passing two parameters, simultaneously in the assertTrue() method. Wherein, one parameter would be for an assertion error message and the second parameter would be for specifying the particular condition against which we need to apply our assertion method as True. It throws an AssertionError (with message) if the condition given in the method is not True.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertTrue(String message, boolean assertCondition); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let us look at an assert JUnit example Selenium testing script for assertTrue():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.assertions.junit 1;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AssertionDemo1 {

    public static WebDriver driver;

    @BeforeClass
    public static void openBrowser()
    {
        System. setProperty("webdriver.chrome.driver", "D:\\AutomationPractice\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void assertURL() {
        driver.get("https://www.spicejet.com/");

        String actualURL = driver.getCurrentUrl();
        System.out.println(actualURL);

        String expectedURL="https://www.spicejet.com/";

        Assert.assertTrue("URL does not match",expectedURL.equals(actualURL));
        System.out.println("Test Passed");  

    }


    @AfterClass
    public static void closeBrowser()
    {
        driver.close();
    }
} 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above code, we can see that we have provided two parameters in the assertTrue() method, which is an assertion error message and boolean condition. If the condition does not match or is not true then the assertion error will be thrown and execution of the program will get terminated at this same line i.e. assertion statement itself.&lt;/p&gt;

&lt;p&gt;If we do not want to provide assertion error message then we can just provide condition as we can see in the syntax mentioned above.&lt;/p&gt;

&lt;h3&gt;
  
  
  assertFalse()
&lt;/h3&gt;

&lt;p&gt;On the contrary to JUnit assertTrue, we can make use of the assertFalse() method to verify whether a given condition is False or not. You can declare JUnit assertFalse in two ways as well.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It takes a condition as a parameter against which the assertion needs to be applied.It throws an AssertionError (without message) if the condition given in the method is not False.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Syntax:&amp;lt;&amp;gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertFalse(boolean condition); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Similar to assertTrue, you can pass two parameters for assertFalse as well. One to determine the assertion error message and another to specify the condition against which apply the assertFalse. It throws an AssertionError (with message) if the condition given in the method is not False.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertFalse(String message, boolean condition);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let us look at an assert JUnit example Selenium testing script for assertFalse():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.assertions.junit 1;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AssertionDemo1 {

    public static WebDriver driver;

    @BeforeClass
    public static void openBrowser()
    {
        System. setProperty("webdriver.chrome.driver", "D:\\AutomationPractice\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void assertURL() {
        // TODO Auto-generated method stub
        driver.get("https://www.spicejet.com/");

        String actualURL = driver.getCurrentUrl();
        System.out.println(actualURL);

        String expectedURL="https://www.google.com/";

        Assert.assertFalse("URL does match",expectedURL.equals(actualURL));
        System.out.println("Test Passed");          
    }

    @AfterClass
    public static void closeBrowser()
    {
        driver.close();
    }
} 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above Selenium testing script, we can see that we have provided two parameters in the assertFalse() method, which is an assertion error message and a boolean condition. If the condition does match or is not false then the assertion error will be thrown and execution of the program will get terminated at this same line i.e. assertion statement itself.&lt;/p&gt;

&lt;p&gt;If we do not want to provide assertion error message then we can just provide condition as we can see in the syntax mentioned above.&lt;/p&gt;

&lt;h3&gt;
  
  
  assertNull()
&lt;/h3&gt;

&lt;p&gt;To verify whether a passed object contains a null value or not, we make use of the assertNull() method which helps to display an assertion error in case the object is not of null values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertNotNull(Object obj);
    Assert.assertNotNull(String msg, Object obj);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let us look at an example Selenium testing script for JUnit assertNull():&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.assertions.junit 1;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AssertionDemo1 {

    public static WebDriver driver;


    //To open the browser before running test
    @BeforeClass
    public static void openBrowser()
    {
        System. setProperty("webdriver.chrome.driver", "D:\\AutomationPractice\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void assertURL() {

        //Redirect to the URL 
        driver.get("https://www.spicejet.com/");

        String actualURL = driver.getCurrentUrl();
        System.out.println(actualURL);

        String expectedURL="https://www.google.com/";

        //Assertion     
        Assert.assertNotNull("Null Object", actualURL);;
        System.out.println("Test Passed");  

    }

    //To close the browser after running test
    @AfterClass
    public static void closeBrowser()
    {
        driver.close();
    }

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



&lt;p&gt;In the above code we can see that we have provided two parameters in the assertNull() method, which is an assertion error message and an object. If the provided object is not null then the assertion error will be thrown and the execution of the program will get terminated at this same line i.e. assertion statement itself.&lt;br&gt;&lt;br&gt;
If we do not want to provide assertion error message then we can just provide an object as we can see in the syntax mentioned above.&lt;/p&gt;
&lt;h3&gt;
  
  
  assertNotNull()
&lt;/h3&gt;

&lt;p&gt;assertNotNull() method checks if provided object does not hold a null value. We can pass an object as a parameter in this method and we will get Assertion Error if the object which we pass does hold NULL values along with the assertion error message if provided.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Assert.assertNotNull(Object obj);
    Assert.assertNotNull(String msg, Object obj); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let us look at an assert JUnit example Selenium testing script for assertNotNull():&lt;/p&gt;

&lt;p&gt;package com.assertions.junit 1;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AssertionDemo1 {

    public static WebDriver driver;


    //To open the browser before running test
    @BeforeClass
    public static void openBrowser()
    {
        System. setProperty("webdriver.chrome.driver", "D:\\AutomationPractice\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void assertURL() {

        //Redirect to the URL 
        driver.get("https://www.spicejet.com/");

        String actualURL = driver.getCurrentUrl();
        System.out.println(actualURL);

        String expectedURL="https://www.google.com/";

        //Assertion     
        Assert.assertNotNull("Null Object", actualURL);;
        System.out.println("Test Passed");  

    }

    //To close the browser after running test
    @AfterClass
    public static void closeBrowser()
    {
        driver.close();
    }

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



&lt;p&gt;In the above code we can see that we have provided two parameters in the assertNotNull() method, which is an assertion error message and an object. If the provided object is null then only the assertion error will be thrown and the execution of the program will get terminated at this same line i.e. assertion statement itself.&lt;/p&gt;

&lt;p&gt;If we do not want to provide an assertion error message then we can just provide an object as we can see in the syntax mentioned above.&lt;/p&gt;

&lt;h3&gt;
  
  
  assertSame()
&lt;/h3&gt;

&lt;p&gt;While &lt;a href="https://www.lambdatest.com/blog/speed-up-automated-parallel-testing-in-selenium-with-testng/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;performing Selenium testing&lt;/a&gt; you may often encounter a scenario where you would need to compare two different objects passed as parameters in a method, to evaluate whether they are referring to the same object or not. This is where you can make use of JUnit assertSame(). As assertion error is displayed if the two objects don’t refer to the same object. Also, we will receive Assertion Error message along with that if message is provided as shown in below syntax.&lt;/p&gt;

&lt;p&gt;Syntax for JUnit assertSame() in Selenium testing script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; a) Assert.assertSame(Object expected, Object actual);
    b) Assert.assertSame(String message, Object expected, Object actual); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  assertNotSame()
&lt;/h3&gt;

&lt;p&gt;assertNotSame() method verifies that if the two objects which we have passed as parameters are not equal. If both objects have the same references, then an Assertion Error will be thrown with the message which we have provided (if any).&lt;br&gt;&lt;br&gt;
One more thing to observe in this method is, it compares references of the object and not the value of those objects.&lt;/p&gt;

&lt;p&gt;Syntax for JUnit assertNotSame() in Selenium testing script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   a) Assert.assertNotSame(Object expected, Object actual);
    b) Assert.assertNotSame(String message, Object expected, Object actual); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  assertArrayEquals()
&lt;/h3&gt;

&lt;p&gt;assertArrayEquals() method verifies that if the two object arrays which we have passed as parameters are equal. If both the object arrays have the values as null, then they will be considered as equal.&lt;br&gt;&lt;br&gt;
This method will throw an Assertion Error with the message provided if both the object arrays which we have passed as parameters in method are not considered equal.&lt;/p&gt;

&lt;p&gt;Syntax for JUnit assertArrayEquals() in Selenium testing script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a) Assert.assertArrayEquals(Object[] expected, Object[] actual);
    b) Assert.assertArrayEquals(String message, Object[] expected, Object[] actual);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Latest Version Of JUnit: JUnit 5
&lt;/h2&gt;

&lt;p&gt;JUnit 5 offers a new architecture which is redesigned to overcome the problems with the older versions of JUnit. The new architecture consists of a combination of various modules for &lt;strong&gt;JUnit Platform&lt;/strong&gt; , &lt;strong&gt;JUnit Jupiter&lt;/strong&gt; and &lt;strong&gt;JUnit Vintage&lt;/strong&gt;. If you are curious to know about JUnit Platform, JUnit Jupiter or JUnit Vintage then I suggest you read &lt;a href="https://junit.org/junit5/docs/current/user-guide/"&gt;JUnit’s official guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;JUnit 5 comes with some additional new methods to assert in JUnit. Before we go through them, we must realize the difference in ways to assert in JUnit 5 and JUnit 4.&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference In JUnit Assertions Between JUnit5 vs JUnit4
&lt;/h3&gt;

&lt;p&gt;JUnit Jupiter comes with many of the assertion methods which are already present in the JUnit 4 and it adds a few more assertion methods that lend themselves well to being used with Java 8 Lambdas. Ass the assertions in JUnit Jupiter are the static methods from the class org.junit.jupiter.api.Assertions&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Junit 4&lt;/strong&gt; , &lt;code&gt;org.junit.Assert&lt;/code&gt; has different assertion methods which validate expected results and resulted outcomes. Also we can give extra parameter for Assertion Error message as FIRST argument in method signature. You can refer to them in the below syntax or in every method which we discussed above.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void assertEquals(long expected, long actual);
    public static void assertEquals(String message, long expected, long actual); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In JUnit 5&lt;/strong&gt; , &lt;code&gt;org.junit.jupiter.Assertions&lt;/code&gt; contains most of assert methods including additional assertThrows() and assertAll() methods.&lt;/p&gt;

&lt;p&gt;JUnit 5 assertions methods also have overloaded methods to support passing error message to be printed in case test fails&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---EPpHxde--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/9b88277a-be64-4579-b476-74cd454c7094/" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---EPpHxde--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://ucarecdn.com/9b88277a-be64-4579-b476-74cd454c7094/" alt="Capture35.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void assertEquals(long expected, long actual);
public static void assertEquals(long expected, long actual, String message);
public static void assertEquals(long expected, long actual, Supplier messageSupplier); 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  New Methods To Assert In JUnit5
&lt;/h2&gt;

&lt;p&gt;Now, that we have a clear understanding of the difference in ways to assert in JUnit5 vs JUnit 4. We will now dig deep into the latest methods to assert in JUnit5.&lt;/p&gt;

&lt;h3&gt;
  
  
  assertAll()
&lt;/h3&gt;

&lt;p&gt;The newly added method &lt;strong&gt;assertAll()&lt;/strong&gt; will be executed to check all the assertions as grouped assertion. It has an optional heading parameter which allows to recognize group of assertions with that method assertAll().While at the time of failure, assertion error message shows detailed information about each and every field assertion which are used in that group.&lt;/p&gt;

&lt;p&gt;Let’s look at an assert JUnit example for &lt;strong&gt;assertAll&lt;/strong&gt; with grouped assertion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;

import java.util.Arrays;
import java.util.List;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class AssertionDemoClass {

    public static WebDriver driver;

    @BeforeClass
    public static void openBrowser()
    {
        System. setProperty("webdriver.chrome.driver", "D:\\AutomationPractice\\chromedriver_win32\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.manage().window().maximize();
    }

    @Test
    public void assertURL() {
        // TODO Auto-generated method stub
        driver.get("https://www.spicejet.com/");


        String actualURL = driver.getCurrentUrl();
        System.out.println(actualURL);
        String expectedURL="https://www.spicejet.com/";

        String actualTitle =  driver.getTitle();
        System.out.println(actualTitle);
        String expectedTitle = "SpiceJet - Flight Booking for Domestic and International, Cheap Air Tickets";

        Assertions.assertAll( 
                () -&amp;gt; assertEquals(expectedURL, actualURL),
                () -&amp;gt; assertEquals(expectedTitle, actualTitle)
                );

        System.out.println("Test Passed");
    }

    @AfterClass
    public static void closeBrowser()
    {
        driver.close();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  assertThrows()
&lt;/h3&gt;

&lt;p&gt;Another newly added method in JUnit 5 is to replace the &lt;strong&gt;ExpectedException Rule&lt;/strong&gt; from JUnit 4. Now, all assertions can be made against the returned instance of a class Throwable which will make the test scripts more readable. As executables we can use lambdas or method references.&lt;/p&gt;

&lt;h3&gt;
  
  
  Third-party Assertions In JUnit
&lt;/h3&gt;

&lt;p&gt;JUnit Jupiter provides sufficient assertion facilities for most of the testing scenarios, but there can be some scenarios which require additional functionalities apart from which are provided by JUnit Jupiter like matchers are desired or required.&lt;br&gt;&lt;br&gt;
For such scenarios, it is recommended by JUnit team to use the third party assertion libraries like Hamcrest, AssertJ, Truth, etc. User can use these third-party libraries whenever there is a need.&lt;/p&gt;

&lt;p&gt;Just for an assert JUnit example, To make assertions more descriptive and readable, we can use the combination of matchers and a fluent API.&lt;/p&gt;

&lt;p&gt;While, JUnit Jupiter’s (JUnit 5) org.junit.jupiter.api.Assertions class does not provide method assertThat() which was available with org.junit.Assert class in JUnit 4 which accepts a Hamcrest Matcher. That way, you can leverage the built-in support for matchers offered by third party assertion libraries.&lt;/p&gt;

&lt;p&gt;Assert JUnit Example for Selenium Testing using Third-Party assertions :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Test
    public void assertWithHamcrestMatcher() {       

        TestAssertClass tA = new TestAssertClass();

        assertThat(tA.testSubstract(5, 2), is(equalTo(3)));                 
    } 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Results For Test Cases Passed In Selenium Testing:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;When the assertion is pass and so is test case, we can see the JUnit result as below&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--loosCA6r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/junit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--loosCA6r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/junit.png" alt="junit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When the assertion is &lt;strong&gt;failed&lt;/strong&gt; and so is the test case, we can see that in the result as below. Also, we can see the Assertion Error message we have provided.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s_PQtEKg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/assertion-is-failed.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s_PQtEKg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/10/assertion-is-failed.png" alt="assertion is failed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summing It Up
&lt;/h2&gt;

&lt;p&gt;Assertions play an indispensable role if you are performing&lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;automation with Selenium testing&lt;/a&gt;. They help us figure out whether a test case has passed or failed by evaluating the parameters passed into objects through our Selenium testing scripts. If you wish to have automation logs managed neatly and organized then assertions can do wonders for you.&lt;/p&gt;

&lt;p&gt;So far you have learned various methods to assert in JUnit with examples, you also dwelled upon the difference between JUnit5 and JUnit4 with respect to assertions in JUnit. We also covered the newly introduced assertions in JUnit, along with third-party assertions in JUnit.&lt;/p&gt;

&lt;p&gt;I hope this article helped you become proficient in &lt;a href="https://www.lambdatest.com/blog/tutorial-on-junit-annotations-in-selenium-with-examples/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;Selenium testing with JUnit&lt;/a&gt; assertions. Let me know in the comments about how you use the assertions in JUnit, if there are any favourite ones, or if there are any questions. Happy Testing! 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Harshit-15112019&amp;amp;utm_term=Harshit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0j-luKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg" alt=" cross browser testing"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>selenium</category>
      <category>testing</category>
    </item>
    <item>
      <title>How to Integrate LambdaTest with Calliope.pro?
</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Thu, 31 Oct 2019 11:38:48 +0000</pubDate>
      <link>https://forem.com/ramitd1995/how-to-integrate-lambdatest-with-calliope-pro-5h48</link>
      <guid>https://forem.com/ramitd1995/how-to-integrate-lambdatest-with-calliope-pro-5h48</guid>
      <description>&lt;p&gt;Collaboration is pivotal for any successful release. Can you imagine going through a sprint without consulting or informing any other team involved in the project about what you did? You can’t right because it is not a pretty picture. Modern SDLCs demand various teams to coordinate as they try to deliver a product as quickly as possible in the market, with assured quality.&lt;/p&gt;

&lt;p&gt;Your job as an automation tester doesn’t end up by merely running automation scripts for your web application, you also have to share the test results across different teams such as the development team, or business analysts. Generating and presenting reports requires a lot of effort as your reports need to clearly indicate which modules are working fine and which ones are failing.&lt;/p&gt;

&lt;p&gt;This week I added a new tool in my testing checklist to help me share across the results of my Selenium automation testing across my team as I performed automated cross browser testing, and the tool is &lt;a href="https://www.calliope.pro/"&gt;Calliope&lt;/a&gt;. In this article, I am going to help you integrate your LambdaTest account with Calliope, so you could share reports of test automation scripts executed at LambdaTest Selenium Grid across your teammates in a jiffy. Let’s start with the big question.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Calliope?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tft1L9D_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/Calliope.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tft1L9D_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/Calliope.png" alt="Calliope"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Calliope is cloud-based tool providing you with a collective dashboard for sharing, and monitoring, and comparing the results of your automation script execution. Offering compatibility with major test automation frameworks, Calliope enables your organization to have a unified view of everything that is going around with your automation test scripts. Your stakeholders can analyze it too for comparing the current state of your test cycles with a historic state.&lt;/p&gt;

&lt;p&gt;Calliope ensures that your entire team is on the same page when it comes to analyzing your test results. Here is how:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sharing your test results –&lt;/strong&gt; Your test results are presented in Gherkin syntax, making it easier to understand by your stockholders as well. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customize your own dashboard –&lt;/strong&gt; Invite your colleagues and structure the dashboard in a manner as you structure your team.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compare Historical Data –&lt;/strong&gt; You can compare the current health status of your test builds with historical status. Plus, all your test cases are gathered in a single region allowing even your non-technical stakeholders with a clear picture of the overall health for your automation scripts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy Regression Check –&lt;/strong&gt; Calliope stores all your test imports on their clouds making it easier for you to reflect back anytime for validating your regression test cycles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API integration –&lt;/strong&gt; Calliope API will help you run your test suites on third-party tools instantly through the test results dashboard presented in your Calliope instance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI/CD Integration with GitLab –&lt;/strong&gt; Like LambdaTest, Calliope also offers integration with GitLab CI to help you import your test cases directly from your CI/CD pipeline to Calliope instance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, that we have an idea about the various features offered by Calliope. It is about time we get to know about integrating LambdaTest with Calliope. However, to those of us who are not aware of LambdaTest.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is LambdaTest?
&lt;/h2&gt;

&lt;p&gt;We offer a cloud-based &lt;a href="https://www.lambdatest.com/"&gt;cross browser testing&lt;/a&gt; platform to help you perform browser compatibility testing by both manual and &lt;a href="https://www.lambdatest.com/selenium-automation"&gt;automation testing with Selenium&lt;/a&gt;. LambdaTest offers a Selenium Grid of 2000+ real browsers for both mobile and desktop, running on real operating systems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/landing-text-cta"&gt;Perform Cross Browser Testing with LambdaTest on 2000+ Browsers With A Free Sign-up.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should You Integrate LambdaTest With Calliope?
&lt;/h2&gt;

&lt;p&gt;If not well-orchestrated, cross browser testing can turn out to be a mess. You will require a thorough plan and strategy, design a &lt;a href="https://www.lambdatest.com/blog/creating-browser-compatibility-matrix-for-testing-workflow/"&gt;cross browser compatibility matrix&lt;/a&gt; to figure out which browsers are of higher priority and which ones are of the lowest. Depending on the amount of test coverage, and time in-hand, you will need to make a decision to opt for automated cross browser testing. To pace things even faster you would require parallel execution with Selenium, by which you can run multiple test cases simultaneously. And even after following up the right plan, you would need a testing dashboard where you can club all of your test cases in one place, for everyone to have a clear and concise view. This is where LambdaTest integration with Calliope comes into the picture.&lt;/p&gt;

&lt;p&gt;Using LambdaTest integration with Calliope you can analyze the test results of automation test scripts being executed in parallel on more than 2000 browsers + OS combinations. Let’s get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Import LambdaTest Automation Test Results Into Calliope Dashboard
&lt;/h2&gt;

&lt;p&gt;So, now you are aware of LambdaTest and Calliope’s services, let’s have a look at how you can import your LambdaTest automation test results directly to Calliope dashboard. For fetching LambdaTest automation test results details from scratch we need to call LambdaTest API which provides us our recently executed test session details such as name, status, os, browser, version and all generated logs endpoint. We will be making use of the below API:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Get/sessions/{session_id}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will provide us with information specific to our test sessions. This would require you to give the session ID for the test session you want to retrieve the details for. You can refer to &lt;a href="https://www.lambdatest.com/support/docs/api-doc/#/Session/get_sessions__session_id_"&gt;LambdaTest API Documentation&lt;/a&gt; to check the example value or schema.&lt;/p&gt;

&lt;p&gt;Below is the test session details that would be fetched through LambdaTest API and will get imported to Calliope dashboard.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
data:{
name=Calliope-Sample-Test,
duration=24,
platform=win10,
browser=chrome,
browserVersion=74.0,
device=,
statusInd=running,
sessionId=ca7e3b1df8ddc533fc5394141601431f,
buildName=LambdaTest Integration with Calliope,
consoleLogsUrl=https://api.lambdatest.com/automation/api/v1/sessions/ca7e3b1df8ddc533fc5394141601431f/log/console,
networkLogsUrl=https://api.lambdatest.com/automation/api/v1/sessions/ca7e3b1df8ddc533fc5394141601431f/log/network,
commandLogsUrl=https://api.lambdatest.com/automation/api/v1/sessions/ca7e3b1df8ddc533fc5394141601431f/log/command,
seleniumLogsUrl=https://api.lambdatest.com/automation/api/v1/sessions/ca7e3b1df8ddc533fc5394141601431f/log/selenium,
videoUrl=https://automation.lambdatest.com/public/video?testID=3K6C3-HBAMX-BUS4B-FWY5Z,
screenshotUrl=https://d15x9hjibri3lt.cloudfront.net/3K6C3-HBAMX-BUS4B-FWY5Z/screenshots.zip
}, 
message:Retrieve session was successful, 
status:success
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You might be wondering how you can send the above test session details directly to Calliope dashboard after retrieving from LambdaTest API. So, here is the Java-TestNG code for you that can help you setting up the test environment which further includes your username, accesskey, gridURL and test configurations such as browser, browser version, OS etc.&lt;/p&gt;

&lt;p&gt;Once you have set the test environment, you can now write your test cases. We have been using SessionId Java class that provides the session ID for running session, we can use the same session ID for calling LambdaTest GET Session API whose URL is:&lt;br&gt;&lt;br&gt;
&lt;code&gt;https://api.lambdatest.com/automation/api/v1/sessions/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For accessing the LambdaTest API, you need to get authorized with your credentials that include your username and access key. We have used Base64 class to encode the credentials which are universally accepted format by web servers and browsers.&lt;br&gt;&lt;br&gt;
Now, we can use our encoded basic authorization with session URL to send the GET request for the test session details.&lt;/p&gt;

&lt;p&gt;Since, we are using Java-TestNG here, all our test results and logs get saved in testng-results.xml file. The purpose of this file is to capture the test session data and can further be used with Calliope API in order to transfer the saved test session data to Calliope Dashboard. In the below code, we have also used Reporter.log which would report the test logs and all other session details to the testng-results.xml file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/LambdaTest/LambdaTest-Calliope-Integration"&gt;Check out our GitHub repository for accessing the entire code represented in this article to integrate LambdaTest with Calliope.&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BaseTest.java


package calliopeIntegration;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Base64;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.SessionId;
import org.testng.Reporter;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import calliopeIntegration.session.SessionResponse;


@Listeners({IntegrationExecution.class})
public class BaseTest {

    public String username = "Your_Username";    //LambdaTest Username
    public String accesskey = "Your_AccessKey;   //LambdaTest AccessKey
    public static RemoteWebDriver driver = null;
    public String gridURL = "@hub.lambdatest.com/wd/hub";   //GridURL
    boolean status = false;


    @BeforeMethod
     public void setUp() {
        DesiredCapabilities capabilities = new DesiredCapabilities();   // Setting configurations
        capabilities.setCapability("browserName", "chrome");
        capabilities.setCapability("version", "74.0");
        capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one
        capabilities.setCapability("build", "LambdaTest Integration with Calliope");
        capabilities.setCapability("name", "Calliope-Sample-Test");
        capabilities.setCapability("network", true); // To enable network logs
        capabilities.setCapability("visual", true); // To enable step by step screenshot
        capabilities.setCapability("video", true); // To enable video recording
        capabilities.setCapability("console", true); // To capture console logs
        try {
            driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
        } catch (MalformedURLException e) {
            System.out.println("Invalid grid URL");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        Reporter.log("Build and Session Information retrieved from LambdaTest API's",true);
     }

             // Test cases
    @Test
    public void BuildSession() throws Exception {

        try {

            driver.get("https://www.apple.com/");
            driver.manage().window().maximize();
            Thread.sleep(5000);

            driver.findElement(By.xpath("//*[@id=\'ac-globalnav\']/div/ul[2]/li[3]")).click();
            Thread.sleep(2000);

            driver.findElement(
            By.cssSelector("#chapternav &amp;gt; div &amp;gt; ul &amp;gt; li.chapternav-item.chapternav-item-ipad-air &amp;gt; a")).click();
            Thread.sleep(2000);

            driver.findElement(By.linkText("Why iPad")).click();
            Thread.sleep(2000);



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




    @AfterMethod
     public void teardown() throws Exception {

        SessionId session = driver.getSessionId();
        String sessionId = session.toString();

         if (driver != null) {
                ((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
               driver.quit();
            }


        String usernameColonPassword = username+":"+accesskey  ;    // API Authorization
        String basicAuthPayload = "Basic " + Base64.getEncoder().encodeToString(usernameColonPassword.getBytes());
        Reporter.log(basicAuthPayload);



        //Session Info
        String sessionURL = "https://api.lambdatest.com/automation/api/v1/sessions/"+sessionId;
        Reporter.log(sessionURL,true);  
        String jsonResponse2 = sendGetRequest(sessionURL,basicAuthPayload);
        ObjectMapper objectMapper2 = new ObjectMapper();
        objectMapper2.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        SessionResponse response2 = objectMapper2.readValue(jsonResponse2, SessionResponse.class);
        Reporter.log(response2.toString(),true);    

    }





    public static String sendGetRequest(String url, String basicAuthPayload) throws Exception {
        HttpClient client = HttpClientBuilder.create().build();
        HttpGet request = new HttpGet(url);

        // add GET request header
        request.addHeader("Content-Type", "application/json");
        request.addHeader("Authorization", basicAuthPayload);
        HttpResponse response = client.execute(request);

        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

        StringBuffer result = new StringBuffer();
        String line = "";
        while ((line = rd.readLine()) != null)
        {
            result.append(line);
        }
        return result.toString();   
     }



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



&lt;p&gt;Now, after executing the above code, we have our test executed on LambdaTest Selenium Grid along with the test testng-results.xml file saved in our system which includes all our recent test session details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Uxzjf8ta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/pasted-image-0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Uxzjf8ta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/pasted-image-0.png" alt="LambdaTest Automation Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next step is to call Calliope API to post the test data from testng-results.xml file to Calliope dashboard. Calliope support different result file format according to different frameworks. For instance, XML for Junit and TestNG, JSON for Cucumber. For more information on this, you can refer to &lt;a href="https://docs.calliope.pro/supported-formats/other-formats/"&gt;Calliope’s documentation link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We have used MediaType class to define the file type(XML) for our TestNG framework. Now, we need a testng-results.xml file to GET and POST test session data. So, we need to define the directory where this file is saved to access the file by calling the Calliope API.&lt;br&gt;&lt;br&gt;
We have defined API command as an endpoint URL which includes your profile number along with OS, platform and build name. You can extract your Calliope API from their &lt;a href="https://docs.calliope.pro/import/api-import/"&gt;documentation for API import&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Make sure you have entered the correct API Key, otherwise, your test would fail due to unmatch of API Key with your profile number.&lt;/p&gt;

&lt;p&gt;After setting up the endpoint URL and the API Key, it’s time to call Calliope API now by sending a POST request for importing test results to the dashboard.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CalliopeAPI.java

package calliopeIntegration;


import java.io.File;
import java.io.IOException;

import org.testng.annotations.Test;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class CalliopeAPI 
{
    @Test 
    public void calliopeAPIcall()
    {    
        final MediaType MEDIA_TYPE_XML = MediaType.parse("application/xml");    // for xml files    
        final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json");  // for json files


        MultipartBody requestBody = null;
        try {
            String report_filename = "C:\\Users\\Lenovo-I7\\git\\Calliope-Integration-with-LambdaTest\\CalliopeSample\\test-output\\testng-results.xml";     // Result File Address

            requestBody = new MultipartBody.Builder()
                    .setType(MultipartBody.FORM)
                    .addFormDataPart("file", report_filename, RequestBody.create(MEDIA_TYPE_XML, new File(report_filename)))
                    .build();
        } catch (Exception e1) {

            e1.printStackTrace();
        }  

        OkHttpClient client = new OkHttpClient();
        String endpoint_url = "https://app.calliope.pro/api/v2/profile/577/report/import?os=myos&amp;amp;platform=myplatform&amp;amp;build=mybuild";   // Calliope API
        final String API_KEY = "ZDk4ZGVhM2VlMzRlYjlkZGI0Y2MxZTA4Yjg1OTYxNjUyMzQzMGZhZmE0NTY0MTk4Y2MyMmM0NGQ3OTlmNTk2N2Jm";  //Calliope AccessKey
        Request request = new Request.Builder().url(endpoint_url).post(requestBody).addHeader("x-api-key", API_KEY).build();   // POST request

        Response response = null;
        try {
            response = client.newCall(request).execute();
            System.out.println("=============");
            System.out.println(response);
            String response_body = response.body().string();
            System.out.println(response_body);
            System.out.println("=============");

            if (response.isSuccessful()){

                 System.out.println("created");
            } else {
                throw new IOException("Unexpected HTTP code " + response);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }


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



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BAFt6oOs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/Console-Output.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BAFt6oOs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/Console-Output.png" alt="Console Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make sure that CalliopeAPI.java file is getting executed after BaseTest.java file finishes its execution, we have used TestNG Listeners for this. Just for the recap, the BaseTest.java file includes the test configurations, test cases and the procedure for calling the LambdaTest GET session API. So, unless the execution of BaseTest.java doesn’t end up we cannot call CalliopeAPI.java, this is the reason that we have used IExecutionListener which provides two methods and onExecutionFinish().&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Method onExecutionStart() gets invoked before TestNG run starts. &lt;/li&gt;
&lt;li&gt;Method onExecutionFinish() gets invoked when all the suites have been run.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IntegrationExecution.java


package calliopeIntegration;

import org.testng.IExecutionListener;

public class IntegrationExecution  implements IExecutionListener {

    public void onExecutionStart() {

        System.out.println("Fetching LambdaTest Automation Test Data and Sending to Calliope Dashboard");

    }

    public void onExecutionFinish() {

        CalliopeAPI object = new CalliopeAPI();
        object.calliopeAPIcall();  // Calling Calliope API after test execution on LambdaTest

    }

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



&lt;p&gt;Since we are retrieving data from LambdaTest API whose schema is in JSON format, so we need to set up and organize the test session retrieving data using JsonPropertyOrder.&lt;/p&gt;

&lt;p&gt;Below is the code which would show you the hierarchy or list in which the test session data would get organized.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SessionData.java


package calliopeIntegration.session;


import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "name",
    "duration",
    "platform",
    "browser",
    "browser_version",
    "device",
    "status_ind",
    "session_id",
    "build_name",
    "console_logs_url",
    "network_logs_url",
    "command_logs_url",
    "selenium_logs_url",
    "video_url",
    "screenshot_url"
})
public class SessionData {

    @JsonProperty("name")
    private String name;
    @JsonProperty("duration")
    private Integer duration;
    @JsonProperty("platform")
    private String platform;
    @JsonProperty("browser")
    private String browser;
    @JsonProperty("browser_version")
    private String browserVersion;
    @JsonProperty("device")
    private String device;
    @JsonProperty("status_ind")
    private String statusInd;
    @JsonProperty("session_id")
    private String sessionId;
    @JsonProperty("build_name")
    private String buildName;
    @JsonProperty("console_logs_url")
    private String consoleLogsUrl;
    @JsonProperty("network_logs_url")
    private String networkLogsUrl;
    @JsonProperty("command_logs_url")
    private String commandLogsUrl;
    @JsonProperty("selenium_logs_url")
    private String seleniumLogsUrl;
    @JsonProperty("video_url")
    private String videoUrl;
    @JsonProperty("screenshot_url")
    private String screenshotUrl;

    @JsonProperty("name")
    public String getName() {
        return name;
    }

    @JsonProperty("name")
    public void setName(String name) {
        this.name = name;
    }

    @JsonProperty("duration")
    public Integer getDuration() {
        return duration;
    }

    @JsonProperty("duration")
    public void setDuration(Integer duration) {
        this.duration = duration;
    }

    @JsonProperty("platform")
    public String getPlatform() {
        return platform;
    }

    @JsonProperty("platform")
    public void setPlatform(String platform) {
        this.platform = platform;
    }

    @JsonProperty("browser")
    public String getBrowser() {
        return browser;
    }

    @JsonProperty("browser")
    public void setBrowser(String browser) {
        this.browser = browser;
    }

    @JsonProperty("browser_version")
    public String getBrowserVersion() {
        return browserVersion;
    }

    @JsonProperty("browser_version")
    public void setBrowserVersion(String browserVersion) {
        this.browserVersion = browserVersion;
    }

    @JsonProperty("device")
    public String getDevice() {
        return device;
    }

    @JsonProperty("device")
    public void setDevice(String device) {
        this.device = device;
    }

    @JsonProperty("status_ind")
    public String getStatusInd() {
        return statusInd;
    }

    @JsonProperty("status_ind")
    public void setStatusInd(String statusInd) {
        this.statusInd = statusInd;
    }

    @JsonProperty("session_id")
    public String getSessionId() {
        return sessionId;
    }

    @JsonProperty("session_id")
    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    @JsonProperty("build_name")
    public String getBuildName() {
        return buildName;
    }

    @JsonProperty("build_name")
    public void setBuildName(String buildName) {
        this.buildName = buildName;
    }

    @JsonProperty("console_logs_url")
    public String getConsoleLogsUrl() {
        return consoleLogsUrl;
    }

    @JsonProperty("console_logs_url")
    public void setConsoleLogsUrl(String consoleLogsUrl) {
        this.consoleLogsUrl = consoleLogsUrl;
    }

    @JsonProperty("network_logs_url")
    public String getNetworkLogsUrl() {
        return networkLogsUrl;
    }

    @JsonProperty("network_logs_url")
    public void setNetworkLogsUrl(String networkLogsUrl) {
        this.networkLogsUrl = networkLogsUrl;
    }

    @JsonProperty("command_logs_url")
    public String getCommandLogsUrl() {
        return commandLogsUrl;
    }

    @JsonProperty("command_logs_url")
    public void setCommandLogsUrl(String commandLogsUrl) {
        this.commandLogsUrl = commandLogsUrl;
    }

    @JsonProperty("selenium_logs_url")
    public String getSeleniumLogsUrl() {
        return seleniumLogsUrl;
    }

    @JsonProperty("selenium_logs_url")
    public void setSeleniumLogsUrl(String seleniumLogsUrl) {
        this.seleniumLogsUrl = seleniumLogsUrl;
    }

    @JsonProperty("video_url")
    public String getVideoUrl() {
        return videoUrl;
    }

    @JsonProperty("video_url")
    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    @JsonProperty("screenshot_url")
    public String getScreenshotUrl() {
        return screenshotUrl;
    }

    @JsonProperty("screenshot_url")
    public void setScreenshotUrl(String screenshotUrl) {
        this.screenshotUrl = screenshotUrl;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("{\nname=");
        builder.append(name);
        builder.append(",\nduration=");
        builder.append(duration);
        builder.append(",\nplatform=");
        builder.append(platform);
        builder.append(",\nbrowser=");
        builder.append(browser);
        builder.append(",\nbrowserVersion=");
        builder.append(browserVersion);
        builder.append(",\ndevice=");
        builder.append(device);
        builder.append(",\nstatusInd=");
        builder.append(statusInd);
        builder.append(",\nsessionId=");
        builder.append(sessionId);
        builder.append(",\nbuildName=");
        builder.append(buildName);
        builder.append(",\nconsoleLogsUrl=");
        builder.append(consoleLogsUrl);
        builder.append(",\nnetworkLogsUrl=");
        builder.append(networkLogsUrl);
        builder.append(",\ncommandLogsUrl=");
        builder.append(commandLogsUrl);
        builder.append(",\nseleniumLogsUrl=");
        builder.append(seleniumLogsUrl);
        builder.append(",\nvideoUrl=");
        builder.append(videoUrl);
        builder.append(",\nscreenshotUrl=");
        builder.append(screenshotUrl);
        builder.append("\n}");
        return builder.toString();
    }

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



&lt;p&gt;In &lt;strong&gt;SessionData.java&lt;/strong&gt; only session data variables are declared, though they are defined in a hierarchical manner but they do not contain any values yet. We have now created a new class SessionResponse.java that would set values to the previously defined session data variables.SessionResponse.java class has been called by &lt;strong&gt;BaseTest.java&lt;/strong&gt; class for setting the values for session data variables after retrieving from LambdaTest GET session API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SessionResponse.java


package calliopeIntegration.session;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class SessionResponse {

    @JsonProperty("data")
    private SessionData sessionData;
    @JsonProperty("message")
    private String message;
    @JsonProperty("status")
    private String status;

    @JsonProperty("data")
    public SessionData getData() {
        return sessionData;
    }

    @JsonProperty("data")
    public void setData(SessionData sessionData) {
        this.sessionData = sessionData;
    }

    @JsonProperty("message")
    public String getMessage() {
        return message;
    }

    @JsonProperty("message")
    public void setMessage(String message) {
        this.message = message;
    }

    @JsonProperty("status")
    public String getStatus() {
        return status;
    }

    @JsonProperty("status")
    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("{\ndata:");
        builder.append(sessionData);
        builder.append(", \nmessage:");
        builder.append(message);
        builder.append(", \nstatus:");
        builder.append(status);
        builder.append("\n}");
        return builder.toString();
    }

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



&lt;p&gt;Now, if you look at the Calliope dashboard you will be able to notice a screenshot below, representing the executions of your automation test script at LambdaTest Selenium Grid for &lt;a href="https://www.lambdatest.com/"&gt;automated cross browser testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nA_s5mJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/Calliope-Dashboard.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nA_s5mJI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.lambdatest.com/blog/wp-content/uploads/2019/09/Calliope-Dashboard.png" alt="Calliope Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Was That?
&lt;/h2&gt;

&lt;p&gt;Kudos! You have successfully imported your automation test results of the Selenium Grid offered by LambdaTest on your Calliope dashboard. Now, you can effortlessly collaborate your teammates while &lt;a href="https://www.lambdatest.com/blog/performing-cross-browser-testing-with-lambdatest/"&gt;performing cross browser testing with LambdaTest&lt;/a&gt;. Let me know your thoughts on this integration and how it helped to fast track your test cycles. Stay tuned for more articles by hitting the notification bell at the bottom. Cheers and happy testing! 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0j-luKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>testing</category>
      <category>csharp</category>
    </item>
    <item>
      <title>22 Reasons Why Test Automation Fails For Your Web Application
</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Mon, 21 Oct 2019 13:06:39 +0000</pubDate>
      <link>https://forem.com/ramitd1995/22-reasons-why-test-automation-fails-for-your-web-application-ik3</link>
      <guid>https://forem.com/ramitd1995/22-reasons-why-test-automation-fails-for-your-web-application-ik3</guid>
      <description>&lt;p&gt;I can relate to the feeling where you wish to achieve flawless automation testing in the blink of an eye! On the other hand, I also understand the apprehension that is causing you to delay test automation. When an enterprise has just begun the transformation, there are a plethora of challenges to overcome. Even if you apply the best practices, some shortcomings can result in wastage of automation efforts. So, I’ve decided to list out 22 reasons that in my experience, are responsible for automation testing failure.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Impractical Expectations – A 100% Automation
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
The very first test automation failure reaps from impractical expectations. I have observed it many times in my career, once you get an automation QA or staff on-board then the management expects them to automate testing for everything. As pleasing as it may sound, it is not possible. You can’t go for a 100% automation testing as there are going to be few areas where human inspection would be mandatory. One of these areas could be around the accessibility of your web application or more.&lt;br&gt;
​&lt;br&gt;
For instance, if you are performing &lt;a href="https://www.lambdatest.com/selenium-automation"&gt;automated cross browser testing&lt;/a&gt; then the automation script for &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;Selenium testing&lt;/a&gt; will render the display of your web pages across different browsers or operating systems. However, to decide if the website is rendering as per design, if the typography is well, if the text is appropriate is best evaluated manually.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What To Automate &amp;amp; How Much To Automate?
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Many organizations do realize the problem statement of expecting a 100% automation testing but often struggle with the following question. &lt;strong&gt;What can we automate &amp;amp; if not 100%, then how much automation can we achieve realistically for our web product?&lt;/strong&gt;&lt;br&gt;
​&lt;br&gt;
There is no perfect percentage or approximate figure for automation testing coverage that is applicable to every business. It all depends upon the web application that you are offering, and since different businesses are catering to different needs. It is only natural to expect a unique expectation around how much percentage of automation testing can one realistically go for? The scope of automation testing will differ from an e-commerce web-applications to static, dynamic, or animated web applications. So, if you are wondering why automation testing fails for your organization? Then I would recommend you to evaluate the amount of automation testing required based on the type of web-application you are offering.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Improper Management Leading To Lack Of Visibility For Test Automation
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
I have been a victim of improper management back when I started my IT career as an automation tester. I was working for a Service-based company and they allocated me my first project. This project had been running for a couple years then and I was handed over a list of test automation scripts, right after I joined. The higher-ups of the project were about to leave the organization and the management was too busy with the upcoming sprints to consider a thorough knowledge transition sessions from the senior automation testers who were about to leave. What happened after they left wasn’t a pretty sight? We were slammed with outages, and me being a fresher with minimum knowledge of how the various outbound and inbound processes were being impacted by numerous automation scripts, was at the hearing end from my manager. However, when I look back to that scenario I realize that it wasn’t entirely my fault.&lt;br&gt;&lt;br&gt;
I have seen teams with a handful of members in charge of implementing automation while the others are clueless about what’s going on.&lt;br&gt;
​&lt;br&gt;
Don’t you think it’s a bit unrealistic to expect magic out of automation testing when half the team lacks visibility? Since automation has to be a collaborative effort, it is important to educate every team member about the related tools and processes, especially the freshers. You can accomplish this by holding team meetings and sessions to discuss tools, trends, and practices related to automation.&lt;br&gt;
​&lt;br&gt;
&lt;a href="https://www.lambdatest.com/webinar/web-ui-testing-with-python-and-lambdatest#bookyourseats?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zsIhMA_x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/10/Banner-2.jpg" alt="**Web UI Testing with Python and LambdaTest**"&gt;&lt;/a&gt;&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  4. No Understanding Of Manual Testing Or Exploratory Testing
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
This may surprise you a little, another reason why test automation fails for you could be the lack of manual testing skills, or &lt;a href="https://www.lambdatest.com/blog/9-must-have-skills-to-master-exploratory-testing/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;exploratory testing skills&lt;/a&gt;. Automating your test scripts doesn’t mean that team members can cut themselves some slack. As we know by far, that an automated approach doesn’t cover everything and that is where the challenge begins. Because now you have to dig deeper into your web-application and find critical test scenarios that were not yet revealed by your teammates.&lt;br&gt;
​&lt;br&gt;
Automation is a way to save testing efforts. Software companies should use it to minimize repetitions and automate only those elements that are less prone to changes. Once that is done, the company should allocate their resources to perform extensive manual testing or exploratory testing to find unique test cases.&lt;br&gt;
​&lt;br&gt;
&lt;a href="https://www.lambdatest.com/blog/exploratory-testing-all-about-discovery/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;strong&gt;Read More: Exploratory Testing: It’s All About Discovery&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Not Thinking Through And Scripting The Scenario
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Automation seems like a one-stop destination for minimizing efforts. But a well-thought-out scenario is a must, before developing a test automation scripts. Moreover, it can take a substantial amount of execution time of your automation tests. The flexibility of frameworks and test automation tools plays a crucial role in how much time it takes to develop a scripted scenario.&lt;br&gt;
​&lt;br&gt;
Since every scenario is different, scripting is a must. Even if you think it through, it’s all a waste without scripting the scenario. Ensure that the coding skills of your test engineer are at par with the complexity of the tests. Complex tests take a lot of time to automate. Therefore, with the development of brand new features, they often don’t get a chance to discover regression bugs. Make sure you keep these things in mind before you write down your test scenario.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Lack Of Understanding About When To Use Automation And When Not To!
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
The most common reason behind “ &lt;strong&gt;why test automation fails for your company?&lt;/strong&gt; ” is that the people are not aware of when to automate and when not to. For instance, it’s alright to automate different webpage functionalities. But it’s not a good idea to evaluate the padding, images, etc. rendering issues through test automation. If you are using coordinates to determine element locations, it can lead to discrepancies when run on varying screen resolutions and sizes.&lt;br&gt;
​&lt;br&gt;
It’s not viable to use automation when you are testing something prone to a lot of changes. If you are testing out a stable entity, automation is the way to go. Basically, mundane tasks that require a certain action to be repeated are best suited for automated testing. So test automation can comfort your regression testing process.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Improper Selection Of Staff And Resource Planning
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
I have seen a false belief rampant in the IT industry. People think that any developer or tester can carry out test automation. Design, configuration, and implementation of test automation calls for a specific skill set. A tester carrying out automation should know how to articulate ideas between managers, developers, and customers. He/she should also have a clear understanding of development trends and should know what the development team is headed to.&lt;br&gt;
​&lt;br&gt;
Automation test engineers are some of the most difficult, yet, significant hires. To kickstart various automation projects, it is essential to hire testers with extensive technical knowledge. Instead of one or a few people carrying out automation testing, the entire team should be aware of what’s going on. Even though the investment in hiring technically sound staff is high, the return is worthwhile.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Not Paying Enough Attention To Test Reports
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Since automation testing is a relatively new phenomenon, chances of failure are high. There are so many new experiments the testing team conducts that it becomes important to analyze the results accurately. After carrying out the tests, the tester has to make a thorough test report. But here is why test automation fails for you! Your team is not paying enough attention to test report analysis. If not carried out properly, the analysis can leave faults unattended and cause wastage of time, resources and efforts.&lt;br&gt;
​&lt;br&gt;
Some tests succeed and some fail in automated testing. Therefore, it is mandatory to examine test reports for faults and analyze the reason behind the failure of certain tests. It is better to conduct the analysis manually so as to uncover genuine failures. It is vital to unmask hidden problems and make sure that they don’t get overlooked due to masking by other issues.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Bottom-Up Approach In Defining Your Automation Goals
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Setting too good to be true objectives for automation seems perfect on paper. But when it comes to executing the steps, there is a severe lack of clarity among team members. The biggest problem is that the goals are vague. They lack precision and accuracy for obtaining real value from automation. What most firms do is that they start automating something very complex and end up refactoring the whole framework. As a result, the team ends up losing a lot of time, money, and effort.&lt;br&gt;
​&lt;br&gt;
You can eliminate uncertainties by starting small and working your way up to complexities. Pick out stable functionalities and begin with their automation initially. After that, gather feedback to determine what’s wrong. Once you achieve consistency in their testing, continue with other functionalities. Have a customized approach for test automation since needs can vary for different project contexts.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Selection Of The Right Tool For Efficient And Effective Testing
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
With a plethora of automation tools out there, sometimes it becomes challenging to choose the best. Improvement of the overall testing procedure and meeting real requirements is the end goal. But most teams fail to shift through the chaff and pick out the tools that best suit their testing needs. Automation testing is, without a doubt, highly dependent on the tool you decide to go ahead with. Every tool has specific capabilities. But teams lack the level of expertise needed to get the best out of these capabilities.&lt;br&gt;
​&lt;br&gt;
Moreover, firms get caught up in the hype of a particular tool. But after opting for it, they realize that it doesn’t provide everything that they were hoping to get. Plus, every team has a budget and sometimes the cost of the tool exceeds that. Before jumping on to choosing a hyped tool, carefully line out the requirements. After that, decide what you are expecting from the tool. Be very specific in setting goals and check the correspondence with user acceptance criteria for products. You can also consult experts who are experienced with the use of these tools.&lt;br&gt;
​&lt;br&gt;
Talking about automation testing tools, if you are looking to perform automated cross browser testing on cloud then LambdaTest offers you a &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;cloud-based Selenium Grid&lt;/a&gt; with 2000+ real browsers and operating systems, along with integrations to multiple third-party CI/CD tools.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Ignoring False Negatives &amp;amp; False Positives
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
This is something which is often observed in almost every organization. Once the automation test suites are ready and they seem to work fine, the management starts to relax. They start slacking off on in-depth analysis of test execution as they believe that only pass-fail checking will do enough. But this is why test automation fails for them!&lt;br&gt;
​&lt;br&gt;
Sometimes, a system works fine fundamentally. However, automation scripts don’t reflect the same. They state otherwise and cause a false positive scenario. Thus, it creates a situation of confusion and wastes time, effort, and resources. I have seen how frustrating it is for the testing team trying to find something that isn’t there!&lt;br&gt;
​&lt;br&gt;
Another scenario is that when the automation script gives the green signal and there is something wrong. The system isn’t working as it should but the script declares otherwise. Network issues can cause discrepancies in the test environment settings. This occurs due to a lack of accuracy in the beginning stages of a database. Leaving a system in a compromised state can cause catastrophic consequences in the long term.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Web Elements With Undefined IDs
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
It is mandatory for every web element to have an ID to execute efficient testing. But sometimes, the developers fail to allot IDs to all web elements and this is why test automation fails. In this case, the automated script has to find these web elements which takes up a lot of time. Moreover, if the script is unable to find these elements within a prescribed time frame, the test fails. Thus, to ensure proper synchronization of the script, the team has to allot unique IDs to all web elements.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Not Leveraging Parallel Execution
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
So, you ended up automating everything you wanted to automate. You end up with humongous test suites, and only now, you start hitting the wall. These complex test suites take up longer time for execution than you anticipated. Which starts to compromise with the quality of the test queue in your respective IDE, test automation framework. As a result, the test cases are halted abruptly due to Queue timeout issues, all because you are executing them sequentially. Sequential execution of test cases is another reason why test automation fails for your web application.&lt;br&gt;
​&lt;br&gt;
Unlike the sequential running of tests, parallel execution enables the execution of multiple tests in different environments at the same time. But automated testing can cause unintended code interactions. It makes it challenging to debug the cause of the failure so you need thorough reporting mechanism, offering detailed insights regarding your test execution.&lt;br&gt;
​&lt;br&gt;
&lt;a href="https://www.lambdatest.com/landing-text-cta?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;strong&gt;LambdaTest provides a Selenium Grid which allows you to perform Parallel Testing with Selenium.&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  14. False Estimations Of ROI Through Test Automation
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Irrespective of what business you run online, ROI is going to be the agenda for every board meeting. The stockholders demand for greater returns. And no matter how much time and effort you put into preparing your test automation suites, if the ROI generated from them is not as per expectations then their importance would be weighed a lot less than you expect.&lt;br&gt;
​&lt;br&gt;
There are many metrics that one may consider while calculating ROI on test automation such as test maintenance, cost involved in buying necessary test automation tools, resources on-board, and more. Planning impractical ROI can be problematic for many organizations and may be the reason why test automation fails.&lt;br&gt;
​&lt;br&gt;
&lt;a href="https://www.lambdatest.com/blog/how-do-you-calculate-your-roi-on-test-automation-with-selenium/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;strong&gt;How Do You Calculate Your ROI On Test Automation With Selenium?&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  15. Failing To Evaluate The Ripple Effect
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Many organizations are under the impression that automation testing is easy. All you need to do is just write a few lines of code to automate your web-application’s testing workflows. And that is it! You should not bother wondering about the planning and input of your test automation scripts at all. But that is not it!&lt;br&gt;
​&lt;br&gt;
You need to evaluate the ripple effect. Your web-application is going to be a mixture of numerous test automation scripts meant to test different modules and processes. If one test scripts fail to execute properly, it could trigger test automation to fail for other scripts too. That is not all, ripple effect should also be calculated while resource planning.&lt;br&gt;
​&lt;br&gt;
Say you are having a Senior resource who wrote a script way back and has now left your company. You may not have thought of the ripple effect that the resignation may have in future timelines of your automation projects. Which is why you need to document every detail about every automation test script in your system. The documentation should serve as a standard for budding automation testers as well as experienced automation testers.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  16. Test Suites Are Not Static thing
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Another reason why test automation fails for your organization could be the unadaptable test suites. Many automation testers create static test suites, which are not so flexible as you scale your business. They end up re-writing the entire automation testing scripts all over, every time your platform evolves. It is a bad practice, because you are wasting time, resource bandwidth, and money. Plus, it is a faulty process. Make sure that you write test suites that evolve and adapt as your platform scales.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  17. Automating One Process And Hopping To Another Without Looking Back
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Another way to avoid test automation failure is to improvise your test suites. Now, that may sound obvious but it is not practised in numerous organization. Reason being, once they design the test suite, and find it to be working as it should then they start working on automating new areas. I am not criticizing the effort of indulging or exploring new areas to automate. However, it wouldn’t hurt to manage a time window where you and your team look back into an existing piece of code for figuring out a way to optimize it even further. Always experiment with your test suites to make things better.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  18. Failure To Collaborate
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
With worldwide adoption of modern SDLCs(Software Development Life Cycles) methodologies such as Agile, Kanban, etc. Collaboration has become a key component in faster deployment of web application into the market.&lt;br&gt;
​&lt;br&gt;
It’s a multi-dimensional software development process, where all the teams are working simultaneously to develop a web application. You have a team of developers designing front-end, another responsible for backend, a team responsible for middleware activities. As a tester, you need to understand which team is responsible for which module. You have to stay up-to-date with product enhancements committed by different teams and make relevant changes to your automation script, to ensure your test automation doesn’t fail.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  19. Manually Setting Up The Test Environment Before Executing Every Test Automation Suite
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
The primary purpose of automation testing is to minimize the stress involved in repetitive manual testing, in order to save time. On an abstract level, it sounds good but for those who perform test automation, realize the struggle in configuring the right infrastructure for performing in-house test automation. I have often observed testers refreshing the entire test automation suite before executing a new script to avoid any ambiguity with scripts. But that fails the entire point of automation testing, doesn’t it?&lt;br&gt;
​&lt;br&gt;
For instance, if you are performing automated cross browser testing with an in-house Selenium Grid to test your website of macOS and windows operating systems for Google Chrome and Safari browsers. Now, you may have to face the hassle of setting up a new OS every time before you run your Selenium scripts. In such cases it is better to opt for a cloud-based cross &lt;a href="https://www.lambdatest.com/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;browser compatibility testing tool&lt;/a&gt; such as LambdaTest, which offers you instant access to more than 2000 combinations of browsers + OS.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  20. Running Multiple Test Suites On A Static Test Environment Repeatedly Without Cleaning
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
This is a very common reason why test automation fails for your organization. Especially, when deadlines are near. Your test department continues to run numerous test suites over the same test environment, without clearing the cache of the previously executed test automation scripts. That may lead to faulty test evaluation, your test reports may get compromised as you encounter more false negatives and false positives.&lt;br&gt;
​&lt;br&gt;
For instance, say you need to test your web-applications for different geographies. While performing geo location from a static test environment. There is a possibility that your script may encounter a test from Google asking you to prove that you are not a bot. This would lead to failure of test automation script.&lt;br&gt;
​&lt;br&gt;
Which is why LambdaTest offers you a fresh virtual machine with cleared cached so you get accurate results for your automated &lt;a href="https://www.lambdatest.com/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;cross browser testing&lt;/a&gt; scripts.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  21. The Test Environment Itself Is Buggy
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
To make automation work across different test environments, there is a great deal of planning involved. You need to test on staging environments to ensure the code works flawlessly when moved into the production pipeline. However, it happens many times that your test automation script for code change, when tested in Stage environment, works seamlessly but when moved to Production, it falls apart. There could be many reasons behind such issues such as lack of constant monitoring, Staging environment failing to twin the Production environment, absence of live traffic and more.&lt;br&gt;
​&lt;br&gt;
&lt;a href="https://www.lambdatest.com/blog/13-reasons-why-staging-environment-is-failing-for-your-organization/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;strong&gt;Read More: 13 Reasons Why Staging Environment Is Failing For Your Organization&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  22. There Are Errors In The Test Code Itself
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
Last but not least. If all the points we have covered so far and your test automation is still failing then the only place left for you to reflect back is going to be your own test automation scripts. Make sure you are not committing any compile time, and runtime errors for any test script involved in your entire project.&lt;br&gt;
​&lt;/p&gt;

&lt;h2&gt;
  
  
  Summing It Up
&lt;/h2&gt;

&lt;p&gt;​&lt;br&gt;
If you need a productivity booster for your organization, automation testing is the way to go. It is one of the most efficient processes required to increase the quality of the end product. Test automation also increases the robustness of the software. But be cautious of hasty implementation and procrastination. You can’t rush it without knowing the roadblocks as no company can afford to lose massive funds. On the other hand, too much fear can prevent you from reaping the striking benefits automation testing has to offer.&lt;br&gt;
​&lt;br&gt;
Remember, the reasons I’ve mentioned above are not the only ones that can lead to test automation failures. You are likely to encounter new obstacles as you make progress. But to avoid catastrophic failure, stay aware of the complications and keep an eye on the solutions. Happy testing! 🙂&lt;br&gt;
​&lt;br&gt;
&lt;strong&gt;Originally Published:&lt;/strong&gt; &lt;a href="https://www.lambdatest.com/blog/22-reasons-why-test-automation-fails-for-your-web-application/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;strong&gt;LambdaTest&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
​&lt;br&gt;
&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-21102019&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0j-luKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>webdev</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Selenium Automation Testing with Disabled JavaScript Settings; Is It Worth Your Time?</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Thu, 12 Sep 2019 12:27:02 +0000</pubDate>
      <link>https://forem.com/ramitd1995/selenium-automation-testing-with-disabled-javascript-settings-is-it-worth-your-time-3l8p</link>
      <guid>https://forem.com/ramitd1995/selenium-automation-testing-with-disabled-javascript-settings-is-it-worth-your-time-3l8p</guid>
      <description>&lt;p&gt;Selenium has been a pinnacle for open-source software in the industry of automated website testing. The automation testing framework is widely adopted by the testing community to help them in automating interactions with their web-application for desktops.&lt;/p&gt;

&lt;p&gt;I have been an automation tester from couple years now, and have been fondly towards Selenium ever since I knew what it’s capable of. Recently, I was pondering about a few questions though! What would happen if I disable JavaScript and then perform &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-12092019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;automation testing with Selenium&lt;/a&gt;? How would a website react then? Is it even possible? Is it even required?&lt;/p&gt;

&lt;p&gt;The only way to know the answers to these questions was to have them tested myself. And I came up with interesting results. Which is why I am writing this article to share these results with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things That Can Be Done With JavaScript &amp;amp; Things That Can’t Be!
&lt;/h2&gt;

&lt;p&gt;I am sure you must be intrigued to know if there is a need for testing a web application after disabling the JavaScript? However, before I answer that question we need to understand what you can do as a tester with JavaScript &amp;amp; what you cannot!&lt;/p&gt;

&lt;h3&gt;
  
  
  Things You Can Do With JavaScript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Access and modify all the content visible on the web page such as text, images, videos or any other kind of private data.&lt;/li&gt;
&lt;li&gt;Access the cookies sent by the web server.&lt;/li&gt;
&lt;li&gt;Make request to other servers for data capturing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Things You Can’t Do With JavaScript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Accessing files stored in your local system other than those uploaded on a web page.&lt;/li&gt;
&lt;li&gt;Accessing data from other web pages open in other tabs or on different browsers.&lt;/li&gt;
&lt;li&gt;Accessing and controlling the hardware capabilities of your system.&lt;/li&gt;
&lt;li&gt;Accessing any kind of stuff related to extensions and plugins which have been installed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that you know the purpose of JavaScript. You may be wondering about the reason for your end user to disable JavaScript in their browsers while surfing the internet?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Would A User Visit Your Website With JavaScript Disabled?
&lt;/h2&gt;

&lt;p&gt;Believe it or not! Some of us actually prefer to surf the internet with JavaScript disabled in our browsers. Why?&lt;br&gt;&lt;br&gt;
Well, by disabling JavaScript we aim to achieve an interrupted user-experience of a website’s content. Doing so eliminates of the pop-ups, advertisements, warnings etc.Let us take a scenario to understand this better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do you think Mike would be feeling right now?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well, he may feel disappointed with the overall experience of the website. And such pop-ups are quite common to encounter on any website over the internet. Which is why, Mike made sure to disable the JavaScript to ensure he doesn’t encounter more pop-ups, alerts, warnings, advertisements etc. from your website.&lt;/p&gt;

&lt;p&gt;However, the moment Mike disables JavaScript, your website collapsed entirely! The content rendered in an absurd manner. Your website images with embedded hyperlinks to related articles broke down &amp;amp; started showing the links separately than image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fjavascript.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fjavascript.png" alt="javascript"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looks nightmarish isn’t it? Now, it would be impossible for you to stop users like Mike from disabling JavaScript in their browsers. I agree, there won’t be many who would be surfing the internet as Mike. There are some websites that are fully dependent on JavaScript which is really a bad practise and fails to load any resources or makes UX downgraded when JavaScript is disabled.&lt;/p&gt;

&lt;p&gt;However, it depends entirely on how well you want your business to look like, more importantly to how many. As a best practice, it would be in the best interest to test your website with JavaScript disabled. The best part is that you don’t need to install any plugin or any other third party application in order to disable JavaScript, you have this option in your browser preferences itself. In further sections, I will show you how you can test with JavaScript disabled. However, before we do that, there are some other reasons for you to consider disabling JavaScript as you test your website.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Testing With JavaScript Disabled Should Be A Part Of Your QA Checklist?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Increase the testing speed:&lt;/strong&gt; Since the main purpose of JavaScript is to bring interactive patterns to a webpage which require higher bandwidth to load and when you have a lower bandwidth connection, it either loads very slow or downgrade the user interaction with the website. So, testing after disabling JavaScript increases your testing speed by avoiding unnecessary JavaScript resources to load and doesn’t fail your automation testing script because of web page load failure.&lt;br&gt;&lt;br&gt;
As a conclusion to this, you would get your testing results in every short period of time without any chances of getting your test flow disturbed because of any third party resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ease of accessibility:&lt;/strong&gt; Many end users don’t want any kind of advertisements or pop-ups while accessing any website since this kind of stuff makes them distracted from their desirable content. So, many times these kinds of JavaScript resources are closed by the end users while accessing a particular website. This force a website owner to test their website after disabling JavaScript to verify that their users are getting easy accessibility to their website.&lt;br&gt;&lt;br&gt;
Also, keep in mind that some websites are fully dependent on JavaScript to make their UI more interactive, testing of such web applications after disabling JavaScript would not make any sense, than it would be better if you go for headless browser testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross Browser Compatibility:&lt;/strong&gt; Common &lt;a href="https://www.lambdatest.com/blog/fixing-javascript-cross-browser-compatibility-issues/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-12092019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;cross browser compatibility issues for JavaScript&lt;/a&gt; can be noticed such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser JavaScript Interpreter is not able to parse and execute JavaScript code.&lt;/li&gt;
&lt;li&gt;New JavaScript features such as ECMAScript6 / ECMAScript Next and modern Web API fails to work in older browser versions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Handling such JavaScript issues can cause a nightmare for web developers. Hence, it is necessary for testers to &lt;a href="https://www.lambdatest.com/blog/performing-cross-browser-testing-with-lambdatest/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-12092019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;perform cross browser testing&lt;/a&gt; for verifying how their website renders without JavaScript and then the development team can proceed with the resolution of JavaScript issues. Some developers prefer progressive enhancement technique and some prefer graceful degradation technique for cross browser compatibility testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/landing-text-cta?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-12092019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;strong&gt;LambdaTest is a cross browser testing tool with 2000+ real browsers to help you test your web applications on cloud. Sign up for free!&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can test your website on LambdaTest with and without JavaScript to know how your web page renders in different scenarios.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security:&lt;/strong&gt; As discussed, JavaScript is an executable code of a website which gets downloaded to your system local browser whenever we visit the website and then runs. Many advertisements visible on a webpage are basic intent of hackers to spread malware. This kind of online ads are commonly known as malvertising and planting of zombie cookies in the user’s machine. This forces end users who are highly concerned with security to disable the website JavaScript for further accessing.&lt;br&gt;&lt;br&gt;
Hence, it becomes necessary now to test a web application for such end users who prefer accessing websites without JavaScript.&lt;/p&gt;

&lt;p&gt;Now, we will look into the process of disabling JavaScript for website testing.&lt;/p&gt;
&lt;h2&gt;
  
  
  How To Disable JavaScript For Manual Testing
&lt;/h2&gt;

&lt;p&gt;I will be demonstrating the process in 2 browsers i.e. Google Chrome &amp;amp; Mozilla Firefox to help you integrate the process in your cross browser testing checklist. I would be using LambdaTest to help me access different browser without going through the trouble of installing them.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Google Chrome
&lt;/h3&gt;

&lt;p&gt;Testing in Chrome browser has always been a priority for testers. Here is how Google search represents itself by default. Meaning, when JavaScript is enabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fpasted-image-0-7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fpasted-image-0-7.png" alt="Disable JavaScript For Manual Testing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;JavaScript Enabled&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Below are the steps that can help you disabling JavaScript in Chrome:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch a webpage for which you need to disable JavaScript.&lt;/li&gt;
&lt;li&gt;Right click on a page and direct to Inspect Elements.&lt;/li&gt;
&lt;li&gt;Once you get the developer tools open, then press CTRL+SHIFT+P.&lt;/li&gt;
&lt;li&gt;Type “Disable JavaScript” and click on the first option that says debugger.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2FDisable-JavaScript.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2FDisable-JavaScript.png" alt="Disable JavaScript"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;JavaScript Disabled&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Mozilla Firefox
&lt;/h3&gt;

&lt;p&gt;Similarly to Google Chrome, Here is how Google search represents itself by default with enabled JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fenabled-javascript.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2Fenabled-javascript.png" alt="enabled javascript"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;JavaScript Enabled&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Follow the below steps to disabling JavaScript for website on Mozilla Firefox:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Launch a browser and enter “about:config” in URL address bar&lt;/li&gt;
&lt;li&gt;Click on “I accept the risk!” to see the configurations&lt;/li&gt;
&lt;li&gt;Enter “javascript.enabled” in search field&lt;/li&gt;
&lt;li&gt;Double click on “javascript.enabled” available entry to set boolean value as false&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2FJavaScript-Disabled.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.lambdatest.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F08%2FJavaScript-Disabled.png" alt="JavaScript Disabled"&gt;&lt;/a&gt;&lt;em&gt;JavaScript Enabled&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; You can use this &lt;a href="https://www.whatismybrowser.com/detect/is-javascript-enabled" rel="noopener noreferrer"&gt;website&lt;/a&gt; for confirming if your JavaScript is enabled or disabled.&lt;/p&gt;
&lt;h2&gt;
  
  
  How To Disable JavaScript For Automation Testing with Selenium
&lt;/h2&gt;

&lt;p&gt;Now, we get down to automation testing with Selenium. Below is the code that helps to disable JavaScript on Chrome and Firefox browser. We have used &lt;strong&gt;ChromeOptions&lt;/strong&gt; and &lt;strong&gt;FirefoxOptions&lt;/strong&gt; class to handle the preferences of the browser. These classes further help in setting &lt;strong&gt;ChromeDriver&lt;/strong&gt; and &lt;strong&gt;FireFoxDriver&lt;/strong&gt; specific capabilities such as browser version, disabling extension, start maximized, start headless and making browser default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code To Run Automation Testing with Selenium In Mozilla Firefox&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;

public class JSdisableFirefox {

    //Disabling JS in Firefox
    @Test()
    public void Firefox_javascript_disable() throws InterruptedException {

        System.setProperty("webdriver.firefox.driver", "C:\\geckodriver.exe");

        FirefoxOptions options = new FirefoxOptions();
        options.addPreference("javascript.enabled", false);

        WebDriver driver = new FirefoxDriver(options);

        driver.get("https://www.google.com/imghp");
        driver.findElement(By.name("q")).sendKeys("flowers");
        driver.findElement(By.className("Tg7LZd")).click();

        Thread.sleep(5000);
        driver.quit();

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code To Run Automation Testing with Selenium In Google Chrome&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class JSdisableChrome {

           //Disabling JS in Chrome
          @Test()
    public void Chrome_javascript_disable() throws InterruptedException {

        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Lenovo-I7\\Desktop\\Selenium\\chromedriver.exe");

        ChromeOptions options = new ChromeOptions();
        Map&amp;lt;String, Object&amp;gt; prefs = new HashMap&amp;lt;String, Object&amp;gt;();
        prefs.put("profile.managed_default_content_settings.javascript", 2);
        options.setExperimentalOption("prefs", prefs);


        WebDriver driver = new ChromeDriver(options);

        driver.get("https://www.google.com/imghp");
        driver.findElement(By.name("q")).sendKeys("flowers");
        driver.findElement(By.className("Tg7LZd")).click();
        Thread.sleep(5000);


        driver.quit();  


    }



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

&lt;/div&gt;



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

&lt;p&gt;JavaScript has been an integral part of web development, and it definitely helps to provide us with an eye-appealing website. However, it is important that we test what we build. In my opinion, the results were a bit devastating from UX point of view. Few websites that I tested turn out to be completely blank. Reason being, the website was entirely dependent on JavaScript rendering. Even if the website is partially dependent on JavaScript, it is the responsibility of the tester to test their product with and without JavaScript according to the user perspective. Not to forget &lt;a href="https://www.lambdatest.com/feature?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-12092019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;browser compatibility testing&lt;/a&gt; with JavaScript disabled will help you ensure a robust website for a wider set of audience. If you are using a cloud-based cross browser testing tool such as LambdaTest, then you get to test on 2000+ real browsers hosted by VM on cloud. So you don’t get to worry about maintaining your own browser library, as we do it for you. Happy testing! 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-12092019&amp;amp;utm_term=Ramit" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0e5vtqzcoqm2zr3cb7la.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>How to Setup Selenium Grid For Parallel Execution In Different Browsers</title>
      <dc:creator>ramitd1995</dc:creator>
      <pubDate>Tue, 23 Jul 2019 12:37:14 +0000</pubDate>
      <link>https://forem.com/ramitd1995/how-to-setup-selenium-grid-for-parallel-execution-in-different-browsers-47pc</link>
      <guid>https://forem.com/ramitd1995/how-to-setup-selenium-grid-for-parallel-execution-in-different-browsers-47pc</guid>
      <description>&lt;p&gt;Selenium is by far the most used web automation testing tools. One of the reasons behind this huge popularity is Selenium’s automated cross browser testing capabilities. &lt;a href="https://www.lambdatest.com/selenium-automation?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;Selenium automation testing&lt;/a&gt; can help you test on all major browsers, all major operating systems, and even on mobile device browsers. You can get a huge browser coverage in all your functional tests ensuring the perfect experience for a wide range of your potential users.&lt;/p&gt;

&lt;p&gt;But there is a challenge. You can load only so many different browsers on your local machine. For example, if you have a windows machine, you cannot test on Safari browsers, similarly, if you have a Mac machine you won’t be able to test on IE or Edge browsers. In addition, running tests on a single machine was a time-consuming process. If you have multiple computers, why test on a single one at a time?&lt;/p&gt;

&lt;p&gt;The ideal scenario would be to test on a network of interconnected machines having different browser environments running multiple tests cases concurrently, in parallel, and reducing the overall testing time by multiple folds. And here I am also including time taken for &lt;a href="https://www.lambdatest.com/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;cross browser testing&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;And that is exactly what Selenium Grid is built for. Unlike &lt;a href="https://www.lambdatest.com/blog/tips-for-test-automation-with-selenium/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;Selenium WebDriver&lt;/a&gt; which allows you to &lt;a href="https://www.lambdatest.com/blog/lambdatest-now-live-with-an-online-selenium-grid-for-automated-cross-browser-testing/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;perform automated cross browser testing&lt;/a&gt; in a sequential manner, a Selenium Grid setup will allow you to run test cases in different browsers/ browser versions, simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Selenium Grid?
&lt;/h2&gt;

&lt;p&gt;Before we start with Selenium Grid setup, it is necessary to realize the basics of a Selenium Grid.&lt;/p&gt;

&lt;p&gt;So, the Selenium Grid basically allow us to run our automated tests on different operating systems against different browsers. And that too in a parallel manner. Selenium automation testing tool will help you with faster automated cross browser testing, along with efficient utilization of in-house hardware.&lt;/p&gt;

&lt;p&gt;Selenium Grid is comprised of two concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hub: It is the center of the Selenium Grid setup architecture that manages the network of the test machines. There is only one hub in a network which is assigned to a test of DesiredCapabilities(operating system, browser, browser versions) and then the hub finds the test that matches the given configurations.&lt;/li&gt;
&lt;li&gt;Node: Nodes are the test machines that execute the test that was earlier loaded on the hub. There can be multiple nodes configured with a different operating system and different browsers. It is not mandatory for the node to run on the same platform on which the hub is running.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Infrastructure to configuring a Selenium Grid setup for parallel execution involves just two steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating a hub.&lt;/li&gt;
&lt;li&gt;Defining the nodes and connecting to that hub.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Using Command Prompt For Selenium Grid Setup
&lt;/h2&gt;

&lt;p&gt;The first step of a Selenium Grid setup would be to create a hub. You would have to make sure that your system has Java Runtime Environment (JRE) or better yet Java Development Kit (JDK) installed. Though most people recommend going for the latest JDK, I prefer an earlier tried and tested versions like JDK SE 08 or 09. You can go for the latest one if you wish. Here are the next steps –&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download and extract Selenium Standalone server JAR files. You can download them from &lt;a href="https://www.seleniumhq.org/download/"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Next, open a command prompt or terminal and navigate to the directory where the Selenium Standalone Server jar file is saved.&lt;/li&gt;
&lt;li&gt;Run the command “java -jar selenium-server-standalone-3.141.59.jar -role hub”. This command would launch a Selenium Grid hub on port 4444 by default. You can also check the same by directing to &lt;a href="http://localhost:4444/grid/console"&gt;http://localhost:4444/grid/console&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since the hub has already been created, the next step to Selenium Grid setup for parallel execution would involve launching a node. You start with going to the other machines where we want to setup nodes. Again, these machines should have a JDK/JRE setup.&lt;/p&gt;

&lt;p&gt;In the node machine, open a command prompt or terminal and navigate to the directory where you have saved the browser driver files.&lt;/p&gt;

&lt;p&gt;Enter the below command in order to configure Chrome driver in your &lt;a href="https://www.lambdatest.com/blog/speed-up-automated-parallel-testing-in-selenium-with-testng/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;Selenium Grid setup for parallel execution&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -Dwebdriver.chrome.driver="C:\chromedriver.exe" -jar 
selenium-server-standalone-3.141.59.jar -role webdriver -hub 
http://10.0.0.22:4444/grid/register -port 4546 

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



&lt;ul&gt;
&lt;li&gt;In the above command I have used my machine IP along with the port 4444 where the hub is actually running. I have also selected the port 4546 where I want my node to get registered. You can opt for any free port for registering the node. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarly, you can register other nodes for other browsers. For example, here’s how you can configure Firefox(Gecko) driver and Internet Explorer driver to your Selenium Grid setup for parallel execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuring Firefox(Gecko) driver in Selenium Grid setup:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -Dwebdriver.gecko.driver="C:\geckodriver.exe" -jar 
selenium-server-standalone-3.141.59.jar -role webdriver -hub 
http://10.0.0.22:4444/grid/register -port 5566 

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



&lt;p&gt;&lt;strong&gt;Configuring IE(Internet Explorer) driver in Selenium Grid setup:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -Dwebdriver.ie.driver="C:\IEDriverServer.exe" -jar 
selenium-server-standalone-3.141.59.jar -role webdriver -hub 
http://10.0.0.22:4444/grid/register -port 4547

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



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Please make sure that you select different ports for different nodes to connect with the single hub running on port 4444. Also, before running your test on IE, make sure that the browser zoom is exactly 100% otherwise it might show an error.&lt;/p&gt;

&lt;p&gt;You can notice by above commands that we are running our first node for chrome driver on port 4546, the second node for firefox driver is running on port 5566, and the third node for IE browser is running on port 4547. Here is the output screenshot for further reference:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yd6cPwrD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/07/pasted-image-0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yd6cPwrD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/07/pasted-image-0.png" alt="Automation Testing With Selenium"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, that we have our Selenium Grid setup configured, your next step is to perform Selenium automation testing for your cross browser testing suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Execute Automation Testing With Selenium Grid For Parallel Execution
&lt;/h2&gt;

&lt;p&gt;It is time for some automated cross browser testing! I will be running an automation script demonstrating the Selenium Grid for parallel execution. This script would run parallelly on Chrome, Firefox, and Internet Explorer which are registered on different ports and attached to a single hub.&lt;/p&gt;

&lt;p&gt;Here is the sample code I used to perform automation testing with Selenium Grid for parallel execution in different browsers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package DemoAutomation;

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

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;


public class Selenium_MultiBrowser_Test 
{
    WebDriver driver;
    String nodeURL;

    @Parameters({"Port"})
    @BeforeMethod()
    public void setUp(String Port) throws MalformedURLException
    {           
        if(Port.equalsIgnoreCase("4546"))
        {
            nodeURL = "http://10.0.0.22:4546/wd/hub";
            System.out.println("Chrome Browser Initiated");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();            
            capabilities.setBrowserName("chrome");
            capabilities.setPlatform(Platform.WINDOWS);

            driver = new RemoteWebDriver(new URL(nodeURL),capabilities);

            driver.get("https://www.apple.com/");
            driver.manage().window().maximize();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        }

        else
            if(Port.equalsIgnoreCase("5566"))
            {
                nodeURL = "http://10.0.0.22:5566/wd/hub";
                System.out.println("Firefox Browser Initiated");
                DesiredCapabilities capabilities1 = DesiredCapabilities.firefox();
                capabilities1.setBrowserName("firefox");
                capabilities1.setPlatform(Platform.WINDOWS);

                driver = new RemoteWebDriver(new URL(nodeURL),capabilities1);   

                driver.get("https://www.apple.com/");
                driver.manage().window().maximize();
                driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            }

        else

        if(Port.equalsIgnoreCase("4547"))
        {
            nodeURL = "http://10.0.0.22:4547/wd/hub";
            System.out.println("Internet Browser Initiated");
            DesiredCapabilities capabilities2 = DesiredCapabilities.internetExplorer();
            capabilities2.setBrowserName("internet explorer");
            capabilities2.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
            capabilities2.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
            capabilities2.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            capabilities2.setCapability("ignoreProtectedModeSettings", true);
            capabilities2.setCapability("nativeEvents", false);
            capabilities2.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "");
            capabilities2.setCapability(InternetExplorerDriver.LOG_LEVEL, "DEBUG");


            capabilities2.setPlatform(Platform.WINDOWS);

            driver = new RemoteWebDriver(new URL(nodeURL),capabilities2);

            driver.get("https://www.apple.com/");
            driver.manage().window().maximize();    
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        }
    }

    @Test
    public void appleSite() throws InterruptedException
    {
        try
        {

        driver.findElement(By.xpath("//*[@id=\'ac-globalnav\']/div/ul[2]/li[3]")).click();
        Thread.sleep(2000);

        driver.findElement(By.cssSelector("#chapternav &amp;gt; div &amp;gt; ul &amp;gt; li.chapternav-item.chapternav-item-ipad-air &amp;gt; a &amp;gt; figure")).click();
        Thread.sleep(2000);

        driver.findElement(By.linkText("Why iPad")).click();
        Thread.sleep(2000);
        }

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


    @AfterMethod()
    public void tearDown()
    {
            driver.quit();
            System.out.println("Browser Closed");
    }
} 

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



&lt;p&gt;Above is the java class file that is configured with the XML file which includes the values of parameters passed in the java file and also helps in creating a suite of different classes that would run in a parallel manner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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 thread-count="3" name="BlogSuite" parallel="tests"&amp;gt;

&amp;lt;test name="Chrome Test"&amp;gt;
&amp;lt;parameter name="Port" value="4546"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="DemoAutomation.Selenium_MultiBrowser_Test"/&amp;gt;

    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; 

  &amp;lt;test name="Firefox Test"&amp;gt;
&amp;lt;parameter name="Port" value="5566"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="DemoAutomation.Selenium_MultiBrowser_Test"/&amp;gt;

    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; 


  &amp;lt;test name="Internet Explorer Test"&amp;gt;
&amp;lt;parameter name="Port" value="4547"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="DemoAutomation.Selenium_MultiBrowser_Test"/&amp;gt;

    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; 


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

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



&lt;p&gt;&lt;strong&gt;Output Screen:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--069MU2u---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/07/NewBlog.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--069MU2u---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/07/NewBlog.jpg" alt="Output Screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code, I have used &lt;strong&gt;DesiredCapabilities&lt;/strong&gt; class that would help you set properties for the Selenium WebDriver. These properties can be used to configure instances of browser such as BrowserName and BrowserVersion on which you want your script to run on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; However, the script would only run on the browser and browser version that is currently installed on the test machine. Suppose, if you try running your test on Chrome 72 and you only have Chrome 74 installed on your test machine, then your script would show an error. This same scenario occurs while you opt for the different operating system compared to the operating system of your test machines.&lt;/p&gt;

&lt;p&gt;In addition, it is quite expensive to invest in new Mac and Windows environments every time a new OS is launched.&lt;/p&gt;

&lt;p&gt;So, if you wish to perform automated cross browser testing on different browsers, browser versions and operating systems then I would recommend you to look for a tool that offers Selenium Grid setup on-cloud, such as LambdaTest.&lt;/p&gt;

&lt;p&gt;LambdaTest saves you from the hassle of maintaining your Selenium Grid setup, so you could focus on &lt;a href="https://www.lambdatest.com/blog/8-actionable-insights-to-write-better-automation-code/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;writing better automation&lt;/a&gt; code. LambdaTest also empowers you with that ability of Selenium Grid for parallel execution, all on the cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is LambdaTest?
&lt;/h2&gt;

&lt;p&gt;LambdaTest is a cross browser testing platform on cloud. It’s an online manual and automated testing tool where you can test your website/ web application across 2000+ combinations of browsers, browser versions, and operating systems.&lt;/p&gt;

&lt;p&gt;With LambdaTest, not only can you perform Selenium automation testing, you could even perform live interactive real time cross browser testing, responsive testing of your web app/ website as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.lambdatest.com/blog/understanding-the-difference-between-cross-browser-testing-responsive-testing/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;&lt;strong&gt;Want to know the difference between Cross Browser Testing &amp;amp; Responsive Testing? Read our blog around it.&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running Automated Tests On LambdaTest Selenium Grid Cloud
&lt;/h2&gt;

&lt;p&gt;Let’s try running our same test case on LambdaTest Selenium Grid. You can use LambdaTest &lt;a href="https://www.lambdatest.com/capabilities-generator/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;Desired Capabilities Generator&lt;/a&gt; for configuring the desiredcapabilities object. This would save you a lot of your time spent in Selenium Grid setup when done manually.&lt;/p&gt;

&lt;p&gt;With LambdaTest, you only need to &lt;strong&gt;create a Remote Server, add your LambdaTest username, access key, and the Grid URL in your script,&lt;/strong&gt; and then you are good to go.&lt;/p&gt;

&lt;p&gt;Below is the Java code in the TestNG framework that would be more beneficial in this scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package lambdatest;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;


public class SampleTest {
   public String username = "enteryourusernamehere";
  public String accesskey = "enteryourkeyhere";
  public RemoteWebDriver driver = null;
  public String gridURL = "@hub.lambdatest.com/wd/hub";
  boolean status = false;

  @BeforeTest
  @org.testng.annotations.Parameters(value={"browser","version","platform"})
  public void setUp(String browser, String version, String platform) throws Exception {
     DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setCapability("browserName", browser);
      capabilities.setCapability("version", version);
      capabilities.setCapability("platform", platform); // If this cap isn't specified, it will just get the any available one
      capabilities.setCapability("build", "Selenium Grid");
      capabilities.setCapability("name", "Sample Test");
      capabilities.setCapability("network", true); // To enable network logs
      capabilities.setCapability("visual", true); // To enable step by step screenshot
      capabilities.setCapability("video", true); // To enable video recording
      capabilities.setCapability("console", true); // To capture console logs
      try {
          driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities);
      } catch (MalformedURLException e) {
          System.out.println("Invalid grid URL");
      } catch (Exception e) {
          System.out.println(e.getMessage());
      }
  }

  @Test
  public void testSimple() throws Exception {
     try {

            driver.get("https://www.apple.com/");
            driver.manage().window().maximize();

            driver.findElement(By.xpath("//*[@id=\'ac-globalnav\']/div/ul[2]/li[3]")).click();
            Thread.sleep(2000);

            driver.findElement(
            By.cssSelector("#chapternav &amp;gt; div &amp;gt; ul &amp;gt; li.chapternav-item.chapternav-item-ipad-air &amp;gt; a")).click();
            Thread.sleep(2000);

            driver.findElement(By.linkText("Why iPad")).click();
            Thread.sleep(2000);

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


  @AfterTest
  public void tearDown() throws Exception {
     if (driver != null) {
          ((JavascriptExecutor) driver).executeScript("lambda-status=" + status);
          driver.quit();
      }
  }
} 


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



&lt;p&gt;Now, we would run this Java class file with the XML file that contains the value of parameters passed in the Java file and also helps in creating a suite of different classes, using which, we can perform &lt;a href="https://www.lambdatest.com/blog/selenium-grid-setup-tutorial-for-cross-browser-testing/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;automation testing with Selenium Grid&lt;/a&gt; for parallel execution on different configurations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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 thread-count="3" name="BlogSuite" parallel="tests"&amp;gt;

  &amp;lt;test name="FirefoxTest"&amp;gt;
  &amp;lt;parameter name="browser" value="firefox"/&amp;gt;
  &amp;lt;parameter name="version" value="62.0"/&amp;gt;
  &amp;lt;parameter name="platform" value="WIN8"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="lambdatest.SampleTest"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; 

  &amp;lt;test name="ChromeTest"&amp;gt;
  &amp;lt;parameter name="browser" value="chrome"/&amp;gt;
  &amp;lt;parameter name="version" value="70.0"/&amp;gt;
  &amp;lt;parameter name="platform" value="WIN10"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="lambdatest.SampleTest"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; 

  &amp;lt;test name="SafariTest"&amp;gt;
  &amp;lt;parameter name="browser" value="safari"/&amp;gt;
  &amp;lt;parameter name="version" value="11.0"/&amp;gt;
  &amp;lt;parameter name="platform" value="macos High Sierra"/&amp;gt;
    &amp;lt;classes&amp;gt;
      &amp;lt;class name="lambdatest.SampleTest"/&amp;gt;
    &amp;lt;/classes&amp;gt;
  &amp;lt;/test&amp;gt; 

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

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



&lt;p&gt;&lt;strong&gt;Output Screen:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zb_-7UCQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/07/pasted-image-0-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zb_-7UCQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2019/07/pasted-image-0-1.png" alt="Output Screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we have successfully executed automation testing with Selenium Grid for parallel execution on different browsers along with different operating systems without any hassle of creating a hub and launching the nodes on different ports. While the test is running on a Selenium Grid, you can see the live video streaming of your tests and various other details such as commands which includes the screenshot of each command passed by your script and also the logs and exceptions raised.&lt;/p&gt;

&lt;p&gt;You can also create your own team and run your automated cross browser compatibility testing scripts as a team. These test results would be visible to each member added in a team. In addition through our single click integration, your teammates can log any bug found during their cross browser testing session directly to various project management platforms like Jira, Trello, Asana, Mantis, GitHub, etc. In addition, LambdaTest also integrates with CI/CD platforms that are complementary to your automation testing tools like CircleCI, Jenkins, TravisCI, etc. Check out all of the &lt;a href="https://www.lambdatest.com/integrations?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;LambdaTest integrations&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;Selenium Grid setup, if done manually, could be challenging. If the main purpose of Selenium Grid is to run tests in parallel and test on a different configuration, you can perform the same on LambdaTest without investing time and resources on creating Selenium Grid hub and Selenium Grid nodes. So, give it a try once by running your automated tests on this online Grid and let us know in the comment box about your feedback using LambdaTest. Happy Testing! 🙂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://accounts.lambdatest.com/register/?utm_source=dev&amp;amp;utm_medium=Blog&amp;amp;utm_campaign=Ramit-23072019&amp;amp;utm_term=Ramit"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M0j-luKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.lambdatest.com/blog/wp-content/uploads/2018/11/Adword-Cyber2.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>java</category>
    </item>
  </channel>
</rss>
