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– testerab2015年09月29日 12:20:12 +00:00Commented 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.Kenil Fadia– Kenil Fadia2015年11月28日 14:36:51 +00:00Commented Nov 28, 2015 at 14:36
-
@Waits, It's working fine with partiallinkTextLakshmi Priya– Lakshmi Priya2015年12月02日 04:44:31 +00:00Commented Dec 2, 2015 at 4:44
-
It's working fine with partiallinkTextLakshmi Priya– Lakshmi Priya2015年12月02日 04:45:27 +00:00Commented Dec 2, 2015 at 4:45
-
I was able to solve by using partial link text @FindBy(partialLinkText="Change") public WebElement lnk_ChangePswd;Lakshmi Priya– Lakshmi Priya2015年12月02日 04:47:19 +00:00Commented Dec 2, 2015 at 4:47
2 Answers 2
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.
-
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.justcurious– justcurious2015年09月29日 11:01:42 +00:00Commented 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]).justcurious– justcurious2015年09月29日 11:05:09 +00:00Commented 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.justcurious– justcurious2015年09月29日 11:06:42 +00:00Commented Sep 29, 2015 at 11:06 -
Can you login with Email --- [email protected], password is password ? Thanks for your patienceLakshmi Priya– Lakshmi Priya2015年09月29日 11:08:07 +00:00Commented 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.justcurious– justcurious2015年09月29日 11:11:44 +00:00Commented Sep 29, 2015 at 11:11
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");
}
-
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 workingLakshmi Priya– Lakshmi Priya2015年09月29日 09:49:29 +00:00Commented Sep 29, 2015 at 9:49
-
have u added implicitwait ?sameer joshi– sameer joshi2015年09月29日 09:51:10 +00:00Commented Sep 29, 2015 at 9:51
-
yes i added before if conditionLakshmi Priya– Lakshmi Priya2015年09月29日 09:52:25 +00:00Commented Sep 29, 2015 at 9:52
-
try with partial link text or by tagnamesameer joshi– sameer joshi2015年09月29日 09:53:54 +00:00Commented Sep 29, 2015 at 9:53
-
I tried with partial link text, but not workingLakshmi Priya– Lakshmi Priya2015年09月29日 09:59:35 +00:00Commented Sep 29, 2015 at 9:59
Explore related questions
See similar questions with these tags.