Your browser does not support JavaScript!

Blog

What is Cross Browser Automation Testing & How to perform it?
What is Cross Browser Automation Testing & How to perform it?
Automation Testing
June 20, 2017

Cross browser testing is a technique which is used to test the behavior of a website or an application in multiple browsers. It is necessary to ensure that your web application or website is performing accurately on all the browsers due to the fact that browsers have a different method of presenting the site, in which case differences and errors might occur in the layout, feature or functionality. It involves examining the compatibility of your application across multiple web browsers. Cross Browser testing involves testing both the client side and server side behavior of the Web application when it is accessed using different Web Browsers.

With the availability of wide range of web browsers, the end users are using variety of web browsers to access the web applications. Web-based applications are totally different from Windows applications. A web application can be opened in any browser by the end user. Thus, it has now become crucial to test the web applications on multiple browsers. The client components like JavaScript, AJAX requests, Applets, Flash, Flex etc. may behave differently on different browsers. Also, the process of request handling for different browsers also varies.

How to Automate Cross Browser Testing?

i) With the help of Selenium WebDriver, we can automate test cases and run those test cases simultaneously across various browsers such as Internet Explorer, FireFox, Chrome, and Safari browsers.

ii) TestNG framework with Selenium WebDriver is used for execution of same test cases on the same machine at the same time but with different browsers.

Selenium WebDriver can be used to run browser compatibility tests on various browsers such as Chrome, Firefox, Internet Explorer, Safari, and Opera. WebDriver API drives the web browser just like a real user. Firefox Driver has ‘selenium-server-standalone.jar’ library by default while Chrome, IE, Safari, and Opera do need external libraries. In order to perform cross browser automation testing, one needs to initialize WebDriver for various browsers. Let us discuss various browsers and also the steps to initialize WebDriver for different browsers.

1. Mozilla Firefox: The ‘selenium-server-standalone’ library is bundled with Firefox Driver to initialize and run tests in a Firefox browser. Firefox Driver is added to the Firefox profile as a file extension on starting a new instance of Firefox Driver. To start Mozilla Firefox, the code is:

WebDriver driver = new FirefoxDriver();

2. Google Chrome: Chrome Driver is an external library file that makes use of WebDriver protocol to run Selenium tests in a Google Chrome web browser. To start Google Chrome, the code is:

System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

3. Internet Explorer: IEDriverServer is an executable file. It uses the WebDriver wire protocol to control the IE browser in Windows. IE versions ranging from 6 up to 10 are supported by it. To start Internet Explorer, the code is:

System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");

DesiredCapabilities dc = DesiredCapabilities.internetExplorer();

dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

WebDriver driver = new InternetExplorerDriver(dc);

4. Apple Safari: Just like FirefoxDriver, SafariDriver is also internally bundled with the latest Selenium servers thereby starting the Apple Safari browser without any external library. SafariDriver supports the Safari browser versions 5.1.x and runs only on MAC. To initiate SafariDriver, the code is:

WebDriver driver = new SafariDriver();

5. Opera: OperaPrestoDriver (formerly called OperaDriver) is available only for Presto-based Opera browsers. Currently, it does not support Opera versions 12.x and above. However, the recent releases (Opera 15.x and above) of Blink-based Opera browsers are handled using OperaChromiumDriver. To initiate OperaChromiumDriver, the code is:

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("opera.binary", "C://Program Files (x86)//Opera//opera.exe");

capabilities.setCapability("opera.log.level", "CONFIG");

WebDriver driver = new OperaDriver(capabilities);

Advantages of Cross Browser Automation Testing

i) Automation of different type of browsers can be achieved by using Selenium.

ii) Multi Browser Testing can be performed by integrating Selenium with TestNG.

iii) Test scripts are re-usable and can be used across various environments, parameters and scenarios.

iv) Automated testing offers a level of consistency which is not achievable by using  manual testing.

   

Author: Harinder Kaur

Alternative Text

Harinder works as Automation Test Engineer at BugRaptors. She is experts in writing scripts in web driver/Behat using Cucumber, gherkin languages. She has tested the web application on multiple Browsers and OS using Automation.

Leave a Reply

Your email address will not be published. Required fields are marked *