Selenium、Firefox 和 GeckoDriver
Selenium, Firefox and GeckoDriver
我有一个疑问和一个问题。
问题:
通过使用 Selenium 3.4.0,最新版本的 Firefox 不需要 GeckoDriver 即可进行 运行 测试。因为使用 Firefox 45,我可以 运行 在没有 GeckoDriver 的情况下进行测试,尽管我认为这是必需的。
问题:
我正在尝试使用 Firefox 最新版本 53.0、Selenium 3.4.0 和 GeckoDriver 0.16.0
我将 Firefox 设置为 PATH。我在 class 中如下设置 Gecko 的路径属性:enter image description here
,堆栈跟踪:
1493481035911 geckodriver INFO Listening on 127.0.0.1:32281 1493481036538 geckodriver::marionette INFO Starting browser \?\C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"] 1493481037661 addons.manager ERROR startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no] Stack trace: FileUtils_getDir()@resource://gre/modules/FileUtils.jsm:70 < FileUtils_getFile()@resource://gre/modules/FileUtils.jsm:42 < validateBlocklist()@resource://greJav/amSocdruilpets /eArdrdoorn:M arnageers.ojusrmc:e6:7/1/ g<r es/tmaordtuulpe(s)/@ArdedsoonuMracnea:g/e/rg.rjes/mm,o dluilnees /1A6d5d7o:n MNaSn_aEgReRrO.Rj_sNmO:T_INIT8I3A4L I<Z EsDt:a rAtdudpo(n)M@arneasgoeurr cies: /n/ogtr ei/nmiotdiualleized
s/AddonManager.jsm:3129 < observe()@resource://gre/components/addonManager.js:65
[GFX1]: Potential driver version mismatch ignored due to missing DLLs 0.0.0.0 and 0.0.0.0
1493481041925 Marionette INFO Listening on port 54083
JavaScript error: resource://gre/modules/AddonManager.jsm, line 2570: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@150c158, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@4524411f}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '8c03df6', time: '2017-03-02 09:30:17 -0800'
System info: host: 'DESKTOP-HUOROU4', ip: '192.168.43.167', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:130)
at Test.main(Test.java:11)
让我试着一一解答你的问题:
By using Selenium 3.4.0 what is the latest version of Firefox that doesn't require GeckoDriver to run tests
- 使用 Selenium 3.4.0,您可以在没有 gecko 驱动程序的情况下使用 Mozilla Firefox 47.x。从 Mozilla Firefox 47.x 开始,必须安装 gecko 驱动程序。
使用 Selenium 3.4.0、geckodriver v0.16.1 和 Mozilla Firefox 53.0 这段代码工作正常:
System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(dc);
driver.get("http://google.com/");
此外,如果您在默认 Firefox 配置文件中使用任何扩展,您需要 disable/delete 它们或为您的自动化工作创建一个新的 Firefox 配置文件。
如果这对你有帮助,请告诉我。
我有一个疑问和一个问题。
问题:
通过使用 Selenium 3.4.0,最新版本的 Firefox 不需要 GeckoDriver 即可进行 运行 测试。因为使用 Firefox 45,我可以 运行 在没有 GeckoDriver 的情况下进行测试,尽管我认为这是必需的。
问题:
我正在尝试使用 Firefox 最新版本 53.0、Selenium 3.4.0 和 GeckoDriver 0.16.0
我将 Firefox 设置为 PATH。我在 class 中如下设置 Gecko 的路径属性:enter image description here
,堆栈跟踪:
1493481035911 geckodriver INFO Listening on 127.0.0.1:32281 1493481036538 geckodriver::marionette INFO Starting browser \?\C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"] 1493481037661 addons.manager ERROR startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no] Stack trace: FileUtils_getDir()@resource://gre/modules/FileUtils.jsm:70 < FileUtils_getFile()@resource://gre/modules/FileUtils.jsm:42 < validateBlocklist()@resource://greJav/amSocdruilpets /eArdrdoorn:M arnageers.ojusrmc:e6:7/1/ g<r es/tmaordtuulpe(s)/@ArdedsoonuMracnea:g/e/rg.rjes/mm,o dluilnees /1A6d5d7o:n MNaSn_aEgReRrO.Rj_sNmO:T_INIT8I3A4L I<Z EsDt:a rAtdudpo(n)M@arneasgoeurr cies: /n/ogtr ei/nmiotdiualleized
s/AddonManager.jsm:3129 < observe()@resource://gre/components/addonManager.js:65
[GFX1]: Potential driver version mismatch ignored due to missing DLLs 0.0.0.0 and 0.0.0.0
1493481041925 Marionette INFO Listening on port 54083
JavaScript error: resource://gre/modules/AddonManager.jsm, line 2570: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions@150c158, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile@4524411f}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '8c03df6', time: '2017-03-02 09:30:17 -0800'
System info: host: 'DESKTOP-HUOROU4', ip: '192.168.43.167', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:130)
at Test.main(Test.java:11)
让我试着一一解答你的问题:
By using Selenium 3.4.0 what is the latest version of Firefox that doesn't require GeckoDriver to run tests
- 使用 Selenium 3.4.0,您可以在没有 gecko 驱动程序的情况下使用 Mozilla Firefox 47.x。从 Mozilla Firefox 47.x 开始,必须安装 gecko 驱动程序。使用 Selenium 3.4.0、geckodriver v0.16.1 和 Mozilla Firefox 53.0 这段代码工作正常:
System.setProperty("webdriver.gecko.driver", "C:\Utility\BrowserDrivers\geckodriver.exe"); DesiredCapabilities dc = DesiredCapabilities.firefox(); dc.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(dc); driver.get("http://google.com/");
此外,如果您在默认 Firefox 配置文件中使用任何扩展,您需要 disable/delete 它们或为您的自动化工作创建一个新的 Firefox 配置文件。
如果这对你有帮助,请告诉我。