Home > Software engineering >  How to get a number from the div block using xPath
How to get a number from the div block using xPath

Time:10-01

Just recently started to study xPath.And I faced such a difficult task for me. I need to get it somehow here "22 973 ₴".How can I do this?

<div class="col search_price discounted responsive_secondrow">
   <span style="color: #888888;"><strike>25 758₴</strike></span><br>22 973₴                    
</div>
           

CodePudding user response:

You can try this;

xpath('//div[@class="col search_price discounted responsive_secondrow"]//text()').split()[1]

CodePudding user response:

You can use below xPath to get value 22 973₴

//div[contains(@class,'discounted')]/text()[2]

Code:

driver.findElement(By.xPath("//div[contains(@class,'discounted')]/text()[2]")).getText();
  • Related