【问题标题】:How to change selenium-standalone port number via webdriverio wdio file?如何通过 webdriverio wdio 文件更改 selenium-standalone 端口号?
【发布时间】:2019-12-02 07:52:52
【问题描述】:

我需要更改 selenium 独立服务器默认使用的端口号 (4444)。端口 4444 当前正在使用中,有没有办法通过 wdio 文件更改端口号?

// Test runner services
// Services take over a specific job you don't want to take care of. They enhance
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
services: ['selenium-standalone'],

目前我正在通过以下命令启动 selenium 服务器:

./node_modules/.bin/selenium-standalone start

我也尝试使用以下方法,但没有成功:

./node_modules/.bin/selenium-standalone start -port 7777

运行上述命令仍会尝试在端口 4444 上运行 selenium sever。

【问题讨论】:

    标签: javascript selenium selenium-webdriver webdriver-io


    【解决方案1】:

    要在特定端口上运行selenium-standalone,您应该使用以下语法:

    ./node_modules/.bin/selenium-standalone start -- -port 7777
    

    更改wdi.conf.js中的端口:

    seleniumArgs: {
      seleniumArgs: ["-port", "7777"],
    },
    

    另外,阅读更多关于 wdio 配置文件 here 和 wdio-cli here

    所以,你最终的wdio.conf.js 应该是这样的:

    exports.config = {
      /**
      * server configurations
      */
      services: ['selenium-standalone'],
      port: 7777,
      seleniumArgs: {
        seleniumArgs: ["-port", "7777"],
      },
    }
    

    【讨论】:

    • 谢谢@Yevhen 感谢!
    • 嘿@Yevhen,很抱歉再次打扰您,我可以将 args 添加到列出的 wdio 文件中吗?服务:['selenium-standalone'],seleniumArgs:{ seleniumArgs:[“-port”,“7777”],},
    • 嘿@Gbru!没听懂,能改一下吗?
    • 嘿@Yevhen,目前我正在使用webdriverio (webdriver.io/docs/configurationfile.html) 构建一个框架,你知道如何在wdio 文件中添加seleniumArgs,而不是需要通过命令行传递端口号吗?谢谢
    • 哦,我明白了。我已将其添加到答案中。
    【解决方案2】:
    nodejs webdriver-manager start --seleniumPort 5555
    

    【讨论】:

      猜你喜欢
      • 2021-11-24
      • 1970-01-01
      • 1970-01-01
      • 2020-07-09
      • 1970-01-01
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多