【问题标题】:Webdriverio v7 remote selenium gridWebdriverio v7 远程硒网格
【发布时间】:2021-05-17 16:21:37
【问题描述】:

如何使用 Intranet Selenium Grid 运行 webdriver-io v7 测试?根据公司政策,Intranet Selenium Grid 是唯一的选择吗?我可以在 Webdriverio 服务中找到独立的 selenium、chrome 驱动程序和一些云服务,但不能找到内部公司 Selenium 网格实例

【问题讨论】:

  • 您是否在问如何在内部硒网格上运行测试?
  • 是的,如果您指的是内部 selenium Grid,可以在公司内部访问,但不能从公共互联网访问
  • 是的。这就是我的意思。
  • 您有什么具体问题吗?

标签: selenium-grid webdriver-io


【解决方案1】:

即使我也面临同样的问题。以下步骤对我有用!

>  hostname: 'selenium.company.internal',
>     port: <number>,
>     path: '/wd/hub/',
>     protocol: 'https',

在 wdio.conf.js 文件中添加上述值。

  • 从你的 package.json 中移除 wdio-chromedriver-service 依赖 文件。
  • 执行npm inpm ci
  • 运行你的测试(npm run test 在我的 案例)

轰!您的测试执行将在网格中开始

【讨论】:

    【解决方案2】:

    不需要像 Selenium Standalone Service 或 ChromDriver 服务这样的额外 webdriverio 服务。需要什么正确的 wdio.conf.js 或 wdio.conf.ts 。重要字段是主机名、端口、路径、协议和功能。

    export const config: WebdriverIO.Config = {
        //
        // ====================
        // Runner Configuration
        // ====================
        //
        // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
        // on a remote machine).
        runner: 'local',
        //
        // =====================
        // Server Configurations
        // =====================
        // Host address of the running Selenium server. This information is usually obsolete as
        // WebdriverIO automatically connects to localhost. Also, if you are using one of the
        // supported cloud services like Sauce Labs, Browserstack, Testing Bot or LambdaTest you don't
        // need to define host and port information because WebdriverIO can figure that out
        // according to your user and key information. However, if you are using a private Selenium
        // backend you should define the host address, port, and path here.
        //
        hostname: 'selenium.company.internal',
        port: <number>,
        path: '/wd/hub/',
        protocol: 'https',
    

    ........

    能力:[{

        // maxInstances can get overwritten per capability. So if you have an in-house Selenium
        // grid with only 5 firefox instances available you can make sure that not more than
        // 5 instances get started at a time.
        'maxInstances': 5,
        'browserName': 'chrome',
        'acceptInsecureCerts': true,
        // If outputDir is provided WebdriverIO can capture driver session logs
        // it is possible to configure which logTypes to include/exclude.
        // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
        // excludeDriverLogs: ['bugreport', 'server'],
        'goog:chromeOptions': {
            'args': [
                // Runs Chrome in headless mode.
                "--headless",
                // Temporarily needed if running on Windows.
                "--disable-gpu",
                "--window-size=2000,1024",
                // dont show the 'this browser is controlled by software' bar
                "--disable-infobars"
            ]
        }
    }],
    

    【讨论】:

      【解决方案3】:

      在配置文件中更改它。 在网格中运行时

      services: [],
      hostname: your.domain.without.http.and.without.port,
      port: 4444,
      path: '/wd/hub/',
      protocol: 'http',
      

      在本地运行时

      services:  ['chromedriver'],
      

      在本地运行中,主机名、端口、路径和协议可以是任何值或被删除,因为框架不会获取该值。 需要安装依赖“wdio-chromedriver-service”,因为它对于本地运行是必不可少的。

      【讨论】:

        猜你喜欢
        • 2018-07-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-01
        • 2018-09-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多