Thursday, October 5, 2017

ExecuteScript not working with AngularJS form and Protractor

Used below codes to automate a login form. Form is built in AngularJS and I am using Protractor Framework. After filling textbox and clicked submit button; I am getting error that both textbox are empty. Used wait also. sendkeys is working fine, but its taking time to input larger forms; so I am expecting to use executeScript.

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">

Protractor Code:

var username = element(by.model('email'));
browser.executeScript("arguments[0].value='test@gmail.com'", username);
var password = element(by.model('pass'));
browser.executeScript("arguments[0].value='test123@'", password);
var submitButton = element(by.css('button.btn.btn-block'));
submitButton.click();

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/05/executescript-not-working-with-angularjs-form-and-protractor/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment