top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Cross Browser Testing using selenium WebDriver

In this blog we are going to see how do i achieve Cross Browser Testing using selenium with cucumber BDD tool which can coded in Java. And also we will be discussed about how a single line change in config file can execute different browsers(Google Chrome, Safari, Microsoft Edge, Internet Explorer, Firefox , etc).


What is Cross Browser Testing?

Cross-browser testing is a type of testing done to check the application’s working capabilities on various browsers and their versions to make sure that the application gives uniform user experience concerning the requirements


Need Of Cross Browser Testing

Every browser uses different web browsers like some one use chrome, some else will use safari . Because of that reason cross browser testing is created.

Cross browser testing is mainly used to check the application's user interface design and functionalities on various browsers.

A website consists of several components such as content, images , CSS, and scripts. Each browser will handle all of this components in a different way.

What is WebDriver Manager and how it works?

WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers required by Selenium WebDriver in a fully automated manner.

Selenium WebDriver is a library that allows controlling web browsers programmatically. It provides a cross-browser API that can be used to drive web browsers (e.g., Chrome, Edge, or Firefox, among others) using different programming languages (e.g., Java, JavaScript, Python, C#, or Ruby). The primary use of Selenium WebDriver is implementing automated tests for web applications.

Selenium WebDriver carries out the automation using the native support of each browser. For this reason, we need to place a binary file called driver between the test using the Selenium WebDriver API and the browser to be controlled. Examples of drivers for major web browsers nowadays are chromedriver (for chrome), geckodriver (for firefox), or msedgedriver (for edge).


Features

WebDriverManager provides a fluent API available using the class WebDriverManager (package io.github.bonigarcia.wdm). This class provides a group of static methods to create managers, i.e., objects devoted to providing automated driver management and other features.

Steps For Cross Browser Testing using WebDriver Manager

Step : 1

First we have to create a maven project with what are the dependencies needed . Add all dependencies in pom.xml.

Then we have to add latest version of a WebDriver Manager dependency from maven repository

<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager --> <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>5.3.1</version> </dependency>

Step : 2

We have to create Packages with names cross browser and hooks in src/test/java. Inside of those Packages create Classes DriverFactory and Hooks.



And also create config.properties file inside src/test/resources

Step : 3

In DriverFactory class we should write all our cross browser codes.


Primary use of WebDriverManager is the automation of driver management. To use this feature, you need to select a given manager in the WebDriverMager API (e.g., chromedriver() for Chrome) and invoke the method setup().

Setup :

Once we have downloaded the driver to our computer, we need to provide a way to locate this driver from our Selenium WebDriver tests. In Java, this setup can be done in two different ways. First, we can add the driver location to our PATH environmental variable. Second, we can use Java system properties to export the driver path. Each driver path should be identified using a given system property, as follows:

In the above screenshot WebDriverManager.chromedriver().setup(); .It will set the path. Like this

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver"); System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver"); System.setProperty("webdriver.edge.driver", "/path/to/msedgedriver"); System.setProperty("webdriver.opera.driver", "/path/to/operadriver");

System.setProperty("webdriver.ie.driver", "C:/path/to/IEDriverServer.exe");

WebDriverManager provides a set of managers for Chrome, Firefox, Edge, Opera, Chromium, and Internet Explorer. The basic use of these managers is the following:

WebDriverManager.chromedriver().setup(); WebDriverManager.firefoxdriver().setup();

WebDriverManager.edgedriver().setup();

WebDriverManager.operadriver().setup(); WebDriverManager.chromiumdriver().setup() ;

WebDriverManager.iedriver().setup();

Step : 4

In Hooks we can give all the hooks (@BeforeAll, @AfterAll, @BeforeStep, @AfterStep, etc) . We have to implement the browser before all steps. For repeatedly implementing we can use before all annotation. It will implement this method before the project code execution.

Step : 5

In config.properties file we just can give browser in key pair values.

suppose you want to access through edge browser then you have to give

browser = edge. Then the browser will change to edge.


Step : 6

In the above screenshot we had given browser as chrome so it will start using chrome browser.Without giving any path with the help of WebDriver Manager we can run through any browser.


WebDriverManager provides a set of managers for Chrome, Firefox, Edge, Opera, Chromium, and Internet Explorer. The basic use of these managers is the following:

WebDriverManager.chromedriver().setup(); WebDriverManager.firefoxdriver().setup();

WebDriverManager.edgedriver().setup();

WebDriverManager.operadriver().setup(); WebDriverManager.chromiumdriver().setup() ;

WebDriverManager.iedriver().setup();

Conclusion :

Cross browser testing is one of the most important testing types used for customer satisfaction.

Manual cross browser testing is time and resource consuming but cross browser test test automation is saving some bucks and also increase the quality of the application.

Cross browser testing is performed by the QA team. But in some organizations, apart from the QA team, developers also play the role of cross-browser tester. Usually, cross browser testing is done not only for functional but also for non-functional requirements.

Thank you For Reading my blog.

230 views0 comments

Commentaires

Noté 0 étoile sur 5.
Pas encore de note

Ajouter une note
bottom of page