Nightwatch: elementIdElements doesn't work as expected

Created on 20 Jan 2019  路  4Comments  路  Source: nightwatchjs/nightwatch

version: [email protected]

I am not sure if I misunderstand elementIdElements command. But I think it could be an issue.

Following code can find one element from it's parent correctly:

browser.elementIdElement('some-element-id', 'css selector', 'a', result => {
  /*
  result is:
  {
    sessionId: 'f6a6ee0a67af5994214cd1bcb128b2cb',
    status: 0,
    value: { ELEMENT: '0.6004867345005469-6' }
  }
  */
);

But following code can't find elements from it's parent as expected:

browser.elementIdElements('some-element-id', 'css selector', 'a', result => {
  /*
  Response body:
  {
    sessionId: '9bb0d78ba88319b5b55b3df25c0b95e6',
    status: 0,
    value:
      [ { ELEMENT: '0.8921189491374937-7' },
        { ELEMENT: '0.8921189491374937-8' },
        { ELEMENT: '0.8921189491374937-9' },
        { ELEMENT: '0.8921189491374937-10' } ]
  }
  */

  /*
  BUT result is:
  {
    status: 0,
    value: '0.8921189491374937-7'
  }

  NOT
  {
    status: 0,
    value: [ { ELEMENT: '0.8921189491374937-7' },
        { ELEMENT: '0.8921189491374937-8' },
        { ELEMENT: '0.8921189491374937-9' },
        { ELEMENT: '0.8921189491374937-10' } ]
  }
  */
});

Thanks.
Gary

bug

Most helpful comment

Seeing the same issue. It appears that this is not performing a multi-element search. In addition to the findings above, I'm seeing this message printed to the log -> "Warning: More than one element (51) found for..."

All 4 comments

Seeing the same issue. It appears that this is not performing a multi-element search. In addition to the findings above, I'm seeing this message printed to the log -> "Warning: More than one element (51) found for..."

Yea, this is quite the bummer.

this.api.elementIdElements(elementId, 'xpath', 'td[contains(@class, "td-data-table-cell")]',  cb);
{ 
  sessionId: 'fc813b0cb293bba5349ed0a30e50cf36',
  status: 0,
  value: 'Really Long Name That Goes On And On' 
}
Warning: More than one element (6) found for <td[contains(@class, "td-data-table-cell")]> with 
selector: "td[contains(@class, "td-data-table-cell")]". Only the first one will be used.`

I would have assumed it would work similarly to this.api.elements() where that does return a full list of elements matching the selector.

This has to be a bug. We upgraded from a 0.x version of Nightwatch to 1.0.18 and were previously using .elementIdElements to get a list of elements.

From a design point of view: why even have .elementIdElement and .elementIdElements if both do the same thing?

Also from the docs of a function in lib/element/element.js:

// @param {Array} resultElements Array of WebElement JSON objectsreturned from a call to elements() or elementIdElements().

This is fixed in v1.1.9

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manjero picture manjero  路  4Comments

davecranwell picture davecranwell  路  3Comments

antogyn picture antogyn  路  4Comments

dakebl picture dakebl  路  4Comments

betweenbrain picture betweenbrain  路  4Comments