I have executed e2e test for following code using angular
it('should successfully login and create a session using valid credentials', function() {
browser.get('');
browser.driver.manage().deleteAllCookies();
var username = element(by.model('username'));
var password = element(by.model('password'));
username.sendKeys('admin');
password.sendKeys('password');
});
but i got error like this
NoSuchElementError: No element found using locator: by.model("username")
how to solve this issue.
I have executed e2e test for following code using angular
it('should successfully login and create a session using valid credentials', function() {
browser.get('http://www.angularjs');
browser.driver.manage().deleteAllCookies();
var username = element(by.model('username'));
var password = element(by.model('password'));
username.sendKeys('admin');
password.sendKeys('password');
});
but i got error like this
NoSuchElementError: No element found using locator: by.model("username")
how to solve this issue.
Share Improve this question edited Jun 2, 2016 at 10:56 giri-sh 6,9622 gold badges27 silver badges50 bronze badges asked Aug 27, 2015 at 10:33 Vijaya KumarVijaya Kumar 1371 gold badge2 silver badges7 bronze badges2 Answers
Reset to default 3You should build your Protractor test not based on assumptions, but with the assistance of tools such as element explorer and elementor.
Then, you can claim, that there is a problem.
Without those tools, writing Protractor test bees very slow process.
Link to elementor repo: https://github./andresdominguez/elementor
Are you sure that your element exists in DOM. If yes, then you should wait for angular to settle down and then try to check for the elements. If the element is still loading then protractor will throw an error. Include ignoreSynchronization
to make sure protractor waits for angular to settle. You can provide explicit wait time for element to be visible or wait until it loads -
it('should successfully login and create a session using valid credentials', function() {
browser.driver.manage().deleteAllCookies();
browser.ignoreSynchronization = false;
browser.get('http://www.angularjs');
var username = element(by.model('username'));
var password = element(by.model('password'));
browser.sleep(2000);
browser.wait(protractor.ExpectedConditions.visibilityOf(username), 20000);
username.sendKeys('admin');
password.sendKeys('password');
});
Hope this helps.