Skip to content
Advertisement

Difficulty with a locator(using java for selenium)

Complete newbie here…started trying to learn selenium with java this month. Having troubles locating one button, because it seems to lack name id, link and its class is weird looking. Can someone help me write a locator for it? Its an accept cookies button.

<button type="button" class="_908LZ _1pO2V m29-z _4R7G3 _2JFg2" aria-disabled="false" aria-label="Приемане на всички бисквитки" data-qa="privacy-settings-action-info">OK</button>

Advertisement

Answer

You can use either of the xpath option to identify the element.

By.xpath("//button[text()='OK']")

OR

By.xpath("//button[@data-qa='privacy-settings-action-info']")
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement