I am using firefox version-59.0.2 and selenium version -3.6.0 .my task is to run headless in firefox with extension enabled.I am able to do only one task at a time i.e either I am able to run headless or lunch firefox with extension but I am unable to do both at a time because both are not supported at a time in a specific jar .how to do so
System.setProperty("webdriver.firefox.bin", "C:\\Users\\rahul\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
String autoFilePath = "C:\\software\\autoauth-3.1.1-an+fx.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(autoFilePath));
FirefoxDriver driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
WebDriverWait wait=new WebDriverWait(driver, 60);
driver.get("http://www.google.com");
Use firefoxOptions.setProfile(profile);
like this:
System.setProperty("webdriver.firefox.bin", "C:\\Users\\rahul\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, "true");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
String autoFilePath = "C:\\software\\autoauth-3.1.1-an+fx.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(autoFilePath));
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
firefoxOptions.setProfile(profile);
FirefoxDriver driver = new FirefoxDriver(firefoxOptions);