Sunday, May 11, 2014

How to open browser with Add Ons using WebDriver

Note- File extension = new File("give here the path of the Add Ons file with use you want to open browser.");

import java.io.File;
import java.io.IOException;

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

public class AddOns {
    public static void main(String[] args) {
        File extension = new File("C:/Users/IBM_ADMIN/Documents/SametimeFileTransfers/firebug-1.12.7-fx.xpi");
        FirefoxProfile profile = new FirefoxProfile();
        try {
            profile.addExtension(extension);
        } catch (IOException e) {
            e.printStackTrace();
        }
        WebDriver driver = new FirefoxDriver(profile);
        driver.get("https://mail.google.com/mail/u/0/#inbox");
       
    }
}

No comments:

Post a Comment