codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS

Home Page:http://codecept.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Codeceptjs 3.5.12 with Chromedriver and Webdriver helper fails

wslaghekke opened this issue · comments

What are you trying to achieve?

Testing without selenium as described here: https://codecept.io/webdriver/#chromedriver-without-selenium

What do you get instead?

Codeceptjs fails on an error initializing the webdriver connection.

Error: Can't connect to WebDriver.
Error: Failed to create session.
Make sure to set `path: '/'` in your wdio.conf.js!
# paste output here

Details

  • CodeceptJS version: 3.5.12
  • NodeJS Version:
  • Operating System:
  • webdriverio
  • Configuration file:
{
host: localhost,
port: 9515,
browser: 'chrome',
path: '/',
}

This issues is caused by the following if statement inside the Webdriver helper: https://github.com/codeceptjs/CodeceptJS/blame/eb1125b0962beed937ee741eae4ecdbccd6fb033/lib/helper/WebDriver.js#L497

I'm not sure what the correct fix should be, i have worked around the issue for now by using hostname in my config instead of host, hostname seems to be an undocumented option so i'm not sure how stable that workaround is.

hi @wslaghekke so I'm a bit confused, you wanna run with or without selenium?

Without selenium:

Testing Chrome locally is now more convenient than ever. You can define a browser channel, and WebDriver Helper will take care of downloading the specified browser version for you. For example:

{
   helpers: {
     WebDriver : {
       smartWait: 5000,
       browser: "chrome",
       browserVersion: '116.0.5793.0', // or 'stable', 'beta', 'dev' or 'canary'
       restart: false,
       windowSize: "maximize",
       timeouts: {
         "script": 60000,
         "page load": 10000
       }
     }
   }
}

hi @wslaghekke so I'm a bit confused, you wanna run with or without selenium?

Without selenium:

Testing Chrome locally is now more convenient than ever. You can define a browser channel, and WebDriver Helper will take care of downloading the specified browser version for you. For example:

{
   helpers: {
     WebDriver : {
       smartWait: 5000,
       browser: "chrome",
       browserVersion: '116.0.5793.0', // or 'stable', 'beta', 'dev' or 'canary'
       restart: false,
       windowSize: "maximize",
       timeouts: {
         "script": 60000,
         "page load": 10000
       }
     }
   }
}

Without selenium, i start chromedriver manually and point codeceptjs to it, the problem is that chromedriver needs the path to be / but the if-statement in the code hardcodes it to /wd/hub if the host property is set

oh, so you wanna specify the path to the downloaded chromedriver. Or browserVersion: '116.0.5793.0', // or 'stable', 'beta', 'dev' or 'canary' shall help?

No i dont specify a path, i point it to the host and port that chromedriver is already running on so i dont need to point to any binary, or specify a version because chromedriver is already running. If it makes it easier, this is the config part that configures that (that used to work fine before the if-statement was introduced in 3.5.12)

exports.config = {
    tests: './test/**/*_test.js',
    output: './test/output',
    helpers: {
        WebDriver: {
            url: 'http://localhost:8100',
            browser: 'chrome',
            host: 'localhost',
            port: 9515,
            path: '/',
            smartWait: 5000,
            waitForTimeout: 5000,
            keepCookies: false,
            restart: true,
            windowSize: "1080x1920",
            desiredCapabilities: {
                chromeOptions: {
                    args: chromeArgs,
                }
            }
        }
    }
}

Hi @wslaghekke, we are facing the same issue. do you manage to fix the issue?

Hi @wslaghekke, we are facing the same issue. do you manage to fix the issue?

The issue should be fixed in version 3.5.13+ if you still have an issue make sure you have set the path.

If you cant update then a workaround is to configure hostname instead of host

@wslaghekke can you please share with me your configuration?

there is my configuration
helpers: {
WebDriver: {
url: "http://localhost:8070",
browser: "chrome",
host: "localhost",
port: 9515,
path: "/",
windowSize: ${settings.window.width}x${settings.window.height},
waitForTimeout: 20000,
disableScreenshots: true,
desiredCapabilities: {
chromeOptions: {

@AramSol changing host to hostname should fix it if you have the same issue i had.

@wslaghekke still have the issue
image

I use
"codeceptjs": "3.5.14",
"webdriverio": "8.32.3"

is there any thing else i should do before i run the ui
tests?
you mentioned that you run webdriver and point it to the codecept- can you tell me how i can run the webdriver? I though the WebdriverIO take care of it

@AramSol The way i run webdriver manually is the "old" way where you needed to manually start it, if you are not used to doing that then you have a different issue.

@kobenguyent can you support here?