Search code examples
javascriptselenium-chromedrivernightwatch.jsnightwatch

Nightwatch using chromedriver version 83 returns `undefined` global values on script


Hi to all and this is the first time I'm posting at StackOverflow.

My nightwatch script with a chromedriver version 77 was working before until I've updated to version 83 which throws a string value of undefined from the global variables at nightwatch.conf.js when I used it on my test script.

Here is my nightwatch.conf.js customized environment settings sample configuration;

    "dev" : {
      "product_url" : "https://website.sampledev.com",
      "demo_site" : "fake.site.com",
      "globals" : {
        "email": "[email protected]",
        "password": "FAKEP@ssw0rd"       
      }
    },

Code used: var test_site = browser.demo_site

Inputting the demo_site global variable to the text box of a website. Which I used browser.setValue(`<sample_xpath_here>`,`${test_site}`)

Expected Result: Inside the text box fake.site.com

Actual Result: Inside the text box undefined


Solution

  • It seems that you're missing two parts:

    This line:

    var test_site = browser.demo_site
    

    should become this instead:

    var test_site = browser.globals.demo_site
    

    And demo_site should be inside globals.