Brian Ly
Brian Ly

Reputation: 183

Angular/Protractor Test: After running first test, dropdown options no longer clickable

Running a test where a dropdown list is selected from. However, after running the first spec, the option tag can no longer be selected. I've isolated each spec to make sure they are working. This issue only occurs when tests are run in succession.

Here is the code I am using to select the dropdown options:

element.all(by.cssContainingText('option', keyword)).first().click();

This is the error that I am receiving after the second test runs:

Failed: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.cssContainingText("option", "keyword")

HTML:

<select>
   <option>David</option>
   <option>Karen</option>
   <option>Linda</option>
   <option>Charlie</option>

Keyword used: David

It says there are 0 elements on the page which means it is not recognizing the option values. Every test works when run alone, the drop down is able to be selected. This error only occurs when run in succession.

Also I've added browser sleeps to check the console and to see if the dropdown is clickable. There appears to be no errors and when using my mouse, the option tags appear and are also clickable. Also added waits and sleeps to see if it just takes some time for the options to appear. Seems to be an issue with protractor identifying the options.

Upvotes: 0

Views: 201

Answers (0)

Related Questions