Reputation: 25
this (Selenium python) function clicking on Follow buttons, but also clicking on Following buttons (because Following also contains Follow). How to prevent it? I need full match (Follow only). thank you
buttons = driver.find_elements_by_xpath("//button[contains(.,'Follow')]")
Upvotes: 1
Views: 47
Reputation: 33384
Try below xpath.The first one give you exact match and then second one truncate the space if they have.
//button[text()='Follow']
OR
//button[normalize-space(.)='Follow']
Code:
buttons = driver.find_elements_by_xpath("//button[text()='Follow']")
Upvotes: 1