Do not randomly click the first matching element#54
Do not randomly click the first matching element#54jeanmonod wants to merge 1 commit intoCodeception:masterfrom
Conversation
|
My example above is quite naive. But when you have two actions on a page, both of which redirect to the same destination, and you don't understand why the action you are testing didn't work. Believe me, it's enough to drive you crazy... |
|
This is certainly a breaking change and we would have to raise a major version. Codeception has always worked this way and there are 27 other places in 17 other methods of InnerBrowser that take the first matching element. |
|
@jeanmonod please specify context as the second paramater for this case: $I->click('Save', 'form');I agree this behavior could be improved. Not to throw exception but to check for exact matches before clicking "Save dolphins: |
Ok, I was not aware of this 😅 Maybe throwing an exception is a bit too much then. My goal was not to break existing tests suites, but to avoid long debugging session while writing new test cases. I don't know conception enough, but possibly you have a mechanism to transmit warning to the developers? Is it the case? |
Here is my case. A simple web page with a menu and a form:
And here is my test case
In this case, I have a test fail. And it's difficult to understand what was the issue.
So in this PR, I suggest stopping clicking the first matching element on the page, but providing to the developer a appropriate error message about the click that was not precise enough.
Wdyt?