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.

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

answered Sep 29, 2015 at 10:29
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. Commented 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]). Commented 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. Commented Sep 29, 2015 at 11:06
  • Can you login with Email --- [email protected], password is password ? Thanks for your patience Commented 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. Commented 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");
}
MKay
2351 silver badge8 bronze badges
answered Sep 29, 2015 at 9:31
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 Commented Sep 29, 2015 at 9:49
  • have u added implicitwait ? Commented Sep 29, 2015 at 9:51
  • yes i added before if condition Commented Sep 29, 2015 at 9:52
  • try with partial link text or by tagname Commented Sep 29, 2015 at 9:53
  • I tried with partial link text, but not working Commented Sep 29, 2015 at 9:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.