【发布时间】:2019-12-11 21:37:29
【问题描述】:
我是 python 新手,我正在尝试编写一个网络抓取脚本。我正在尝试双击此元素(它既不是按钮也不是链接 - 只是一个 td 元素),甚至一开始就找不到它。
下面是代码
<td align="left" valign="middle" class=" "
title="Business Profile (Imported)">Business Profile (Imported)</td>
当我选择它时,类会改变。我怀疑这就是问题所在
<td align="left" valign="middle" class=" cellselected "
title="Business Profile (Imported)">Business Profile (Imported)</td>
我使用了 css 选择器和 xpath。没有工作。我都试过了:
driver.find_element_by_xpath('//td[@title="Business Profile (Imported)"]').click()
driver.find_element_by_css_selector("td[title='Business Profile (Imported)']")
这是我得到的错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//td[@title="Business Profile (Imported)"]"}
任何帮助将不胜感激。谢谢!!
【问题讨论】:
-
它在 IFRAME 内吗?您是否尝试过添加等待?
标签: python selenium selenium-webdriver xpath xpath-1.0