Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python selenium识别这些按钮?_Python_Selenium_Selenium Webdriver_Selenium Chromedriver_Webautomation - Fatal编程技术网

如何使用python selenium识别这些按钮?

如何使用python selenium识别这些按钮?,python,selenium,selenium-webdriver,selenium-chromedriver,webautomation,Python,Selenium,Selenium Webdriver,Selenium Chromedriver,Webautomation,这些蓝色的按钮旁边有十字架,我如何写一行代码来返回所有这些按钮的列表 比如: buttons = browser.find_element_by_css_selector("something here") 或 或者用什么来查找元素。。。这很管用,我看到有多个按钮,大多数都是同一个类的,所以ypu必须使用 然后遍历所有这些 下面是xpath buttons = driver.find_elements_by_xpath("//span[@class='ui_button_icon']") fo

这些蓝色的按钮旁边有十字架,我如何写一行代码来返回所有这些按钮的列表

比如:

buttons = browser.find_element_by_css_selector("something here")


或者用什么来查找元素。。。这很管用,我看到有多个按钮,大多数都是同一个类的,所以ypu必须使用

然后遍历所有这些

下面是xpath

buttons = driver.find_elements_by_xpath("//span[@class='ui_button_icon']")
for button in buttons:
    button.click()    
如果您想单击特定的按钮,您可以使用索引或相对按钮来创建其他元素,如人名

# clicking on 2nd button
driver.find_element_by_xpath("(//span[@class='ui_button_icon'])[2]").click()
这是css

span.ui_button_icon

您可以应用相同的逻辑,使用类型为
nth的

单击第n个元素。请不要发布html图片。使用通过提供的代码片段工具如果您认为此问题已解决,请接受答案,以便我们减少未回答问题的数量:-)
span.ui_button_icon