3

I'm using Page Object in Nightwatch.js. I want to simulate login behavior, so the commands in page object module is:

commands: [{
        setValueToHere(selector,value) {
           return this
                .setValue(selector,value)
        },
        clickTheButton() {
            return this
                .click('@submitButton');
    }
    }]

when I call it in my test the test runs "weird": the pop-up browser runs fine, it behave exact like how users do on the web page. However, the result in the terminal keeps running these lines.

Error while running .locateMultipleElements() protocol action: invalid selector: An invalid or illegal selector was specified

Error while running .locateMultipleElements() protocol action: invalid selector: An invalid or illegal selector was specified

...

This does not happen often, sometimes with runs smoothly but sometimes the error keeps running. Is it because of my internet connection? Has anyone meet this situation?

Community
  • 1
  • 1
Oanh Đỗ
  • 31
  • 1
  • 3

1 Answers1

0

There are two problems. First, your slow internet connection, second, your element identified with XPath.

Css selector should fix the problem.

For www.google.com, for the logo, using the Css selector #hplogo the test passed. Using Xpath, //*[@id="hplogo"] the logo is found, but the test will fail. I found this problem with nightwatch after 2 weeks having the same problem . Have fun.

Surfer
  • 23
  • 7