I have used find the element by Xpath in my code, I get the error as ElementNotVisible.

<div class="loginBtn">
    <input style="width: 59px; height: 20px" id="SubmitCreds" onclick="clkLgn()" type="submit" value="" name="SubmitCreds">

I try search the attribute value for id "SubmitCreds" its available in 3 different locations so used xpath.

  • 1
    thats not the correct way to ask questions, you should share the HTML snippet with your Code that you have tried. Its very vague to answer these kind of questions. See this – Paras Jul 25 '16 at 8:50
  • put your line of code that you have tried. – Paras Jul 25 '16 at 10:44
  • 1
    this is a common question, you need to wait for the page to be loaded and/or for the element to be visible.you can find other similar questions if you do a search. – lauda Jul 25 '16 at 13:44

Selenium determines an element is visible or not by the following criteria (use a DOM inspector to determine what css applies to your element, make sure you look at computed style):

  • visibility != hidden
  • display != none (is also checked against every parent element)
  • opacity != 0 (this is not checked for clicking an element)
  • height and width are both > 0
  • for an input, the attribute type != hidden

Your element is matching one of those criteria. If you do not have the ability to change the styling of the element, here is how you can forcefully do it with javascript:

((JavascriptExecutor)driver).executeScript("arguments[0].checked = true;", inputElement);

But that won't fire a javascript event, if you depend on the change event for that input you'll have to fire it too (many ways to do that, easiest to use whatever javascript library is loaded on that page).

The source for the visibility check -


The WebDriver spec that defines this -


| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.