Search code examples
javascriptxpathnightwatch.js

Using XPATH how to find a text and click on button


Bellow is my elements:

Elements

I already know how can I find the id='0' using:

.waitForElementVisible("//form[contains(@id, '0')]"). 

My current problem is how to identify "Excelente Contribuição in "<form". I need to click on text Excelente contruibuição.

I try to use this one to identify the element first, but don't work:

.waitForElementVisible("//form[contains(@id, '0') and contains(text()='Excelente contribuição')]")

Bellow is the button I need to click.

My button


Solution

  • Try to use this XPath to match form by @id and div by label text:

    //form[@id='0']//div[label[normalize-space()='Excelente contribuição']]