Skip to content Skip to sidebar Skip to footer

Nightwatch. Click On Element With Text

I have a problem, can`t click on web element having some unique text. I have this structure:
wg-wagon-type__title?

.click('.wg-wagon-type__title')

Unfortunately there isn't a CSS selector that matches on the text of an element. However, nightwatch has the capability to run javascript on the browser via 'api.execute' and that allows you to do string matching.

Alternatively, you could use an xpath selector and use that to match the text

.click("//div[contains(@class, 'wg-wagon-type__title') and text()='Text']")

Post a Comment for "Nightwatch. Click On Element With Text"