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

Behat\Mink\Tests\Driver\Js\ChangeEventTest::testSetValueChangeEvent error #9

Closed
jcalderonzumba opened this issue Nov 22, 2016 · 6 comments

Comments

@jcalderonzumba
Copy link

I'm testing https://github.com/jcalderonzumba/MinkPhantomJSDriver with the test suite using phantomjs 2.1.1 and i get this error that does not happen on older phantomjs browsers.

1) Behat\Mink\Tests\Driver\Js\ChangeEventTest::testSetValueChangeEvent with data set "file" ('the-file', 'from empty', 'from existing')
Zumba\GastonJS\Exception\JavascriptError: One or more errors were raised in the Javascript code on the page.
            If you don't care about these errors, you can ignore them by
            setting js_errors: false in your Poltergeist configuration (see documentation for details).
InvalidStateError: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.
InvalidStateError: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.
    at phantomjs://code/agent.js:465 in set
    at :187 in textAreaSetValue
    at :175 in inputSetValue
    at :201
    at :211
    at :212
    at :212
/Users/juan/code/scm/opensource/pjsdriver/vendor/jcalderonzumba/gastonjs/src/Browser/BrowserBase.php:119
/Users/juan/code/scm/opensource/pjsdriver/vendor/jcalderonzumba/gastonjs/src/Browser/BrowserBase.php:99
/Users/juan/code/scm/opensource/pjsdriver/vendor/jcalderonzumba/gastonjs/src/Browser/BrowserScriptTrait.php:16
/Users/juan/code/scm/opensource/pjsdriver/src/FormManipulationTrait.php:39
/Users/juan/code/scm/opensource/pjsdriver/vendor/behat/mink/src/Element/NodeElement.php:105
/Users/juan/code/scm/opensource/pjsdriver/vendor/mink/driver-testsuite/tests/Js/ChangeEventTest.php:50```
@jcalderonzumba
Copy link
Author

I can add more info.
The error seems to be on the file check, you gotta remember that phantomjs is like a real browser so you can not just call setValue for "input type file" as that is a completely different thing and phantomjs provides native methods to really input a file.

@stof
Copy link
Member

stof commented Nov 22, 2016

@jcalderonzumba well, you could handle it by moving some logic at the driver level for setValue instead of putting the whole logic in a JS block executed client-side. Selenium also requires a special code path for file uploads, but our Driver::setValue implementation takes care of this.

@jcalderonzumba
Copy link
Author

jcalderonzumba commented Nov 22, 2016

That's a good point. i'll add that in the todo. However the test itself is actually setting a string the file value, don't think that is accurate at least not for "real browsers"

@stof
Copy link
Member

stof commented Nov 22, 2016

@jcalderonzumba the value passed to Driver::setValue for a file field is the path to a file, because this is a sensible way to provide a file to the driver (we could pass it a File value object encapsulating the path, but I don't see the benefit).

We never said that this getter was equivalent to setting the value property in the DOM in Javascript (otherwise, it would not have support for select and radio/checkboxes either), and so I don't see the point of comparing it to what happens for "real browsers". This API is for people using Mink to say I want to put this value in the field, take care of it internally depending on the type of field so that I don't have to take care myself.

@jcalderonzumba
Copy link
Author

jcalderonzumba commented Nov 22, 2016

I understand that and that's why in my case is done on JS stuff (i need to change that to handle files properly).
My comment was actually focused on the test itself in this part:

public function setValueChangeEventDataProvider()
    {
        return array(
            'input default' => array('the-input-default', 'from empty', 'from existing'),
            'input text' => array('the-input-text', 'from empty', 'from existing'),
            'input email' => array('the-email', 'from empty', 'from existing'),
            'textarea' => array('the-textarea', 'from empty', 'from existing'),
            'file' => array('the-file', 'from empty', 'from existing'),
            'select' => array('the-select', '30'),
            'radio' => array('the-radio-m', 'm'),
        );
    }

on the file => array(...)
Should my implementation just ignore when a file value is not a file path and silently return a success? (once again, just asking opinion as i need to modify my driver).

@robertfausk
Copy link
Contributor

I think this can be closed regarding merged PR #26.

@stof stof closed this as completed Jun 19, 2019
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

3 participants