Home > Mobile >  How could I extract the text under <div> and <ul> class using Selenium Java
How could I extract the text under <div> and <ul> class using Selenium Java

Time:08-12

I want to extract the text "Hi, Harvey " from the below html source

<div shop-menu">
  <ul clas="navbar-nav">
    ::before
     "Hi, harvey "
      <a href="logout.htm">..</a>
     ::after
   </ul>
  </div>
</div>

I have tried:

driver.findElement(By.linkText("Hi, harvey "))

but couldn't extract it, any suggestions?

CodePudding user response:

This should locate that element

driver.findElement(By.xpath("//ul[contains(.,'Hi, harvey')]"))
  • Related