我使用的是火狐59.0.2版和selenium 3.6.0版,我的任务是在启用了扩展的火狐中运行headless .my。我一次只能执行一个任务,即我可以运行headless或午餐firefox with extension,但我无法同时执行这两个任务,因为在特定的jar .how中同时不支持这两个任务
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");
发布于 2018-04-16 22:19:19
像这样使用firefoxOptions.setProfile(profile);
:
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);
https://stackoverflow.com/questions/49858996
复制相似问题