Most important part of every software development process is ‘Testing’ and with mobile applications it has become even more important. Enormous fr...Read More
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.
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 the 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:
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:
DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
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”);
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.