Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

NoSuchElementError when finding an element that does not yet exist. #83

Closed
jeffbcross opened this issue Sep 11, 2013 · 2 comments
Closed

Comments

@jeffbcross
Copy link
Contributor

The findElement call within this example gives a NoSuchElementError, presumably because the element does exist until the beginning of the test is completed.

ptor.get('http://angularjs.org/');
var el = ptor.findElement(protractor.By.input('todoText'));
el.click()
el.sendKeys('Write tests!');

var btn = queryDoc('[ng-submit="addTodo()"] .btn-primary');
btn.click();

expect(tractor.findElement(ptor.By.css('[ng-repeat="todo in todos"]:nth-child(3) span'))).toEqual('Write tests!');
@juliemr
Copy link
Member

juliemr commented Sep 11, 2013

This is working as intended - webdriver throws an error if it can't find an element. Any problem with just switching up the order of the statements?

@jeffbcross
Copy link
Contributor Author

To clarify, it's the below bit of code that wasn't working.

expect(ptor.findElement(protractor.By.css('[ng-repeat="todo in todos"]:nth-child(3) span'))).toEqual('Write tests!');

I assumed there was a change with how protractor manages control flow that had caused this test to stop working in the latest protractor, but after getting the debugger to work, it looks like the problem is that the btn.click() isn't actually registering/creating the element for some reason. I'm working on finding out why.

Closing this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants