LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

Can I perform parallel testing of my web app across different browsers using Selenium?

Can anyone please tell me can I perform parallel testing of my web app across different browsers using Selenium or not.

Up Vote Down Vote 0 Votes
Posted 4 months ago

Answers


Parallel testing In Selenium helps us to perform across numerous browsers and their corresponding versions at the same time with the help of an automation tool. It helps provide better coverage in the shortest span of time without sacrificing quality. Parallel testing in Selenium can be achieved via different automation tools.

Parallel testing in Selenium grid with TestNG helps you run your tests on multiple browsers, operating systems and machine at the same time. It uses a hub-node concept where all the tests are run on a single machine called the hub but execution is performed by various other machines which are connected to the hub and are known as nodes which have different platforms and browsers configured on them. There can be multiple nodes but only one hub will be present in the grid setup. Parallel testing in Selenium grid with TestNG helps in reducing the execution time drastically.

In order to design scripts on a hub-node based architecture we need to be aware of two important concepts:

  • DesiredCapabilities
  • RemoteWebDriver

DesiredCapabilities is a class in org.openqa.selenium.remote.DesiredCapabilities package. It helps to set the properties of the browser like BrowserName, Version and Platform. The setCapabilityMethod() of the DesiredCapabilities class is one of the important methods used for performing parallel testing in Selenium with TestNG or any other framework on different machine configurations. It helps to set the device name, platform version and name, absolute path of the app under test etc. Other different DesiredCapabilities methods include getBrowserName(), setBrowserName(), getVersion(), setVersion(), getPlatform(), setPlatform(), getCapabilityMethod() etc.

Showcasing below code, that uses to set the browser, platform and version number for performing parallel testing in Selenium grid with TestNG:

DesiredCapabilities capability= new DesiredCapabilities();

capability.setPlatform(Platform.WIN8_1);

capability.setBrowserName(“firefox”);

capability.setVersion(“58”);

RemoteWebDriver

RemoteWebDriver is an implementation of the WebDriver interface. The other implementations include the chromedriver, firefoxdriver, IEDriver etc. If running your tests locally, you opt for the above other drivers except remoteWebDriver, whereas remoteWebDriver needs to be configured and then can run on an external machine.

Up Vote Down Vote 0 Votes
Posted 2 months ago