首页 > 解决方案 > 在 selenium python 中,我只点击第二个按钮,假设有 3 个相同的按钮

问题描述

所以我正在自动化一个过程,一个网页上有 3 个相同的按钮。但是,我只想单击第二个按钮。反正我能做到吗?

这是按钮的代码”:

expandButtons = driver.find_elements_by_xpath("//div[@class='expand-collapse']") 

标签: pythonseleniumselenium-webdriverselenium-chromedriver

解决方案


expandButtons[1].click将单击第二个按钮。


推荐阅读