I'm trying to obtain the price text in the following html code:
<span content="79.95" itemprop="price">79,95 TL</span>
Using the code, i have this
prices2=driver.find_element(By.XPATH, "//span[@class='item-price.js-variant-price'")
but so far it can't get the "79.96" value, what am I doing wrong?
Edit: solved thanks to the help of jaSon down below, this is the working code:
prices2=driver.find_element(By.XPATH, "//span[@class='item-price js-variant-price']")
prices2=prices2.get_attribute('innerHTML')
CodePudding user response:
Your selector
"//span[@class='item-price.js-variant-price'"
is incorrect:
- You missed closing square bracket
- In XPath predicate you don't need to separate class names with dot
Correct XPath would be
"//span[@class='item-price js-variant-price']"
Also note that Price value might come from XHR so you might need to implement Wait to get it