I have tried various ways not just name but by xpath, css selectors but every time the error remained same. While inspecting the elements the below is the result. As seen in other answers it is not in iframe. I have also tried putting a wait statement but no luck.


<input class="news" name="USER" value="" size="13" style="width:100%;">
<input class="news" name="PASSWORD" value="" size="13" style="width:100%;" 


org.openqa.selenium.NoSuchElementException: no such element: Unable to 
locate element: {"method":"name","selector":"USER"}
  • I had the same problem, sometimes it happen if the page is not properly at the time of searching the element. Try this PageFactory.initElements(driver, "class name".class); Refer this page. It will give you a proper idea toolsqa.com/selenium-webdriver/…
    – Syrus
    May 24, 2018 at 12:43
  • Can you share the URL? May 24, 2018 at 13:56
  • 1
    use explicit wait statement and try
    – Vel Guru
    May 25, 2018 at 4:36
  • @joe I have tried that way as well but that too isn't working. May 25, 2018 at 6:12
  • its better if you have given the code. I had same problem. Have tried using "PageFactory.initElements"? Take this for an example GoogleSearchPage page = PageFactory.initElements(driver, GoogleSearchPage.class);
    – Syrus
    May 25, 2018 at 8:08

4 Answers 4


There may be several reasons.

  1. Page not correctly loaded at the time. To resolve this driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); you can add page load timeout.

  2. Element is not actually visible in screen and you need to scroll down or scroll up to that element

    public void scrollDown(){
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("window.scrollBy(0,250)", "");
  3. Another solution is Add time to wait until element visible

    public WebElement waitUntilElementVisible(WebDriver driver, WebElement element, int delay) {
            WebDriverWait wait = new WebDriverWait(driver, delay);
            return wait.until(ExpectedConditions.visibilityOf(element));
        }catch (NoSuchElementException e){
            throw new RuntimeException("Web element not visible within given time" + element +" Time "+ delay);

In .Net ISearchContext.FindElement() throws NoSuchElementException. Based on the official Selenium documentation I speculate that in Java it does not throw exception or WebDriverWait.Until knows how to handle it.

WebDriverWait.IgnoreExceptionTypes(typeof(NoSuchElementException)); would help but it does not work.

Solved with static helper method:

using OpenQA.Selenium;
namespace Blah
    public static class SearchContextHelper
        public static IWebElement TryFindElement(this ISearchContext searchContext, By by)
            try { return searchContext.FindElement(by); }
            catch (NoSuchElementException) { return null; }

you can try : selenium.waitForPageToLoad(PAGE_TO_LOAD_TIMEOUT);

  • Since this is a new answer to an old question with several other answers, could you please expand on your answer to explain how it improves on the existing answers?
    – Kate Paulk
    Aug 27, 2021 at 11:34

If page will be not loaded properly then it might be this kind of error will be occur Please try with this:

WebElement username=driver.findelement(By.name("USER"));

WebElement username=driver.findelement(By.name("PASSWORD"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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