I am trying to access user name (id = "username"
) field and enter data, however I am getting:
element not found exception.
HTML Code:
<form method="post" action="/users/validate" autocomplete="off">
<input type="hidden" name="authenticity_token" id="authenticity_token" value="ChCVv99e+eLzD4IYQvnyv/tdc9m6yWGi34gSmp6PsbuQIAwIhjhwmDbzsxzXn1GmvpYzA8vpHmkfZNMfIuLNYw==">
<!-- username non-validatable -->
<div id="username-form-group" class="form-group label-floating">
<label for="username" class="control-label">Username</label>
<input type="text" id="username" name="user[user_name]" class="form-control" autocomplete="off" value="" maxlength="50">
<small><a class="pull-right" href="/username">Forgot username?</a></small>
</div>
</form>
Using Selenium WebDriver and Java.
driver.findElement(By.xpath("//form[@method='post']//input[@id='username']")).sendKeys("ABC");
Looks like not able to switch in the form!