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.

5
  • Hi Lakshmi, welcome to SQA. Is your question answered by this: sqa.stackexchange.com/questions/2084/…
    – testerab
    Sep 29, 2015 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. Nov 28, 2015 at 14:36
  • @Waits, It's working fine with partiallinkText Dec 2, 2015 at 4:44
  • It's working fine with partiallinkText Dec 2, 2015 at 4:45
  • I was able to solve by using partial link text @FindBy(partialLinkText="Change") public WebElement lnk_ChangePswd; Dec 2, 2015 at 4:47

2 Answers 2

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.

10
  • Are you sure the credentials you gave (username : [email protected], password : password) are correct? I'm getting Invalid username and password error when I use them. Sep 29, 2015 at 11:01
  • Logging in thru Google+ is also not working with your credentials, even with the new e-mail id you gave ([email protected]). Sep 29, 2015 at 11:05
  • For [email protected] using Google+ I'm recieving The email and password you entered don't match. error. Password I used - password. Sep 29, 2015 at 11:06
  • Can you login with Email --- [email protected], password is password ? Thanks for your patience Sep 29, 2015 at 11:08
  • This worked and I'm in. I'll try and let you know if I'm able to resolve your issue. Sep 29, 2015 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");
}
9
  • 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 Sep 29, 2015 at 9:49
  • have u added implicitwait ? Sep 29, 2015 at 9:51
  • yes i added before if condition Sep 29, 2015 at 9:52
  • try with partial link text or by tagname Sep 29, 2015 at 9:53
  • I tried with partial link text, but not working Sep 29, 2015 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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