1

I need to click on a link which displays a popup. But, I'm receiving the following exception:

org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with Command duration or timeout: 15.12 seconds

Here is the code:

driver.findElement(By.linkText("Account information")).click();
driver.findElement(By.linkText("Change Password")).click();
driver.findElement(By.id("changeEmail")).click();

and html:

<div class="col-md-9 col-sm-8 col-xs-12 frmmargin" ng-show="!externalUser && isextranalUser==true">
<div class="col-sm-12 col-xs-12">
<p>
<a ng-click="hidesuccessmsg()" data-toggle="modal" target="-self" href="#changeEmail">Change Password</a>
</p>
</div>
</div>

Please let me know what I'm missing here.

  • Hi Lakshmi, welcome to SQA. Is your question answered by this: sqa.stackexchange.com/questions/2084/… – testerab Sep 29 '15 at 12:20
  • @Lakshmi Priya, Error is thrown on which line? If the error is thrown after popup appears, then try Popup Handling. If the error is thrown before the popup appears then try using Waits. – Kenil Fadia Nov 28 '15 at 14:36
  • @Waits, It's working fine with partiallinkText – Lakshmi Priya Dec 2 '15 at 4:44
  • It's working fine with partiallinkText – Lakshmi Priya Dec 2 '15 at 4:45
  • I was able to solve by using partial link text @FindBy(partialLinkText="Change") public WebElement lnk_ChangePswd; – Lakshmi Priya Dec 2 '15 at 4:47
1

I'd recommend you to use any of the below wait methods. You may find success with any of these 3 methods, but it is always a good practice to use Explicit Wait as you are instructing the web driver to specifically look for what you need, instead of blindly waiting till the entire DOM gets loaded.

Explicit Wait: (Most Preferred)

WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("elementID")));

or

WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("elementID")));

Implicit Wait:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Sleep: (Try to avoid this unless absolutely necessary)

Thread.sleep(1000);

Note: It'll be more helpful if you can provide the link you are trying to test, so that we can help you with a more accurate answer.

| improve this answer | |
  • Are you sure the credentials you gave (username : priya.testing@gmail.com, password : password) are correct? I'm getting Invalid username and password error when I use them. – justcurious Sep 29 '15 at 11:01
  • Logging in thru Google+ is also not working with your credentials, even with the new e-mail id you gave (priya.veritis@gmail.com). – justcurious Sep 29 '15 at 11:05
  • For priya.veritis@gmail.com using Google+ I'm recieving The email and password you entered don't match. error. Password I used - password. – justcurious Sep 29 '15 at 11:06
  • Can you login with Email --- laya.indugula@gmail.com, password is password ? Thanks for your patience – Lakshmi Priya Sep 29 '15 at 11:08
  • This worked and I'm in. I'll try and let you know if I'm able to resolve your issue. – justcurious Sep 29 '15 at 11:11
0

try below code :

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    if(driver.findElement(By.linkText("Accountinformation")).isDisplayed())
    {
    System.out.println("Displayed");
    }
else
{
  System.out.println("fail");
}
| improve this answer | |
  • Thanks for your rply Sameer, it's displaying fail. i used assertion and tried with all possible locators xpath, cssselector, linkText, but it's not working – Lakshmi Priya Sep 29 '15 at 9:49
  • have u added implicitwait ? – sameer joshi Sep 29 '15 at 9:51
  • yes i added before if condition – Lakshmi Priya Sep 29 '15 at 9:52
  • try with partial link text or by tagname – sameer joshi Sep 29 '15 at 9:53
  • I tried with partial link text, but not working – Lakshmi Priya Sep 29 '15 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.