I’m not able to login using selenium webdriver using Java Language. It was working fine earlier.
Below is my HTML code:
<div class="form-group">
<label for="loginUsername" style="width: 100%; font-weight: normal" aria-label="Username">
<input id="loginUsername" class="form-control" name="username" type="text" placeholder="Username" autocapitalize="off">
</label>
</div>
<div class="form-group">
<label for="loginPassword" style="width: 100%; font-weight: normal" aria-label="Password">
<input id="loginPassword" class="form-control" name="password" type="password" placeholder="Password" autocapitalize="off">
</label>
</div>
Below is my code before the incident:
driver.findElement(By.xpath("//*[@id=\"loginUsername\"]")).sendKeys("username");
driver.findElement(By.xpath("//*[@id=\"loginPassword\"]")).sendKeys("password");
I even tried changing it up and it looked something like this:
WebElement username = driver.findElement(By.xpath("//*[@id=\"loginUsername\"]")); username.click(); username.clear(); ;username.sendKeys("username");
WebElement password = driver.findElement(By.xpath("//*[@id=\"loginPassword\"]")); password.click(); password.clear(); ;password.sendKeys("password");
Below is my full code:
<div class="col-sm-4 col-sm-offset-4">
<form action="/login" method="post">
<div class="form-group title">
<img src="/img/RA_LOGO_BLUE.png" alt="Risk Assessment System Logo">
</div>
<div class="form-group">
<label for="loginUsername" style="width: 100%; font-weight: normal" aria-label="Username">
<input id="loginUsername" class="form-control" name="username" type="text" placeholder="Username" autocapitalize="off">
</label>
</div>
<div class="form-group">
<label for="loginPassword" style="width: 100%; font-weight: normal" aria-label="Password">
<input id="loginPassword" class="form-control" name="password" type="password" placeholder="Password" autocapitalize="off">
</label>
</div>
<input id="loginBtn" class="btn" type="submit" value="Login">
</form>
<br>
<div class="text-left">
<span class="fakeLink" data-toggle="modal" data-target="#forgotPasswordModal">Forgot Password?</span><br>
<span class="fakeLink" data-toggle="modal" data-target="#forgotUsernameModal">Forgot Username?</span>
</div>
</div>