At work, we've recently started to use protractor to write end-to-end tests for a legacy AngularJs code base.
Last week we found a problem while trying to test that an element from a list was deleted:
The problem was that clicking on the delete icon was displaying an alert box, prompting the user to confirm whether they actually wanted to delete the element or not, that protractor didn't expect and was causing the following error:
UnexpectedAlertOpenError: unexpected alert open
After searching in Google for a while, we found a solution:
that fixed the problem by switching to the alert box and confirming that we wanted to delete the element.
Since it was a bit verbose and we'd probably have to use it again in some other tests, we extracted it to a helper function in our TestTools module:
I hope you might find this useful if you're using protractor.
Yes, thanks this was helpful even without protractor, just for selenium. Alert handling is a big pain in the *** there.
ReplyDeleteI'm glad it was useful to you.
DeleteBest regards,
M
It is very useful but it is not working when i use it after the select option
ReplyDeleteWorks for me...
ReplyDeleteThanks a lot
It is not working for me and I am getting the following error:
ReplyDelete....A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
Protractor.waitForAngular()