1

I am unable to click the hidden link ("WatchBanking") after using moveToElement().

WebElement lnkW2yB=dr.findElement(By.xpath("//a[@href='/personal/ways_to_bank/ways-to-bank-landing']"));
    Actions act=new Actions(dr);
    act.moveToElement(lnkW2yB).build().perform();
    WebElement Span=dr.findElement(By.xpath("//span[contains(text(),'Bank with your Watch')]"));
    WebDriverWait wait=new WebDriverWait(dr,20);
    wait.until(ExpectedConditions.visibilityOf(Span));
    act.moveToElement(Span).build().perform();
    Thread.sleep(5000L);
    WebElement lnk=dr.findElement(By.linkText("WatchBanking"));
    wait.until(ExpectedConditions.visibilityOf(lnk));
    act.moveToElement(lnk).click(lnk).build().perform();

It moves to the span ("Bank with your Watch") and shows the link ("WatchBanking"), but it's not clicking on "WatchBanking" due to its immediate disappearance.

Please give me any solution on this.

  • 1
    Do you have a URL for us to test on? – FDM Jun 28 '15 at 17:56
  • i think after mouse over on the element we should create the select class for selecting the element. – user39923 Jun 7 at 9:51
1

If link is not visible, wait.until(ExpectedConditions.visibilityOf(lnk)); will time out. Wait cannot succeed if link is hidden.

In general, Selenium does only what user could do. If user cannot click on a link because it is hidden, Selenium cannot either. That's the whole point.

0

@Seetharaman,

Try below solution -

hidden_element.sendKeys("");
hidden_element.click();

You can expect good results from snippet! Let me know if your problem exist.

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.