admin管理员组文章数量:1416073
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.
本文标签:
版权声明:本文标题:javascript - Error in protractor (NoSuchElementError: No element found using locator: by.model("username")) - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745244155a2649479.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论