我有一个在 Selenium 2.45.0 中创建的回归包,我最近升级到了 Selenium(selenium-java 3.4.0 和 selenium server 3.7.1)。目前我的系统上有 Firefox ESR v52.3.0。升级到 selenium 3.4.0 window.maximize() 失败并出现以下错误 -
org.openqa.selenium.WebDriverException: Failed to find width field
如果我尝试设置尺寸
driver.manage().window().setSize(new Dimension(1920, 1080));
它给了我以下错误-
org.openqa.selenium.WebDriverException: setWindowRect
我已经设置了 geckodriver 的路径,并使用以下选项设置了 FirefoxProfile,
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", System.getProperty("user.dir") + "\\downloads");
profile.setPreference("browser.helperApps.neverAsk.openFile","text/csv,application/x-msexcel,application/excel,application/x-excel,"
+ "application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv,application/x-msexcel,"
+ "application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
profile.setPreference("browser.download.manager.focusWhenStarting", false);
profile.setPreference("browser.download.manager.useWindow", false);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.closeWhenDone", false);
profile.setPreference("browser.tabs.remote.autostart", false);
profile.setPreference("browser.tabs.remote.autostart.1", false);
profile.setPreference("browser.tabs.remote.autostart.2", false);
profile.setPreference("browser.tabs.remote.force-enable", "false");
请让我知道如何在 Firefox 浏览器 v52.3.0 上最大化窗口。
非常感谢