4

When I am trying to execute below code its giving me exception as:-org.openqa.selenium.ElementNotVisibleException: element not visible

 WebElement elem = newDriver.findElement(By.name("loginId"));
    elem.get(0).clear();
    elem.get(0).sendKeys("asd");

even though element is present.

For more details see the below image.

enter image description here

I am trying to access input box below account label but its giving me exception as element is not visible.

I already used Actions tag and JavascriptExecutor

Any suggestions.

2
  • You can try this : stackoverflow.com/questions/19637507/… Commented Nov 10, 2017 at 11:41
  • @Kapil123 thank you for your suggestion . Commented Nov 10, 2017 at 11:58

1 Answer 1

1

The interested element is inside an iframe:

enter image description here

So, before, you have to switch to the iframe:

    WebElement iframe= driver.findElement(By.id("alibaba-login-box"));
    driver.switchTo().frame(iframe);

If you want to go "out" the iframe:

driver.switchTo().defaultContent();

The entire code:

    WebElement iframe= driver.findElement(By.id("alibaba-login-box"));
    driver.switchTo().frame(iframe);
    WebElement elem = driver.findElement(By.id("fm-login-id"));
    elem.clear();
    elem.sendKeys("asd");

    //when you want to return to the defaultContent
    driver.switchTo().defaultContent();
Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot, it works. I was struggling with the problem more 5 hours, once again thank you for your help.

Your Answer

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.