How to Fix ElementNotVisibleException: Element is not currently visible and so may not be interacted with

8,964 views
Skip to first unread message

Hamid Assous

unread,
Dec 17, 2013, 10:52:29 AM12/17/13
to webd...@googlegroups.com

Hi,

When I execute this code it get an error "org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with"

public void testenroll() throws Exception {
    driver.get(baseUrl + "");
    driver.findElement(By.xpath("//div[@id='enrolBox']/div/div[2]/input")).click();
    driver.findElement(By.xpath("//div[@id='enrolBox']/div/div[2]/input")).clear();
    driver.findElement(By.xpath("//div[@id='enrolBox']/div/div[2]/input")).sendKeys("1234567890");
    driver.findElement(By.xpath("//div[@id='enrolButton']/input")).click();
  }

Thanks,
H. Assous

balaji dn

unread,
Dec 18, 2013, 1:50:56 AM12/18/13
to webd...@googlegroups.com
You can refer to this thread https://groups.google.com/forum/#!topic/webdriver/JNdhXbhPNyg which speaks about a similar issue. This might solve your problem

Mayank Purohit

unread,
Dec 18, 2013, 6:24:43 AM12/18/13
to webd...@googlegroups.com
Please check if the page source contains the same xpath which is not visible. To handle this, you have to refine your xpath so that it clicks the specified element.

darrell

unread,
Dec 18, 2013, 8:11:46 AM12/18/13
to webd...@googlegroups.com
Not really a good message. You don't give the full error message and you trimmed out enough to make it not enough. You post code (this is obvious what doesn't work) but you don't post what you are trying to automate. Even the most basic information isn't present. Which browser, which version of browser, which version of WebDriver. At least from the code provided we can figure out you are using Java but it never hurts to stop making assumptions.

The most obvious solution to your problem is make the element visible before you try to click on it but this might not be your particular problem.

Bill Ross

unread,
Dec 24, 2013, 4:58:39 PM12/24/13
to webd...@googlegroups.com
I have a 'makeelementvisible' javascript routine that works with
elements that have id's, which I use to make select elements
accessible when they are mediated by javascript actions - this way
I can make a selection directly rather than through clicking on
the javascript selector. It sets the visiblity to true and moves
any elements that are invisible by being placed offscreen back
into the picture. It relies on an in-house javascript function,
so might not be relevant to share (and I don't have the code
available now). But this is one practical reason to mess with the
user model presented by the web page. Maybe one could manage the
selection via the javascript selector, but that's a journey I
skipped.

Bill
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
> To post to this group, send email to webd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/webdriver.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages