Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined offset: 12 when disabled checkboxes are present for array field #150

Open
acoulton opened this issue Mar 16, 2020 · 1 comment

Comments

@acoulton
Copy link

With the latest behat/mink-browserkit-driver 1.3.4 and symfony/dom-crawler 4.4.5 there's an incompatibility that causes a fatal error in our testsuite.

We have HTML containing checkboxes with an array field name, some of them disabled - e.g.:

<input type="checkbox" name="permitted_recruiters[]" value="6620" disabled checked>
<input type="checkbox" name="permitted_recruiters[]" value="5340" disabled checked>
<input type="checkbox" name="permitted_recruiters[]" value="6639">
<input type="checkbox" name="permitted_recruiters[]" value="6672">

And we have a step that uses the standard And I check "Major Tom" step in MinkContext.

This has been working fine, but is now giving an Undefined offset: {number} error from BrowserKitDriver.

The error comes from this line

As far as I can see, the issue is that BrowserKitDriver's getFieldPosition() method just enumerates all checkboxes with that name on the page.

However the latest dom-crawler release includes this commit which appears to skip over fields that are disabled hence the array indices are different.

I suspect this can be fixed by duplicating that logic so that getFieldPosition also skips disabled fields, but it might be better to try and make it more robust so that it's not relying on matching just by the array index?

@aik099
Copy link
Member

aik099 commented Mar 19, 2020

Here is what needs to be done:

  1. please create a PR to https://github.com/minkphp/driver-testsuite, that will add missing tests to cover handling of disabled checkboxes in general
  2. after some testing and review from other people it will be merged
  3. after I'll re-run last build for every driver on Travis CI to see if they fail to comply with new test
  4. corresponding per-driver PR will be created with a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants