【发布时间】:2021-10-12 15:09:21
【问题描述】:
My code:
driver = webdriver.Chrome()
driver.get(url)
value = driver.find_element_by_xpath("//*[name()='div' and @id='chartContainer']//*[name()= 'svg' and @style= 'position: absolute; z-index: 6;']//*[name()= 'g' and @font-size= '10pt]")
driver.quit()
print(value)
[网站网址][2]
错误信息: *
InvalidSelectorException:消息:无效选择器:无法定位 具有 xpath 表达式的元素 //[name()='div' 和 @id='chartContainer']//[name()= 'svg' 和@style= '位置: 绝对; z-index: 6;']//[name()= 'g' and @font-size= '10pt] 因为 以下错误: SyntaxError: Failed to execute 'evaluate' on 'Document':字符串 '//[name()='div' 和 @id='chartContainer']//[name()= 'svg' 和 @style= '位置: 绝对; z-index: 6;']//[name()= 'g' and @font-size= '10pt]' 不是 一个有效的 XPath 表达式。 (会话信息:chrome=94.0.4606.81)
【问题讨论】: