1

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": "demo@email.com",
        "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

jtayawa
  • 13
  • 3

1 Answers1

0

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.

pavelsaman
  • 7,399
  • 1
  • 14
  • 32
  • Thanks for the answer @pavelsaman. I was thinking of `globals` and `demo_site` is on the same level. Will try on this part. – jtayawa Jul 20 '20 at 11:51
  • Sure, let me know then. I've tried with your example on my side, so it should work with the changed line. If it works for you, you can then mark the answer as a solution for your question. – pavelsaman Jul 20 '20 at 11:58
  • 1
    It worked on moving the `demo_site` inside the `globals` which was weird. "globals" : { "demo_site" : "fake.site.com", } – jtayawa Jul 21 '20 at 03:07
  • Actually, that's correct like this. I overlooked that in my amswers, although I already tried it with `demo_site` inside `globals`. I think this is the way it's meant to be used. – pavelsaman Jul 21 '20 at 04:53