【发布时间】:2023-03-05 22:33:01
【问题描述】:
我正在尝试使用 Python 和 Selenium 获取此元素。
<h2 class="jobTitle jobTitle-color-purple">
<span title="Director">Director=</span>
<h2>
这是我尝试过的:
try:
title = job.find_element_by_xpath('.//td[@class="title"]//a').text
except:
title = job.find_element_by_xpath('.//h2[@class="title"]//a').get_attribute(name="title")
我做错了什么?
no such element: Unable to locate element: {"method":"xpath","selector":".//h2[@class="title"]//a"}
【问题讨论】:
标签: python selenium selenium-webdriver xpath css-selectors