Selenium-12: Cross Browser Testing

In web world users use different browsers such as Chrome, Firefox, Internet Explorer, Opera, and Safari and so on. These browsers have different behaviors and features. Thus, we should verify web applications functionalities are working as expected for all browsers and this testing activity is called cross browser testing. Selenium webdriver supports HtmlUnit Driver, Firefox Driver, Chrome Driver, Opera Driver, MS Edge Driver, MS Internet Explorer Driver, Safari Driver, GhostDriver (PhamtomJS) and so on.

Selenium webdriver also provides us Remote Webdriver. There are some services such as Sauce Labs or Browser Stack that present us all browsers and their versions in their servers. In order to connect those servers and test web applications with different browsers on the cloud, we use Remote Webdriver. Also, Remote Webdriver is being used for Grid implementations. In another post, I will explain how to use Remote Webdriver and how to test on the cloud.

Due to nature of diversity of browsers we face with different browser behaviors. In order to cover all browsers while we are automating a website, we should think different synchronizations, different startup procedures, and so on.

FireFox Driver

Firefox driver is the built-in driver so you do not need to do for installation. Its startup period is relatively slow.

Declaration: driver = new FirefoxDriver();

Firefox Driver Profile

Profiles provides us to declare driver with extra capabilities and configurations.

Profile Declaration

FirefoxProfile profile = new FirefoxProfile();

Webdriver driver = new FirefoxDriver(profile);

How to use Profiles?

1) Profile Level Methods (Example: Enable NativeEvents)

NativeEvents is disabled by default. In WebDriver, advanced user interactions are provided by either simulating the Javascript events directly (i.e. synthetic events) or by letting the browser generate the Javascript events (i.e. native events). Native events simulate the user interactions better whereas synthetic events are platform independent, which can be important in Linux when alternative window managers are used. Native events should be used whenever it is possible.


FirefoxProfile profile = new FirefoxProfile();


WebDriver driver = new FirefoxDriver(profile);

2) Browser Preferences (Example: Set Language)

profile.setPreference( “intl.accept_languages”, “no,en-us,en” );

3) Load Addons (Example: Load Firebug)

Firefox driver is loaded without extensions/addons by default. Sometimes we need these addons such as firebug for debugging purposes while our test script is running. In order to fix this problem, we can load addons by using their XPI files and webdriver profiles. An example code is shown below.

Test Result:

cross browser

Desired Capabilities

DesiredCapabilities provides to set properties for the WebDriver such as BrowserName, Platform, Version, etc. We can configure all driver instance like FirefoxDriver, ChromeDriver, InternetExplorerDriver using desired capabilities. It is very useful when we are using RemoteWebdriver to test on the cloud by using Browserstack or Saucelabs. Also, we can set a manual proxy with DesiredCapabilities. This temporarily changes the system’s proxy settings and when the test finishes, it will change the system to the original state. [2]

