【发布时间】:2021-08-25 18:31:19
【问题描述】:
get_div1 = driver.find_element_by_xpath("(//div[@dojoattachpoint='titleNode'])[1]")
get_div2 = driver.find_element_by_xpath("(//div[@dojoattachpoint='titleNode'])[2]")
get_div3 = driver.find_element_by_xpath("(//div[@dojoattachpoint='titleNode'])[3]")
get_div4 = driver.find_element_by_xpath("(//div[@dojoattachpoint='titleNode'])[4]")
.
.
.
.
.
我是 Python-Selenium 的新手。当我使用索引时,我得到了我需要的输出......我不确定我在哪个索引上得到了我的输出,那么我该如何迭代呢?因为,我发现很难将此 //div[@dojoattachpoint='titleNode'])[4] 分配给变量并进行操作。而且我不知道该网页中有多少索引可用。
【问题讨论】:
标签: python selenium selenium-webdriver xpath