TESTEVERYTHING

Monday 14 November 2016

WebDriver | Automation | launch/Execute on different version of Firefox

Run tests on specific Firefox version | Selenium


Firefox binary

Imagine a situation where you have to test your web application against two different versions of the Firefox browser. By default, when you instantiate FirefoxDriver, the Firefox version that is available on the PATH variable is launched. But if you want to launch a different version of Firefox, we need to use Firefox Binary. For this first steps you have to install all the versions of Firefox which you want to test on your system.

Make sure the installed Firefox versions on different path locations using Custom installation

Installing multiple versions of Firefox


Suppose you have already installed the Firefox(version 22) means default Firefox is already installed. this can be found on your program file location like this..

"C:\Program Files (x86)\Mozilla Firefox"

Now we have to install another Firefox version (lets take Firefox version 23).

1. Download this version from Mozilla site and start installing it.

2. When you reach the following screen in your installation, select Custom.




3. Enter the path as "C:\Mozilla Firefox\" in the path field as shown as follows, and proceed with the installation:



4. Now try to launch Firefox from your code; it will launch Firefox 22 version (default Firefox browser) as it is available in the PATH variable.

5. So, in order to use Firefox 23.0, try to use Firefox Binary. The following is the code example for it:

Here we have to define the path of my another installed Firefox version


import java.io.File;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

private WebDriver driver;

FirefoxBinary binary = new FirefoxBinary(new File("C:\\Mozilla Firefox\\firefox.exe"));

FirefoxProfile profile = new FirefoxProfile();   

driver = new FirefoxDriver(binary, profile);

driver.get("http://www.google.com");








No comments:

Post a Comment

Which one is right ?

Translate







Tweet