Open firefox with addon in selenium

selenium

The following code will show how we can add firefox addon with selenium

package com.webdriver_06;

import java.io.File;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

public class MyAddon {
	
	public WebDriver driver;
	private String baseUrl;
	
	public static void main(String[] args){
		MyAddon ma = new MyAddon();
		ma.launch_browser();
	}
	public void launch_browser() {
		try{
		baseUrl = "http://google.co.in/";
		
		String firebugFilePath = "F:\\xpi\\firebug.xpi";
		String firepathFilePath = "F:\\xpi\\firepath.xpi";
		
		FirefoxProfile profile = new FirefoxProfile();      
		
		profile.addExtension(new File(firebugFilePath));
		profile.addExtension(new File(firepathFilePath));
		
		driver = new FirefoxDriver(profile);

		driver.get(baseUrl);
		System.out.println("Just open firefox -  with two addin");
		wait(500);
		driver.quit();
		}
		catch (Exception ex)
		{
			ex.getMessage();
		}
	}
}

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *