Unable to find element with css selector == input[name='username']



  • WebElement username = driver.findElement(By.cssSelector("input[name='username']"));
    

    The statement mentioned above was working before but right now concerned element can't be captured and error message including " Unable to find element " is popping up. What might be the reason ?

    Scenario: It's login page by typing username and password.
    browser: IE explorer 11 (code should be run in that browser btw.)

    UPDATE: I dont know why but when I changed my connection to wifi from lan, it worked. Why would that change anything?



  • If it was working before, than the selector should be fine but something else has changed. Please check the site if the element changed. If not, then maybe add a wait to make sure the element is present.

    Other issues could be related to the viewport, or responsive design (element is not displayed on smaller widths)..



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2