mercredi 4 octobre 2017

JavascriptExecutor not working in case of AngularJS forms

I am trying to automate a login form by Selenium Webdriver (JavascriptExecutor) which is built in AngularJS. The script is entering data in textbox; but when submit button is clicked error message shows that textbox is not filled. I have also used events like onkeyup(), blur(); but error shows these are not functions. Textbox validation works fine with sendkeys() and it takes time; but facing issue when JavascriptExecutor is used. http://ift.tt/2xZf1uF

html code:

<input id="email" class="form-control ng-pristine ng-valid ng-touched" type="text" ng-keypress="logindata($event)" ng-model="email" placeholder="Email ID" value="" name="email">
<input id="pass" class="form-control ng-pristine ng-valid ng-touched" type="password" ng-keypress="logindata($event)" ng-model="pass" placeholder="Password" name="pass">

Selenium Code:

JavascriptExecutor executor = (JavascriptExecutor) driver;
WebElement emailElement = driver.findElement(By.id("email"));
WebElement passwordElement = driver.findElement(By.id("pass"));
executor.executeScript("arguments[0].value='test@gmail.com'", emailElement);
executor.executeScript("arguments[0].value='client123@'", passwordElement);
driver.findElement(By.xpath("//form[@id='loginForm']/button")).click();

Aucun commentaire:

Enregistrer un commentaire