【发布时间】:2020-12-10 16:21:53
【问题描述】:
我在使用 selenium 选择此软件中的 RUC 选项时遇到问题,标签不包含区分它们的 id 并且类是相同的:
我正在使用以下代码,但它对我不起作用:
label_tipo_documento = driver.find_element_by_xpath('//div[@id="form-group-tipo_documento"]//div[@class="col-sm-3"]//label[@class="radio-inline"][2]')
print(label_tipo_documento.text)
label_tipo_documento.click()
我尝试在标签 [2] (RUC) 中选择第二个选项,然后收到以下消息:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id="form-group-tipo_documento"]//div[@class="col-sm-3"]//label[@class="radio-inline"][2]"}
(Session info: chrome=87.0.4280.88)
但是,当我使用 [1] 而不是 [2] 时,它会找到一个值:
DNI
【问题讨论】:
标签: python selenium xpath css-selectors webdriverwait