htmlseleniumxpathcss-selectorstextnode

How to extract the text "152" from the textnode using Selenium


enter image description here

I need to extract the xpath for the number 152. The xpath that I created extracts the text after 152 which is "Test" but excludes the number 152. I need to get this count.

I am using below xpath :

//div\[@class='filter_filter__5H_fi'\]/h1

Not sure how to get this.


Solution

  • As per the HTML:

    HTML

    both the text 152 and Test are within their respective text nodes.


    Solution

    To retrive the text 152 you can use either of the following locator strategies: