Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nightwatch selenium command "elements" returns error about first parameter, even when I pass in a css selector or xpath expression

I'm using nightwatch with selenium for automation testing. I'm trying to use the selenium command 'elements' which takes a css selector or xpath as the first parameter, but keep getting the following error :

Error while running elements command: Please provide any of the following using strings as the first parameter: class name, css selector, id, name, link text, partial link text, tag name or xpath

My use is like this:

module.exports = {
    "My test" : function (browser) {
       ...  
       // want to get all the input elements from the document
       browser.elements('input','name', function(els){
       // of xpath like this
       browser.elements('//input','name', function(els){
       });
    }

}

Any ideas why I'm getting this error? Thanks!

like image 379
Mily Dahlke Avatar asked Sep 19 '14 16:09

Mily Dahlke


1 Answers

Ah I figured it out - the first param is a keyword which has to be one of these (from nightwatch selenium protocols.js) var check = /class name|css selector|id|name|link text|partial link text|tag name|xpath/gi;

So the command needs to look like this : browser.elements('tag name', 'input', function(el){ })

like image 166
Mily Dahlke Avatar answered Oct 03 '22 05:10

Mily Dahlke