0

我正在尝试使用 Firefox 在 Amazon Linux 上运行 nodeJs (node v 8.8.1) 自动化测试。由于 Amazon Linux 的一些限制,实际运行的最新版本的 firefox taht 是 41。下面是我的 Firefox 和 Amazon 版本...

[myuser@mymachine ~]$ firefox -v
Mozilla Firefox 41.0
[myuser@mymachine ~]$ uname -a
Linux ip-33-22-3-77 4.9.51-10.52.amzn1.x86_64 #1 SMP Fri Sep 29 01:16:19 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

我的问题是,我使用哪个版本的 Geckodriver 与此版本的 Firefox 兼容?使用最新版本,我们在尝试生成 Firefox 窗口时遇到错误,并且路径中没有壁虎驱动程序,我们会收到错误

/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354
    throw Error(
    ^

Error: The geckodriver executable could not be found on the current PATH. Please download the latest version from https://github.com/mozilla/geckodriver/releases/ and ensure it can be found on your PATH.
    at findGeckoDriver (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354:11)
    at new ServiceBuilder (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:446:22)
    at Function.createSession (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:516:21)
    at createDriver (/home/jboss/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/home/jboss/node_modules/selenium-webdriver/index.js:645:16)
    at Object.<anonymous> (/home/jboss/.jenkins/workspace/subco/automated-tests/nodejs/js/js-FF/driver.js:9:73)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354
    throw Error(
    ^

Error: The geckodriver executable could not be found on the current PATH. Please download the latest version from https://github.com/mozilla/geckodriver/releases/ and ensure it can be found on your PATH.
    at findGeckoDriver (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354:11)
    at new ServiceBuilder (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:446:22)
    at Function.createSession (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:516:21)
    at createDriver (/home/jboss/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/home/jboss/node_modules/selenium-webdriver/index.js:645:16)
    at Object.<anonymous> (/home/jboss/.jenkins/workspace/subco/automated-tests/nodejs/js/js-FF/driver.js:9:73)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354
    throw Error(
    ^

Error: The geckodriver executable could not be found on the current PATH. Please download the latest version from https://github.com/mozilla/geckodriver/releases/ and ensure it can be found on your PATH.
    at findGeckoDriver (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354:11)
    at new ServiceBuilder (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:446:22)
    at Function.createSession (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:516:21)
    at createDriver (/home/jboss/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/home/jboss/node_modules/selenium-webdriver/index.js:645:16)
    at Object.<anonymous> (/home/jboss/.jenkins/workspace/subco/automated-tests/nodejs/js/js-FF/driver.js:9:73)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354
    throw Error(
    ^

Error: The geckodriver executable could not be found on the current PATH. Please download the latest version from https://github.com/mozilla/geckodriver/releases/ and ensure it can be found on your PATH.
    at findGeckoDriver (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:354:11)
    at new ServiceBuilder (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:446:22)
    at Function.createSession (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:516:21)
    at createDriver (/home/jboss/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/home/jboss/node_modules/selenium-webdriver/index.js:645:16)
    at Object.<anonymous> (/home/jboss/.jenkins/workspace/subco/automated-tests/nodejs/js/js-FF/driver.js:9:73)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
ERROR: Maven JVM terminated unexpectedly with exit code 137

编辑:根据答案,我删除并重新安装了 Selenium 2.53 驱动程序...

npm uninstall selenium-webdriver
npm install selenium-webdriver@2.53

但现在我遇到了一个新错误......

Error: The wires executable could not be found on the current PATH. Please download the latest version from https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver and ensure it can be found on your PATH.
    at findWires (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:261:11)
    at createWiresService (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:285:15)
    at new Driver (/home/jboss/node_modules/selenium-webdriver/firefox/index.js:355:21)
    at Builder.build (/home/jboss/node_modules/selenium-webdriver/builder.js:467:16)
    at Object.<anonymous> (/home/jboss/.jenkins/workspace/subco/automated-tests/nodejs/js/js-FF/driver.js:9:73)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
/home/jboss/node_modules/selenium-webdriver/firefox/index.js:261
4

3 回答 3

0

我认为,您收到该错误是因为它要求geckodriver.exe. Geckodriver 在0.8.0 版本之前最初被称为 wires 。请在您的系统路径上提供 exe。

您可以通过将此属性设置为 false 来使用 selenium 3(我认为这是最好的选择,因为它是最新的)而不提供壁虎(早期的 FF 版本)

System.setProperty("webdriver.firefox.marionette", "false");

或者做

FirefoxOptions options = new FirefoxOptions()
  .setLegacy(true);

您可能需要寻找 nodejs 等效项。

编辑: 这里是 js 版本

let options = new firefox.Options().useGeckoDriver(false); 

当您执行上述操作时,FF 将使用其旧版扩展而不是 gecko

正如这里提到的

如果您想了解更多关于木偶客户端-服务器-壁虎交互的信息,可以在这里查看相关问题。

于 2017-11-30T22:02:30.527 回答
0

由于firefox版本是41,使用selenium 2很好,如果我们使用selenium 3意味着最新,我们需要不支持这个旧版本的gecko。

我正在使用 selenium 2,因为它具有 firefox 依赖项http://selenium-release.storage.googleapis.com/index.html?path=2.53/以及最新的 chrome 和 IE 驱动程序,以使用最新的 chrome 和 IE 浏览器。

于 2017-11-30T16:52:06.493 回答
0

事实证明,Amazon Linux Firefox 41 的正确版本是 selenium-webdriver 2.50,不多不少(尝试了 2.48 和 2.53,但都失败了)。

于 2017-12-01T14:42:14.803 回答