【发布时间】:2022-01-15 08:29:11
【问题描述】:
有多个td class='timeslotCellNonPeak",每个td类都有xpath:
//*[@id="searchResultTable"]/table/tbody/tr[2]/td[3],
//*[@id="searchResultTable"]/table/tbody/tr[2]/td[4],
//*[@id="searchResultTable"]/table/tbody/tr[2]/td[5],
...
在其中一些 td 类中,我有一个要单击的复选框。我的最终目标是定义一个 td 类进行搜索,比如说
//*[@id="searchResultTable"]/table/tbody/tr[2]/td[3]
如果存在,请单击复选框。
我尝试过寻找带有
的盒子id=gwt-uid-102
但这不起作用,因为 id 每次都不同。
总之我想:
i = # i will define a number here
tdClass = driver.find_element_by_xpath("//*[@id="searchResultTable"]/table/tbody/tr[2]/td[i]")
# then within this tdClass, click the checkbox if checkbox is present.
【问题讨论】:
标签: python selenium selenium-webdriver selenium-chromedriver