How to use FirefoxBinary class of org.openqa.selenium.firefox package

Best Selenium code snippet using org.openqa.selenium.firefox.FirefoxBinary

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1--L2C1--
2---shippingJuint.java---
3package testRunner;
4import org.junit.runner.RunWith;
5import cucumber.api.CucumberOptions;
6import cucumber.api.junit.Cucumber;
7@RunWith(Cucumber.class)
8@CucumberOptions(features="Features",glue={"stepDefinition"})
9public class ShippingJunit {
10}
11
12---Shipping.feature---
13Feature: To Test the Shipping details in DATAX Shipping Company
14  #Please Do not change Scenario Outline Templet
15  Scenario Outline: Title of your scenario outline 
16    #Please Do not change Given Templet
17    Given Start firefox browser and open the application
18    When  Test the text in H2 tag and the "6543217" for ShipmentID
19    Then Validate the Customer name "Maya" is displayed
20    Then Quit the browser
21    
22    Examples:
23    |Shipment Id|
24    |6543217	|
25	
26---stepDefinition.java----
27import org.openqa.selenium.By;
28import org.openqa.selenium.WebDriver;
29import org.openqa.selenium.WebElement;
30import org.openqa.selenium.firefox.FirefoxDriver;
31import org.openqa.selenium.firefox.FirefoxOptions;
32import org.openqa.selenium.firefox.FirefoxProfile;
33import org.openqa.selenium.firefox.FirefoxBinary;
34import cucumber.api.java.en.Given;
35import cucumber.api.java.en.Then;
36import cucumber.api.java.en.When;
37import org.junit.*;
38public class StepDefinition {
39	WebDriver driver;
40    @Given("^Start firefox browser and open the application$")
41    public void SetUp() throws Throwable {
42		System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
43    	FirefoxBinary firefoxBinary = new FirefoxBinary();
44    	firefoxBinary.addCommandLineOptions("--headless");
45        FirefoxProfile profile=new FirefoxProfile();
46    	FirefoxOptions firefoxOptions = new FirefoxOptions();
47    	firefoxOptions.setBinary(firefoxBinary);
48    	firefoxOptions.setProfile(profile);
49        driver=new FirefoxDriver(firefoxOptions);
50	    driver.get("https://webapps.tekstac.com/shippingDetails/");
51    }
52    @When("^Test the text in H2 tag and the \"([^\"]*)\" for ShipmentID$")
53    public void  testShippingDetails(String arg1) throws Throwable {
54	    //Please fill the required codes
55	    String H2tag = driver.findElement(By.xpath("//h2")).getText();
56	    Assert.assertEquals("Shipping Details", H2tag);
57	    String ShipmentID = driver.findElement(By.xpath("//div[@id='shippingTable']/table/tbody/tr[2]/td[1]/a")).getText();
58	    Assert.assertEquals(arg1, ShipmentID);
59    }
60    @Then("^Validate the Customer name \"([^\"]*)\" is displayed$")
61    public void  validateResult(String arg1) throws Throwable {
62        //Please fill the required codes
63        driver.findElement(By.xpath("//div[@id='shippingTable']/table/tbody/tr[2]/td[1]/a")).click();
64	    String customerName = driver.findElement(By.xpath("//div[@id='result']/table/tbody/tr[2]/td[1]")).getText();
65	    Assert.assertEquals("Maya", customerName);
66    }
67    @Then("^Quit the browser$")
68    public void Quit_the_browser() throws Throwable {
69        driver.close();
70    }
71}
72
73
74--L2C2--
75---user.feature---
76Scenario: Validate Shipment status and details with enrolled User Details.
77    #Please Do not change Given Templet
78	Given User loads the application and navigate to home page
79	When  User enters "Shamili" on the tracking page
80	Then following should be displayed	
81    |Name 		 |Shamili            |
82	|Shipment Id |SHIP1236           |
83	|Phone Number|9224158877         |
84	|E-mail      |[email protected]|
85	
86---StepDefinition---
87package stepDefinition;
88import java.util.List;
89import java.util.concurrent.TimeUnit;
90import org.junit.Assert;
91import org.openqa.selenium.By;
92import org.openqa.selenium.WebDriver;
93import org.openqa.selenium.chrome.ChromeDriver;
94import org.openqa.selenium.firefox.FirefoxDriver;
95import org.openqa.selenium.firefox.FirefoxOptions;
96import org.openqa.selenium.firefox.FirefoxProfile;
97import org.openqa.selenium.firefox.FirefoxBinary;
98import cucumber.api.DataTable;
99import cucumber.api.java.After;
100import cucumber.api.java.en.*;
101
102public class StepDefinition {
103	WebDriver driver;
104	String text;
105	@Given("^User loads the application and navigate to home page$")
106	public void setUp(){		
107		System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
108    	FirefoxBinary firefoxBinary = new FirefoxBinary();
109    	firefoxBinary.addCommandLineOptions("--headless");
110        FirefoxProfile profile=new FirefoxProfile();
111    	FirefoxOptions firefoxOptions = new FirefoxOptions();
112    	firefoxOptions.setBinary(firefoxBinary);
113    	firefoxOptions.setProfile(profile);
114        driver=new FirefoxDriver(firefoxOptions);
115		driver.get("https://webapps.tekstac.com/Handling_Reg_Expression");
116		System.out.println("Application is launched");
117	}
118	@When("^User enters \"([^\"]*)\" on the tracking page$")
119	public void testUserDetails(String Name){
120		//Please fill the required codes
121		driver.findElement(By.id("userId")).sendKeys(Name);
122		driver.findElement(By.id("track")).click();
123	}
124	@Then("^following should be displayed$")
125	public void validateResult(DataTable ShipmentDetails) {
126		//Please fill the required codes
127		List<List<String>> data = ShipmentDetails.raw();
128		text = driver.findElement(By.id("result")).getText();
129		Assert.assertTrue(text.contains(data.get(1).get(0)));  
130		Assert.assertTrue(text.contains(data.get(1).get(1)));
131		Assert.assertTrue(text.contains(data.get(1).get(2)));
132		Assert.assertTrue(text.contains(data.get(1).get(3)));
133	}
134	@After
135	public void closeDriver(){
136		driver.quit();
137	}
138}
139
140--L2C3--
141---discount.feature---
142#Please Do not change Scenario Outline Templet
143Feature: DATAX Shipping Discount calculation.
144#Please Do not change Scenario Outline Templet
145Scenario Outline: Validate Shipping company offers discount for different weights and Distances.
146    #Please Do not change Given Templet
147	Given User loads the application and navigate to DATAX shipping company home
148	When User enters "<weight>" and "<distance>" on Company Offers Discount page
149	Then The text "<discount>" should be displayed
150	Examples:
151	|weight|distance|discount|
152	|100   |200     |Datax shipping company offers discount|
153	|80	   |500     |Datax shipping company offers discount|
154	|120   |520     |Datax shipping company offers discount|
155	|300   |200     |Datax shipping company offers discount|
156	
157---nodiscount.feature---
158#Please Do not change Scenario Outline Templet
159Feature: DATAX Shipping Discount calculation.
160#Please Do not change Scenario Outline Templet
161Scenario Outline: Validate Shipping company doesn't offers discount for different weights and Distances.
162    #Please Do not change Given Templet
163	Given User navigates to DATAX shipping company home
164    When User enters "<weight>" and "<distance>"
165	Then The text "<noDiscount>" should be present
166	Examples:
167	|weight|distance|noDiscount|
168	|60	   |110     |Datax shipping offers no discount|
169	|50	   |150     |Datax shipping offers no discount|	
170---discountstepdefinition.java---
171package stepDefinition;
172import java.util.concurrent.TimeUnit;
173import org.junit.Assert;
174import org.openqa.selenium.By;
175import org.openqa.selenium.WebDriver;
176import org.openqa.selenium.chrome.ChromeDriver;
177import org.openqa.selenium.firefox.FirefoxDriver;
178import org.openqa.selenium.firefox.FirefoxOptions;
179import org.openqa.selenium.firefox.FirefoxProfile;
180import org.openqa.selenium.firefox.FirefoxBinary;
181import cucumber.api.java.en.*;
182
183public class DiscountStepDefinition {
184	WebDriver driver;
185	String text;
186	@Given("^User loads the application and navigate to DATAX shipping company home$")
187	public void setUp() {
188		System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
189    	FirefoxBinary firefoxBinary = new FirefoxBinary();
190    	firefoxBinary.addCommandLineOptions("--headless");
191        FirefoxProfile profile=new FirefoxProfile();
192    	FirefoxOptions firefoxOptions = new FirefoxOptions();
193    	firefoxOptions.setBinary(firefoxBinary);
194    	firefoxOptions.setProfile(profile);
195        driver=new FirefoxDriver(firefoxOptions);
196		driver.get("https://webapps.tekstac.com/CompanyOffersDiscount/");
197		System.out.println("Application is launched");
198	}
199	@When("^User enters \"([^\"]*)\" and \"([^\"]*)\" on Company Offers Discount page$")
200	public void testDiscount(String weight, String distance) {	
201	    //Please fill the required codes
202		driver.findElement(By.xpath("//input[@id='weight']")).sendKeys(weight);
203		driver.findElement(By.xpath("//input[@id='distance']")).sendKeys(distance);
204		driver.findElement(By.xpath("//button[@id='submit']")).click();
205	}
206	@Then("^The text \"([^\"]*)\" should be displayed$")
207	public void validateResult(String message) {
208		//Please fill the required codes
209		String actual = driver.findElement(By.xpath("//div[@id='result']")).getText();
210		//Assert.assertTrue(text.contains(Message));
211		Assert.assertEquals(actual, message);
212		driver.quit();
213	}
214}
215
216---noDiscountstepdefiniton.java---
217package stepDefinition;
218import java.util.concurrent.TimeUnit;
219import org.junit.Assert;
220import org.openqa.selenium.By;
221import org.openqa.selenium.WebDriver;
222import org.openqa.selenium.chrome.ChromeDriver;
223import org.openqa.selenium.firefox.FirefoxDriver;
224import org.openqa.selenium.firefox.FirefoxOptions;
225import org.openqa.selenium.firefox.FirefoxProfile;
226import org.openqa.selenium.firefox.FirefoxBinary;
227import cucumber.api.java.en.Given;
228import cucumber.api.java.en.Then;
229import cucumber.api.java.en.When;
230public class NodiscountStepDefinition {
231	WebDriver driver;
232	String text;
233	@Given("^User navigates to DATAX shipping company home$")
234	public void setUp() {
235		System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
236    	FirefoxBinary firefoxBinary = new FirefoxBinary();
237    	firefoxBinary.addCommandLineOptions("--headless");
238        FirefoxProfile profile=new FirefoxProfile();
239    	FirefoxOptions firefoxOptions = new FirefoxOptions();
240    	firefoxOptions.setBinary(firefoxBinary);
241    	firefoxOptions.setProfile(profile);
242        driver=new FirefoxDriver(firefoxOptions);
243		driver.get("https://webapps.tekstac.com/CompanyOffersDiscount/");
244		System.out.println("Application is launched");
245	}
246	@When("^User enters \"([^\"]*)\" and \"([^\"]*)\"$")
247	public void testNodiscount(String weight, String distance) {
248		//Please fill the required codes
249		driver.findElement(By.xpath("//input[@id='weight']")).sendKeys(weight);
250		driver.findElement(By.xpath("//input[@id='distance']")).sendKeys(distance);
251		driver.findElement(By.xpath("//button[@id='submit']")).click();
252	}
253	@Then("^The text \"([^\"]*)\" should be present$")
254	public void validateResult(String message) {
255		//Please fill the required codes
256		String actual = driver.findElement(By.xpath("//div[@id='result']")).getText();
257		//Assert.assertTrue(text.contains(Message));
258		Assert.assertEquals(actual, message);
259		driver.quit();
260	}
261}
262	
263--L2C4--
264---stepDefinition.java---
265package stepDefinition;
266import org.openqa.selenium.By;
267import org.openqa.selenium.WebDriver;
268import org.openqa.selenium.chrome.ChromeDriver;
269import org.openqa.selenium.firefox.FirefoxDriver;
270import org.openqa.selenium.firefox.FirefoxOptions;
271import org.openqa.selenium.firefox.FirefoxProfile;
272import org.openqa.selenium.firefox.FirefoxBinary;
273import cucumber.api.PendingException;
274import cucumber.api.java.After;
275import cucumber.api.java.Before;
276import cucumber.api.java.en.Given;
277import cucumber.api.java.en.Then;
278import cucumber.api.java.en.When;
279import org.junit.*;
280
281public class StepDefinition {
282	WebDriver driver;
283	public static String result; 
284	public static String weights;
285	public static String trnsmode;
286	@Before
287	public void setUp(){
288		System.setProperty("webdriver.gecko.driver", "/usr/bin/geckodriver");
289    	FirefoxBinary firefoxBinary = new FirefoxBinary();
290    	firefoxBinary.addCommandLineOptions("--headless");
291        FirefoxProfile profile=new FirefoxProfile();
292    	FirefoxOptions firefoxOptions = new FirefoxOptions();
293    	firefoxOptions.setBinary(firefoxBinary);
294    	firefoxOptions.setProfile(profile);
295        driver=new FirefoxDriver(firefoxOptions);
296	}
297	@Given("^I have navigated to shipping application home page$")
298	public void loadUrl(){
299		driver.get("https://webapps.tekstac.com/CostCalculation/");	    
300		System.out.println("Application is launched");
301	}
302	@When("^I enter \"(.*)\" and select \"(.*)\" Transport mode$")
303	public void testCalculateCost(String weight, String transportmode){
304		//Please fill the required codes
305		weights = weight;
306		trnsmode = transportmode;
307		driver.findElement(By.id("weight")).clear();
308        driver.findElement(By.id("weight")).sendKeys(weight);
309        driver.findElement(By.id(trnsmode)).click();
310        driver.findElement(By.id("calculate")).click();
311		result = driver.findElement(By.id("result")).getText();		
312	}
313	@Then("^I validate the message with total shipping cost$")
314	public void validateResult(){
315		//Please fill the required codes
316		if (weights.equalsIgnoreCase("100") && trnsmode.equalsIgnoreCase("air")) 
317		{
318			Assert.assertEquals("Dear Customer, your total shipping cost is $100", result);
319        } 
320        if (weights.equalsIgnoreCase("100") && trnsmode.equalsIgnoreCase("road"))
321        {
322			Assert.assertEquals("Dear Customer, your total shipping cost is $50", result);
323        } 
324        if (weights.equalsIgnoreCase("100") && trnsmode.equalsIgnoreCase("ship")) 
325        {
326			Assert.assertEquals("Dear Customer, your total shipping cost is $70", result);
327        }
328	}
329	@After
330	public void tearDown(){
331		driver.quit();
332	}
333}
334
335---shipping.java---
336#Please Do not change Feature Templet
337Feature: Calculating Trasportation cost
338#Please Do not change Scenario Outline Templet
339Scenario: Calculate Shipping Cost by air
340#Please Do not change Given Templet
341Given I have navigated to shipping application home page
342When I enter "100" and select "Air" Transport mode
343#Please fill the Required code as per the Problem statement
344#Please Do not change Scenario Outline Templet
345Scenario: Calculate Shipping Cost by ship
346#Please Do not change Given Templet
347Given I have navigated to shipping application home page
348When I enter "100" and select "Ship" Transport mode 
349#Please fill the Required code as per the Problem statement
350#Please Do not change Scenario Outline Templet
351Scenario: Calculate Shipping Cost by road
352#Please Do not change Given Templet
353Given I have navigated to shipping application home page
354When I enter "100" and select "Road" Transport mode
355#Please fill the Required code as per the Problem statement
356
Full Screen
copy
1package com.iselsoft.easyium;
2
3import org.openqa.selenium.Capabilities;
4import org.openqa.selenium.firefox.FirefoxBinary;
5import org.openqa.selenium.firefox.FirefoxOptions;
6import org.openqa.selenium.firefox.FirefoxProfile;
7
8public class FirefoxDriver extends WebDriver {
9
10    public FirefoxDriver() {
11        super(new org.openqa.selenium.firefox.FirefoxDriver());
12    }
13
14    public FirefoxDriver(FirefoxOptions options) {
15        super(new org.openqa.selenium.firefox.FirefoxDriver(options));
16    }
17
18    public FirefoxDriver(FirefoxBinary binary) {
19        super(new org.openqa.selenium.firefox.FirefoxDriver(binary));
20    }
21    
22    public FirefoxDriver(FirefoxProfile profile) {
23        super(new org.openqa.selenium.firefox.FirefoxDriver(profile));
24    }
25
26    public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile) {
27        super(new org.openqa.selenium.firefox.FirefoxDriver(binary, profile));
28    }
29
30    public FirefoxDriver(Capabilities desiredCapabilities) {
31        super(new org.openqa.selenium.firefox.FirefoxDriver(desiredCapabilities));
32    }
33
34    public FirefoxDriver(Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
35        super(new org.openqa.selenium.firefox.FirefoxDriver(desiredCapabilities, requiredCapabilities));
36    }
37
38    public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, Capabilities capabilities) {
39        super(new org.openqa.selenium.firefox.FirefoxDriver(binary, profile, capabilities));
40    }
41
42    public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, Capabilities desiredCapabilities, Capabilities requiredCapabilities) {
43        super(new org.openqa.selenium.firefox.FirefoxDriver(binary, profile, desiredCapabilities, requiredCapabilities));
44    }
45    
46    @Override
47    public WebDriverType getWebDriverType() {
48        return WebDriverType.FIREFOX;
49    }
50}
51
Full Screen
copy
1package javaConcepts;
2
3import org.openqa.selenium.WebDriver;
4import org.openqa.selenium.firefox.FirefoxBinary;
5import org.openqa.selenium.firefox.FirefoxDriver;
6import org.openqa.selenium.firefox.FirefoxOptions;
7
8public class FirefoxHeadless {
9
10	public static void main(String[] args) {
11		
12		FirefoxBinary firefoxBinary = new FirefoxBinary();
13		firefoxBinary.addCommandLineOptions("--headless");
14		System.setProperty("webdriver.gecko.driver", "C:\\Users\\pkshank\\eclipse-workspace\\Automation_Concepts\\Browser_Drivers\\geckodriver.exe");
15		FirefoxOptions fo = new FirefoxOptions();
16		fo.setBinary(firefoxBinary);
17		WebDriver driver = new FirefoxDriver(fo);
18		driver.get("http://www.imdb.com");
19		System.out.println(driver.getTitle());
20		
21		
22
23	}
24
25}
26
Full Screen
copy
1System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
2
Full Screen
copy
1    <dependency>
2    <groupId>org.seleniumhq.selenium</groupId>
3    <artifactId>selenium-java</artifactId>
4    <version>3.141.59</version>
5    </dependency> 
6
Full Screen
copy
1my recommendation is 
2
3    ===> switch to firefox version 50.0 [latest One] , 
4
5    ===> download the gecko driver from [.](https://github.com/mozilla/geckodriver/releases)  and 
6
7    ===> Selenium version 3.0.1
8     <dependency>
9                <groupId>org.seleniumhq.selenium</groupId>
10                <artifactId>selenium-java</artifactId>
11                <version>3.0.1</version>
12     </dependency>
13
14    ==> On your Code 
15private WebDriver driver;
16System.setProperty("webdriver.gecko.driver", "PATH to GECKO DRIVER");
17        driver = new FirefoxDriver();
18
19    and yes you see the below output in your console :
20
21
22    Dec 17, 2016 6:40:45 PM org.openqa.selenium.remote.ProtocolHandshake createSession
23    INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
24    14819XXXXXXX5   mozprofile::profile INFO    Using profile path C:\Users\User\AppData\Local\XXXXX\rust_XXXprofile.OXXXXXXXXXXX7S
25    148XXXXXXXXX0   geckodriver::marionette INFO    Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
26    148XXXXXXXXX1   geckodriver::marionette INFO    Connecting to Marionette on localhost:XXXXXXX
27    148198XXXX077   Marionette  INFO    Listening on port 53532
28    Dec 17, 2016 6:40:55 PM org.openqa.selenium.remote.ProtocolHandshake createSession
29    INFO: Detected dialect: W3C
30    [Child 4104] ###!!! ABORT: Aborting on channel error.: file c:/builds/moz2_slave/m-rel-w32-00000000000000000000/build/src/ipc/glue/MessageChannel.cpp, line XXXX
31    Dec 17, 2016 6:41:13 PM org.openqa.selenium.os.UnixProcess destroy
32
Full Screen
copy
1    <dependency>
2        <groupId>org.seleniumhq.selenium</groupId>
3        <artifactId>selenium-java</artifactId>
4        <version>2.43.1</version>
5    </dependency>   
6
Full Screen
copy
1    <dependency>
2        <groupId>org.seleniumhq.selenium</groupId>
3        <artifactId>selenium-firefox-driver</artifactId>
4        <version>2.43.1</version>
5    </dependency>
6
7    <dependency>
8        <groupId>org.seleniumhq.selenium</groupId>
9        <artifactId>selenium-support</artifactId>
10        <version>2.43.1</version>
11    </dependency>   
12
13    <dependency>
14        <groupId>org.seleniumhq.selenium</groupId>
15        <artifactId>selenium-api</artifactId>
16        <version>2.43.1</version>
17    </dependency>
18
19    <dependency>
20        <groupId>org.apache.commons</groupId>
21        <artifactId>commons-lang3</artifactId>
22        <version>3.0</version>
23    </dependency>
24
25    <dependency>
26        <groupId>org.apache.httpcomponents</groupId>
27        <artifactId>httpclient</artifactId>
28        <version>4.3.5</version>
29    </dependency>
30
Full Screen
copy
1<dependency>
2    <groupId>org.seleniumhq.webdriver</groupId>
3    <artifactId>selenium-firefox-driver</artifactId>
4    <version>2.XX.X</version>
5</dependency>
6
7<dependency>
8    <groupId>org.seleniumhq.selenium</groupId>
9    <artifactId>selenium-server</artifactId>
10    <version>2.XX.X</version>
11</dependency> 
12
Full Screen
copy
1  System.setProperty("webdriver.chrome.driver","yourplace\chromedriver.exe");
2  WebDriver driver = new ChromeDriver();
3
Full Screen
copy
1System.setProperty("webdriver.gecko.driver", "D:\\Katalon_Studio_Windows_64-5.10.1\\configuration\\resources\\drivers\\firefox_win64\\geckodriver.exe");
2        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
3        capabilities.setCapability("marionette", true);
4        WebDriver driver = new FirefoxDriver(capabilities);
5        DriverFactory.changeWebDriver(driver)
6
Full Screen
copy
1java -jar selenium-server-standalone-2.53.1.jar -Dwebdriver.firefox.bin="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
2
Full Screen
copy
1        var opt = new FirefoxOptions
2        {
3            BrowserExecutableLocation = @"c:\program files\mozilla firefox\firefox.exe"
4        };
5        var driver = new FirefoxDriver(opt);
6
Full Screen
copy
1File pathToBinary = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
2FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
3FirefoxProfile firefoxProfile = new FirefoxProfile();
4System.setProperty("webdriver.gecko.driver","C:\\Users\\Downloads\\selenium-java-3.0.1\\geckodriver.exe");       
5WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
6
Full Screen
copy
1File pathBinary = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
2FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);   
3DesiredCapabilities desired = DesiredCapabilities.firefox();
4FirefoxOptions options = new FirefoxOptions();
5desired.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options.setBinary(firefoxBinary));
6
Full Screen
copy
1System.setProperty("webdriver.gecko.driver","D:\\Workspace\\demoproject\\src\\lib\\geckodriver.exe");
2File pathBinary = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
3FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);   
4DesiredCapabilities desired = DesiredCapabilities.firefox();
5FirefoxOptions options = new FirefoxOptions();
6desired.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options.setBinary(firefoxBinary));
7WebDriver driver = new FirefoxDriver(options);
8driver.get("https://www.google.co.in/");
9
Full Screen
copy
1File pathBinary = new File("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
2FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
3FirefoxProfile firefoxProfile = new FirefoxProfile();       
4WebDriver driver = new FirefoxDriver(firefoxBinary, firefoxProfile);
5
Full Screen
copy
1java -jar "selenium-server-standalone-2.2.0.jar"
2 -Dwebdriver.firefox.bin="C:\FirefoxCollection\Mozilla Firefox 36.0\firefox.exe"
3
Full Screen
copy
1File pathToBinary = new File("C:\\user\\Programme\\FirefoxPortable\\App\\Firefox\\firefox.exe");
2FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
3FirefoxProfile firefoxProfile = new FirefoxProfile();       
4WebDriver driver = new FirefoxDriver(ffBinary,firefoxProfile);
5
Full Screen
copy
1Browser/firefox -marionette
2
Full Screen
copy
1from marionette import Marionette
2client = Marionette('localhost', port=2828);
3client.start_session()
4
Full Screen
copy
1url='http://mozilla.org'
2client.navigate(url);
3
Full Screen
copy
1package qa2all;
2
3import java.io.File;
4import java.util.concurrent.TimeUnit;
5
6import org.junit.After;
7import org.junit.Before;
8import org.junit.Test;
9import org.openqa.selenium.WebDriver;
10import org.openqa.selenium.firefox.FirefoxBinary;
11import org.openqa.selenium.firefox.FirefoxDriver;
12import org.openqa.selenium.firefox.FirefoxProfile;
13
14
15public class HTMLUnit {
16    private WebDriver driver;
17    private String baseUrl;
18    private StringBuffer verificationErrors = new StringBuffer();
19
20    @Before
21    public void setUp() throws Exception {
22        //driver = new HtmlUnitDriver();    
23        //driver = new FirefoxDriver();
24        String torPath = "/home/user/Dropbox/Data/TorBrowser/Linux/32/start-tor-browser";
25        String profilePath = "/home/user/Dropbox/Data/TorBrowser/Linux/32/TorBrowser/Data/Browser/profile.default/";
26        FirefoxProfile profile = new FirefoxProfile(new File(profilePath));
27        FirefoxBinary binary = new FirefoxBinary(new File(torPath));
28        driver = new FirefoxDriver(binary, profile);        
29        baseUrl = "https://qa2all.wordpress.com";
30        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
31    }
32
33    @Test
34    public void testUntitled() throws Exception {
35        driver.get(baseUrl + "/");
36
37    }
38
39    @After
40    public void tearDown() throws Exception {
41        driver.quit();
42        String verificationErrorString = verificationErrors.toString();
43        if (!"".equals(verificationErrorString)) {
44            fail(verificationErrorString);
45        }
46    }
47
48    private void fail(String verificationErrorString) {
49        // TODO Auto-generated method stub
50
51    }
52}
53
Full Screen
copy
1String torPath = "/Volumes/DATA/Downloads/Tor.app/Contents/MacOS/TorBrowser.app/Contents/MacOS/firefox";
2String profilePath = "/Users/mimitantono/Library/Application Support/Firefox/Profiles/1vps9kas.default-1384778906995";
3FirefoxProfile profile = new FirefoxProfile(new File(profilePath));
4FirefoxBinary binary = new FirefoxBinary(new File(torPath));
5FirefoxDriver driver = new FirefoxDriver(binary, profile);
6driver.get("http://www.google.com/webhp?complete=1&hl=en");
7
Full Screen
copy
1String torPath = "..\\Tor Browser\\Browser\\firefox.exe";
2String profilePath = "..\\Tor Browser\\Data\Browser\\profile.default";
3FirefoxProfile profile = new FirefoxProfile(new File(profilePath));
4FirefoxBinary binary = new FirefoxBinary(new File(torPath));
5FirefoxDriver driver = new FirefoxDriver(binary, profile);
6driver.get("http://www.google.com");
7
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)