Selenium python如何通过完全匹配查找按钮
这个(Selenium python)函数可以单击Follow按钮,但也可以单击Follow按钮(因为Follow也包含Follow)。如何预防?我需要完全匹配(只跟随)。多谢各位Selenium python如何通过完全匹配查找按钮,python,selenium,xpath,Python,Selenium,Xpath,这个(Selenium python)函数可以单击Follow按钮,但也可以单击Follow按钮(因为Follow也包含Follow)。如何预防?我需要完全匹配(只跟随)。多谢各位 buttons = driver.find_elements_by_xpath("//button[contains(.,'Follow')]") 试试下面的xpath。第一个会提供精确匹配,然后第二个会截断空格(如果有) //button[text()='Follow'] 或 代码: buttons = dri
buttons = driver.find_elements_by_xpath("//button[contains(.,'Follow')]")
试试下面的xpath。第一个会提供精确匹配,然后第二个会截断空格(如果有)
//button[text()='Follow']
或
代码:
buttons = driver.find_elements_by_xpath("//button[text()='Follow']")
buttons = driver.find_elements_by_xpath("//button[text()='Follow']")