What is Cross Browser Testing?
Cross Browser Testing is a type of functional test to check that your web application works as expected in different browsers.
Why do we need Cross Browser Testing?
Web-based applications are totally different from Windows applications. A web application can be opened in any browser by the end user. For example, some people prefer to open http://twitter.com in Firefox browser, while other's can be using Chrome browser or IE.
In the diagram below you can observe that in IE, the login box of Twitter is not showing curve at all corners, but we are able to see it in Chrome browser.
So we need to ensure that the web application will work as expected in all popular browsers so that more people can access it and use it.
Test Microsoft Edge and also IE8 up to IE11 using virtual machines that you download and manage locally for free. Site Scan With webhint. We've completely revamped our site scanning tool to bring you webhint, a configurable linting tool for the web. How can the answer be improved?
This motive can be fulfilled with Cross Browser Testing of the product.
Reason Cross Browser Issues
- Font size mismatch in different browsers.
- JavaScript implementation can be different.
- CSS,HTML validation difference can be there.
- Some browser still not supporting HTML5.
- Page alignment and div size.
- Image orientation.
- Browser incompatibility with OS. Etc.
How to perform Cross Browser Testing
If we are using Selenium WebDriver, we can automate test cases using Internet Explorer, FireFox, Chrome, Safari browsers.
To execute test cases with different browsers in the same machine at the same time we can integrate Testng framework with Selenium WebDriver.
Your testing.xml will look like that,
This testing.xml will map with the Test Case which will look like that
Here because the testing.xml has two Test tags ('ChromeTest','FirefoxTest'),this test case will execute two times for 2 different browsers.
First Test 'ChromeTest' will pass the value of parameter 'browser' as 'chrome' so ChromeDriver will be executed. This test case will run on Chrome browser.
Second Test 'FirefoxTest' will pass the value of parameter 'browser' as 'Firefox' so FirefoxDriver will be executed. This test case will run on FireFox browser.
Complete Code:
Guru99CrossBrowserScript.java
testing.xml
NOTE: To run the test, Right click on the testing.xml, Select Run As, and Click TestNG
Summary
- Cross browser Testing is a technique to test web application with different web browsers.
- Selenium can support different type of browsers for automation.
- Selenium can be integrated with TestNG to perform Multi Browser Testing.
- From parameters in testing.xml we can pass browser name, and in a test case, we can create WebDriver reference accordingly.
Note: The given program was built & tested on selenium 3.0.1, Chrome 56.0.2924.87 , Firefox 47.0.2 & Microsoft Edge 14.14393. If the programs give an error, please update the driver
Download the Selenium Project Files for the Demo in this Tutorial
There are many different browsers and operating systems and Browserling provides quick access to all the most popular browsers on the most popular operating systems. Users can just go to www.browserling.com select a browser and start testing their website. It's that simple!
This extension makes it even simpler. Once installed, it lets you test the current website that you're browsing. Just click the extension, choose platform, browser and version, and you can start testing!
Currently supported Windows operating systems:
- Windows XP
- Windows Vista
- Windows 7
- Windows 8
- Windows 8.1
- Windows 10
Currently supported Android versions:
* Android 4.4 KitKat
* Android 5.0 Lollipop
* Android 5.1 Lollipop
* Android 6.0 Marshmallow
* Android 7.0 Nougat
* Android 7.1 Nougat
Soon we'll also Android 8.0 and 8.1, OSX, iOS, and Linux browsers.
Supported Browsers:
- Edge
- Internet Explorer
- Google Chrome
- Mozilla Firefox
- Apple Safari
- Opera
Happy cross-browser testing!