【发布时间】:2021-10-20 05:46:46
【问题描述】:
【问题讨论】:
-
你能分享那个页面的链接吗?
标签: python html selenium selenium-webdriver selenium-chromedriver
【问题讨论】:
标签: python html selenium selenium-webdriver selenium-chromedriver
为什么不是这样的 xpath 索引:
(//span[@class='player-name'])[1]
或按钮:
//div[contains(@class, 'add-remove-player')]//button[contains(@class,'StyledIconButton')]
这将代表所有这些。
如果您正在寻找第一个:
(//div[contains(@class, 'add-remove-player')]//button[contains(@class,'StyledIconButton')])[1]
第二个将是:
(//div[contains(@class, 'add-remove-player')]//button[contains(@class,'StyledIconButton')])[2]
等等..
在代码中:-
driver.find_element_by_xpath("(//div[contains(@class, 'add-remove-player')]//button[contains(@class,'StyledIconButton')])[1]").click()
其他按钮以此类推。
【讨论】: