【发布时间】:2018-03-27 12:37:09
【问题描述】:
我正在尝试将机器人中的 xpath 转换为 python 代码。我希望将 Robot 中的以下 xpath 转换为 python 代码
这适用于机器人:
xpath=(//th[@class="picker-switch"])[2]
我在python中试过
self._driver.find_element_by_xpath("//th[@class='picker-switch'][2]")
导致以下错误:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//th[@class='datepicker-switch'][2]"}
和
self._driver.find_element_by_xpath("//th[@class='picker-switch']")[2]
导致:
'WebElement' object does not support indexing
【问题讨论】:
-
“不工作”是一个相当广泛的领域。你能提供给我们错误信息吗?
-
我已经添加了错误。
标签: python-2.7 selenium-webdriver robotframework