[Nightwatch 1.1.9] Unsupported locator strategy

103 views
Skip to first unread message

mart

unread,
May 17, 2019, 4:28:01 AM5/17/19
to NightwatchJs
Hi there,

has someone similar issue?

I try to use execute method, no matter if I have this in command or pages:

.execute(selector => document.querySelector(selector).innerHTML,      
     
[`${body}`], (result) => {
       
this
         
.assert.notEqual(result.value, `${status}`, `---> ${status} <---`);
     
});

and I have an error:

Error while running .executeScript() protocol action: unknown error: Cannot read property 'innerHTML' of null.


Second one is:

Error while running .locateMultipleElements() protocol action: invalid argument: Unsupported locator strategy: //span[normalize-space()="${name}"]

when i try to use

.waitForElementPresent(`//span[normalize-space()="${name}"]`, `Button ${name} presented`)

with xpath strategy.

These problems occurs only in version 1 and above. In Nightwach 0.9.21 everything works perfectly.

I dont have any idea where problem is.

Thanks for response.

Regards,
Mart
Message has been deleted

mart

unread,
May 17, 2019, 4:50:56 AM5/17/19
to NightwatchJs
ok, I know where is a problem. Everything is OK, when I do this way:

leftButton: {
      selector
: '//span[normalize-space()="Analytics"]',
      locateStrategy
: 'xpath',
   
},


and then I apply this selector
leftButton
in
.waitForElementPresent('@leftButton', `Button ${name} presented`)

so I think that this is a Nightwatch bug.

Andrei Rusu

unread,
May 18, 2019, 9:45:46 AM5/18/19
to nightw...@googlegroups.com
To ensure cross-browser compatibility, the specified function should not be in ES6 format (i.e. () => {}).

This syntax is not supported:
.waitForElementPresent(`//span[normalize-space()="${name}"]`, `Button ${name} presented`)

You should either specify the page object element or the locate strategy:
.waitForElementPresent({selector: `//span[normalize-space()="${name}"]`, locateStrategy: 'xpath'}, ...);

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/dcc5ac8d-4bf0-4af0-8218-c424cfc9b204%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages