Tolga Ulusoy
Tolga Ulusoy

Reputation: 143

Webdriverio v7 remote selenium grid

How can be webdriver-io v7 Tests run with an intranet Selenium Grid? According to Company policies is the intranet Selenium Grid only option? I can find in Webdriverio services for stand-alone-selenium, chrome driver, and some cloud services but not for an internal Company Selenium Grid Instances

Upvotes: 0

Views: 3944

Answers (3)

Abdullah Nurum
Abdullah Nurum

Reputation: 345

change this in config file. when run in Grid

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

when run in local

services:  ['chromedriver'],

in local run, hostname, port, path and protocol are can be any value or removed, since framework does not pick up this value. Dependency "wdio-chromedriver-service" needs to be installed since it is essential for local run.

Upvotes: 3

D'nesh
D'nesh

Reputation: 11

Even I faced the same issue. Below steps did the trick for me!

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

Add the above values in wdio.conf.js file.

  • Remove wdio-chromedriver-service dependency from your package.json file.
  • Do a npm i or npm ci
  • Run your tests (npm run test in my case)

BOOM! Your test execution will be started in the grid

Upvotes: 1

Tolga Ulusoy
Tolga Ulusoy

Reputation: 143

There is no need an extra webdriverio service like Selenium Standalone Service or ChromDriver service. What is needed the right wdio.conf.js or wdio.conf.ts . Important Fields are hostname, port, path, protocol and capabilities.

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',

........

capabilities: [{

    // 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"
        ]
    }
}],

Upvotes: 0

Related Questions