I will show you a proxy test example but before run this proxy test code you should install Burp Suite and set localhost:8080 ( as a proxy as shown below.


Proxy Example:

Test Result:
After running above test code, you will see the GET methods as shown below.


HTMLUnit Driver

It is developed by (

HtmlUnit is a “GUI-Less browser for Java programs”. It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc… just like you do in your “normal” browser.

It has fairly good JavaScript support (which is constantly improving) and is able to work even with quite complex AJAX libraries, simulating Chrome, Firefox or Internet Explorer depending on the configuration used. [3]

It is faster but I recommend to use HTMLUnit Driver for basic automation scenarios.

Ghost Driver (PhantomJS)

It is a headless driver, it means when you run it, you won’t see a browser window but you can do everything related web testing. In order to use GhostDriver, you should add below maven dependency into your project. (link: phantomjsdriver 1.2.1)

And you must download PhantomJS executable from and place it under your project directory and declare it in your test automation code.

A sample example is shown below.

You can find detailed information about PhantomJS on this page

Chrome Driver

ChromeDriver is a standalone server which implements WebDriver’s wire protocol for Chromium. ChromeDriver is available for Chrome on Android and Chrome on Desktop (Mac, Linux, Windows and ChromeOS). [4]

In order to use ChromeDriver, you should specify its location via the system property. The sample test code for chrome driver is shown below.

Problem & Solution: If you get java.lang.NoClassDefFoundError: org/openqa/selenium/remote/service/DriverService$Builder error, then you should add below dependency into your pom.xml.   After that that problem will dissepear. I solved this problem in this way.

Note: You should change version with the latest Selenium Webdriver version.

For extra information about Chromium Command Line Switches you can visit

IE Driver

First you have to download IEdriver executable file from here:

Then we should set the “” to the location of the driver executable and declare IEdriver as follows.

Declaration: Driver = new InternetExplorerDriver();

Important Note!

Problem: When I tried to do test with IEdriver I got OpenQA.Selenium.NoSuchWindowException : Unable to get browser” problem.

Solution: I solved this problem to set all security zones to the same Protected Mode setting.

Setting the Local Intranet zone’s Enable Protected Mode setting to true solved the problem

  1. Select Tools > Internet Options and go to the Security tab.
  2. Select each zone (Internet, Local intranet, Trusted sites, Restricted sites) and check the Enable Protected Mode check box.

Also, if above solution doesn’t work, then try to add the test domain to the list of “Trusted Sites”. This may solve this problem. You can do this on the Security tab of Internet Options.


Test Code:

MS Edge Driver

If you are using Windows 10 and if you need to do test automation with MS Edge browser, you should do this in this way.

First you have to download MS Edge Driver from

Then, you should set driver path, declare a EdgeDriver and use it as follows:

There is a nice article about MS Edge Driver here:

Opera Driver

Important Note: The OperaDriver has been deprecated so now the maximum Selenium WebDriver version that it supports is 2.34.0, and it supports a maximum of Opera version 12.17.

You can find information and examples of operachromiumdriver example here:

Safari Driver

SafariDriver on Windows will most likely not work on newer versions of Safari and/or Windows because of Apple’s decision to drop Safari on Windows.

For more information and examples, you can check here:

Common Problems of Cross Browser Testing

While doing cross browser testing, you may face with problems and fails. Different browsers have different driver implementations and these drivers have different behaviors, timing issues, selector differences, implementations bugs, driver implementation scope is not complete (some functionalities are missing), and so on. When you get this kind of errors, I suggest you to read the driver log and search this problem on the internet. Also if you are setting up a new test automation framework, try to implement cross browser testing as early as possible and see the problems at early phases. You can solve your problems easily in early phases of you test automation framework.

References [1] [2] [3] [4]


Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 56 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 15 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...

Getting Started with JavaFX

By Onur Baskirt / Mar 25, 2016 / 0 Comments
When I started to work in my current position, one of my task is to do manual operations for campaign products  every week. After the second week, I thought that I have to automate this task using a GUI based...

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 4 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across wide range of browsers and platforms. In this tutorial you will learn how to do web test automation with Selenium Webdriver and the related tools. Audience...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...

How to Select a Date From DatePicker Using Selenium

By Onur Baskirt / Aug 13, 2016 / 6 Comments
When you need to automate a airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit cumbersome to select a specific date on the Datepicker or calendar.  In this post, I...

Selenium Webdriver Performance testing with Jmeter and Selenium Grid

By Ozgur Kaya / Aug 9, 2016 / 2 Comments
In this post, we will complete Selenium Webdriver Performance testing scenario using Jmeter and Selenium Grid. 1- Install Java 7 or later If necessary 2- Download latest Jmeter version 3.0 or higher. 3- Download Jmeter PluginsManager JAR file and...
By | 2017-01-13T21:33:43+00:00 February 19th, 2016|Selenium, Test Automation, Web Automation|2 Comments

About the Author:

Onur Baskirt
Onur Baskirt is a senior IT professional with 10+ years of experience. He worked at Bahçesehir University, ST Microelectronics, Huawei and Ericsson as research assistant, design verification engineer and software test leader. Also, he worked as software test leader and software operations manager at Turkey's biggest technology retailer, Teknosa. Now, he is working as Head of Software Testing and Manager of two Development Teams at His current research areas are technical software testing, programming, and computer science. Formerly, he has several research works and papers on digital chip design & verification. His hobbies are sport, dancing, traveling, and nutrition. You can find detailed information about him on his linked-in page.


  1. Jako March 7, 2016 at 12:17 pm - Reply

    How to setup Edge working with proxy.
    the capabilities.proxy is not working

Leave A Comment