[英]Not a valid XPath expression
I am getting error while running the program, If i check my xpath in chropath it gives no error in path but while running i am getting error "valid XPath expression."我在运行程序时遇到错误,如果我在 chropath 中检查我的 xpath,它在路径中没有给出错误,但是在运行时我收到错误“有效的 XPath 表达式”。
<article xpath="1">
<div class="imagen">
<img src="https://image.tmdb.org/t/p/w154/bhgCVGl6BDXS8BfcUGzWU5EWnMb.jpg">
<div id="c28153" data-nonce="9f7f7584d7" data-id="28153" data-type="movie" class="cimport">
</div>
</div>
<div class="data">
<h3>It's Alive</h3>
<span>1974</span>
</div>
</article>
PYTHON CODE: PYTHON 代码:
driver.find_element_by_xpath('//h3[translate(. ," - ; : ! , . * ? / \' " , " " )='its live']//preceding::img[1]//following::div[1]').click()
You need to use:你需要使用:
driver.find_element_by_xpath('//h3[translate(. ," - ; : ! , . * ? / \' " , " " )=\'its live\']//preceding::img[1]//following::div[1]').click()
just adding \
before the inner '
.只需在内部
'
之前添加\
。
Replace you Xpath string by this one:用这个替换你的 Xpath 字符串:
'//h3[translate(. ," - ; : ! , . * ? / \' " , " " )="its live"]//preceding::img[1]//following::div[1]'
The probleme you have its a mixing of quote, that prematuraly end the string.你有一个混合引用的问题,过早地结束了字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.