-1

need to getText for the following (

Forgot Your Password

) Tried by csslocator / xpath but no good i sure i missing somthing

please help

<script type="text/javascript" async="" src="https://ssl.google-analytics.com/ga.js"></script><script src="/assets/application-09e7c8eb6ed1c47d9ccf9c9e94726f71.js" type="text/javascript"></script>

<div id="topBar">
  <div class="container">
    <div class="row">
      <div class="span4">
        <img alt="Canvus Applications" src="/assets/canvus_applications-f083c07b0216f0919ec4d11268e53bfa.png">
      </div>
      <div class="span7 hide-on-phones">
        <br>
      </div>
      <div class="span1 hide-on-phones">
        <img alt="powered by Amazon" class="amazon" src="/assets/core_views/amazon-c8de04354cd8a0cd0f311b55726ef892.png">
      </div>
    </div>
  </div>
</div>

<div id="loginContainer" class="container">

  <div class="row">

    <div class="span8 offset2">

    </div>

  </div>

  <div class="row">
    <div class="offset3 span6 loginForm">
      <h3>Forgot Your Password<div></div><div></div></h3>

2 Answers2

0

You didn't provide much information, but If the element returns a blank String when using getText() try this.

 WebElement forgotPassword = driver.findElement(By.cssLocator("cssLocator of the element here");
    String textToRetrieve = forgotPassword.getAttribute("innerText");
    System.out.println(textToRetrieve);
Reez0
  • 2,512
  • 2
  • 17
  • 39
0

You can use like this

   String textPwd=driver.findElement(By.xpath ("//h3[contains (text(),'Forgot Your Password')]")).getText ();
   System.out.println(textPwd);
iamsankalp89
  • 4,607
  • 2
  • 15
  • 36