部分页面来源:
<span style="display:block; overflow:hidden; white-space: nowrap">Gi2/0/20</span>
Run Code Online (Sandbox Code Playgroud)
部分代码:
from selenium import webdriver
...
driver = webdriver.Chrome()
...
IP_CLICK = browser.find_element_by_xpath('//span[@style="display:block; overflow:hidden; white-space: nowrap"]/text()="Gi2/0/20"').click()
Run Code Online (Sandbox Code Playgroud)
我尝试使用表达式在网页中选择一个元素xpath,但出现以下错误:
InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //span[@style="display:block; overflow:hidden; white-space: nowrap"]/text()="Gi2/0/20" because of the following error:
Run Code Online (Sandbox Code Playgroud)
TypeError:无法对“文档”执行“评估”:结果不是节点集,因此无法转换为所需的类型。(会话信息: chrome=72.0.3626.121) (驱动程序信息: chromedriver=73.0.3683.20 (8e2b610813e167eee3619ac4ce6e42e3ec622017),platform=Windows NT 6.1.7601 SP1 x86_64)