如何使用 python selenium 识别此按钮?
How do I identify this button using python selenium?
按钮是 "View All Suggestions" 按钮。
所以我需要这样写:
browser.find_element_by_css_selector("something here").click()
而且不一定要在 css 之前完成。这只是一个例子。什么方法都行。
要单击第一个匹配项,请使用:
browser.find_element_by_xpath('//a//*[contains(text(),"View All Suggestions")]').click()
要点击第 n 次出现,请使用:
elements = browser.find_elements_by_xpath('//a//*[contains(text(),"View All Suggestions")]')
elements[3].click() # <-- Click on the 3rd occurrence if it exists.`
按钮是 "View All Suggestions" 按钮。
所以我需要这样写:
browser.find_element_by_css_selector("something here").click()
而且不一定要在 css 之前完成。这只是一个例子。什么方法都行。
要单击第一个匹配项,请使用:
browser.find_element_by_xpath('//a//*[contains(text(),"View All Suggestions")]').click()
要点击第 n 次出现,请使用:
elements = browser.find_elements_by_xpath('//a//*[contains(text(),"View All Suggestions")]')
elements[3].click() # <-- Click on the 3rd occurrence if it exists.`