Reputation:
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."
<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:
driver.find_element_by_xpath('//h3[translate(. ," - ; : ! , . * ? / \' " , " " )='its live']//preceding::img[1]//following::div[1]').click()
Upvotes: 1
Views: 461
Reputation: 5214
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 '
.
Upvotes: 2
Reputation: 2569
Replace you Xpath string by this one :
'//h3[translate(. ," - ; : ! , . * ? / \' " , " " )="its live"]//preceding::img[1]//following::div[1]'
The probleme you have its a mixing of quote, that prematuraly end the string.
Upvotes: 1