1

The page has 3 buttons with a certain text {text}. I want to be able to click on the first such button.

I tested an xpath on chrome console with the index and that gives out the correct button.

$x("//button[contains(text(), 'sometext')]")[0]

But when I use the exact same xpath as a selector in my nightwatch code, it doesn't seem to find it.

Whereas

selector: '//button[contains(text(), "sometext")]'

does seem to find 3 buttons but when I add [0] (as above) it fails to find the element.

bugsberry
  • 67
  • 1
  • 8

1 Answers1

2

I would try [1] instead of [0]. Xpath is 1 based.

Zoette
  • 1,241
  • 2
  • 18
  • 49