title: How to click on an input type submit with no defined ID using Selenium WebDriver and Java
body: <p>I am trying to login to website, the login form doesn't have any ids associated with its value, and it uses only names:</p>
  
  <pre><code>&lt;div id="warp"&gt;
  &lt;div id="content"&gt;
  &lt;form action="/index.php" method="post" name='login'&gt;
  username: &lt;input type="text" name="username"&gt;
  password: &lt;input type="text" name="password"&gt;
  &lt;input type="submit" name="login" class="submit" value="login"&gt;
  </code></pre>
  
  <p>using the following commands I am able to fill in the user ID and password, but I can't click submit. </p>
  
  <pre><code>WebElement username = driver.findElement(By.name("username"));
  username.sendKeys("xxxxx");
  WebElement password = driver.findElement(By.name("password"));
  password.sendKeys("xxxxx");
  </code></pre>
  
  <p>this doesn't get executed:</p>
  
  <pre><code>WebElement login = driver.findElement(By.name("login"));
  login.click();
  </code></pre>
  
  <p>Error :-</p>
  
  <blockquote>
    <p>Unable to locate element login</p>
  </blockquote>
  
  <p>And if I did element.submit();
  it clears out the entered data in the pass/user fields. </p>