gpt4 book ai didi

selenium-webdriver - 在 Firefox 或 IE 中使用 Protractor

转载 作者:行者123 更新时间:2023-12-01 23:16:59 30 4
gpt4 key购买 nike

Protractor 在 Chrome 上运行良好,但我无法让它启动 Firefox 或 Internet Explorer。

  • 视窗 7
  • 节点 v6.9.1

  • 摘自 package.json :
    "scripts": {
    ....
    "webdriver-manager-update": "webdriver-manager update --ie",
    "protractor": "protractor protractor.conf.js",
    ...
    },
    ...
    "devDependencies": {
    ...
    "protractor": "5.1.1",
    ...
    }
    protractor.conf.js :
    exports.config = {
    capabilities: {
    browserName: "firefox" // or "internet explorer"
    },
    specs: ["target/e2e/**/*.e2e-spec.js"]
    };

    运行后 npm run webdriver-manager-update , <project-home>\node_modules\protractor\node_modules\webdriver-manager\selenium\包含文件 chromedriver_2.28.exe , geckodriver-v0.15.0.exeIEDriverServer3.3.0.exe .

    运行时 npm run protractor ,我收到一个错误:
    [12:29:45] I/launcher - Running 1 instances of WebDriver
    [12:29:45] I/local - Starting selenium standalone server...
    [12:29:46] I/local - Selenium standalone server started at http://192.168.213.25:62661/wd/hub
    [12:29:46] E/launcher - The path to the driver executable must be set by the webdriver.gecko.driver system property

    (对于 IE,它指的是 webdriver.ie.driver 系统属性)

    经过大量的谷歌搜索,我尝试了以下修复:

    a) 添加 <project-home>\node_modules\protractor\node_modules\webdriver-manager\selenium\到系统环境变量 Path .这似乎没什么区别。

    b) 将以下行添加到 protractor.conf.js :
    seleniumArgs: ["-Dwebdriver.gecko.driver=<project-home>\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.15.0.exe"],

    现在 npm run protractor产量:
    [12:40:35] I/launcher - Running 1 instances of WebDriver
    [12:40:35] I/local - Starting selenium standalone server...
    [12:40:35] E/launcher - Error: Error: Server terminated early with status 1
    at Error (native)
    at earlyTermination.catch.e (<project-home>\node_modules\selenium-webdriver\remote\index.js:252:52)
    at process._tickCallback (internal/process/next_tick.js:103:7)
    [12:40:35] E/launcher - Process exited with error code 100

    (与 IE 的类似行为)

    我的搜索结果表明我不是唯一遇到此问题的人,但不幸的是,我没有找到解决方案。

    最佳答案

    最后我在 answer by Nick Tomlin 中找到了解决方案:

    它不是 seleniumArgs您需要设置,但是localSeleniumStandaloneOpts.jvmArgs .所以,在 protractor.conf.js , 写:

    localSeleniumStandaloneOpts: {
    jvmArgs: ["-Dwebdriver.gecko.driver=<project-home>\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\geckodriver-v0.15.0.exe"]
    },

    (类似于 IE)

    关于selenium-webdriver - 在 Firefox 或 IE 中使用 Protractor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43091493/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com