Skip to content

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

Closed

Description

@jcalderonzumba

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```

Activity

  1. jcalderonzumba commented on Nov 22, 2016

    @jcalderonzumba
    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.

  2. stof commented on Nov 22, 2016

    @stof
    Member

    @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.

  3. jcalderonzumba commented on Nov 22, 2016

    @jcalderonzumba
    Author

    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"

  4. stof commented on Nov 22, 2016

    @stof
    Member

    @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.

  5. jcalderonzumba commented on Nov 22, 2016

    @jcalderonzumba
    Author

    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).

  6. robertfausk commented on Mar 29, 2019

    @robertfausk
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions