Wednesday, October 4, 2017

JavascriptExecutor is not working with 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://oditek.in/ikomplianzWeb/client/
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">

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();

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/04/javascriptexecutor-is-not-working-with-angularjs-forms/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment