Today I needed to click on a select option that had a specific value using protractor.
After Googling for a while, I did it using the element selection by xpath.
This is the helper function I created:
And this is how it's used from the test:
----------------
PS: Check also my previous posts about Protractor:
Record of experiments, readings, links, videos and other things that I find on the long road.
Registro de experimentos, lecturas, links, vídeos y otras cosas que voy encontrando en el largo camino.
Showing posts with label Protractor. Show all posts
Showing posts with label Protractor. Show all posts
Wednesday, June 11, 2014
Monday, June 9, 2014
Protractor: How to select a dropdown option to avoid ElementNotVisibleError
Another problem we found last week using protractor was when we tried to click on a dropdown option.
This was the problematic code:
which caused the following error:
ElementNotVisibleError: element not visible
This happened because the element we were trying to click on was hidden.
Googling a bit again, we found (here) that to avoid the error we had to click on the dropdown before clicking on the option to open it up, so that it wa visible to the user:
Again we extracted this bit of code into a helper method in out TestTools module:
----------------
PS: Check also my previous post about Protractor:
This was the problematic code:
which caused the following error:
ElementNotVisibleError: element not visible
This happened because the element we were trying to click on was hidden.
Googling a bit again, we found (here) that to avoid the error we had to click on the dropdown before clicking on the option to open it up, so that it wa visible to the user:
Again we extracted this bit of code into a helper method in out TestTools module:
----------------
PS: Check also my previous post about Protractor:
Protractor: How to avoid UnexpectedAlertOpenError
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.
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.
Subscribe to:
Posts (Atom)