Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Possible fix for a 'selectOption' issue #408
I had what appears to be the same issue as in #295, where the select element was correctly found and the correct option selected but then this error was thrown:
So I changed the implementation slightly so that it no longer cycles through different options - it just selects the first one that matches.
Note: this won't work for selecting multiple options - it will only work for a dropdown select. But given this is the more common one I thought it was much more crucial it work for this. Obviously a better solution would be for it to work on both but I don't know enough about what's going on to work that out.
The tests are likely failing because he changed/broke current behavior.
The error that is being worked around is pretty 'standard' for iterators. Just pushing the results into an array, and then looping through that instead would fix things.
Hacked together like:
Of course, I don't know the exact behavior that is expected by the test. This method of fixing things doesn't really mimic the exact behavior of a user in all cases.
Forgive me for not posting a proper PR for this. I stumbled here searching for the error message while previewing CodeceptJS to see if it was suitable for my project needs. I have neither the time or inclination to get php and a testing environment set up to do things properly. However, the code change I have posted did unblock me from running my specific sample test.
Ok - I worked out that the error was occurring due to changes to the DOM due to an 'onchange' event listener. I've recreated this in a test and following the suggested code changes from @sqmgh (thanks!) both this new test and the existing ones are passing.