MinkExtension icon indicating copy to clipboard operation
MinkExtension copied to clipboard

Attaching file results in a zero sized file

Open bizmate opened this issue 9 years ago • 2 comments

Meta -

OS: Linux/Mac OSX 10.11.6

Selenium Version:
2.53.1 standalone, 2.53.1 grid (docker images), 3 (beta) Browser:
Chrome

Browser Version:
52.0.2743.116 (64-bit)

Expected Behavior -

file is filled with a non zero sized file, correct file

Actual Behavior -

File is attached with correct name, type, size

Steps preface

Created a GIST with all files. https://gist.github.com/bizmate/7559b5b91b615f65f95d77c4f876b007

  • Behat runs the selenium SendKeys with firefox/chrome. In the details of the GIST you can see the
  • page used/ just a simple page with a file input
  • description of all the setup in behat and also a description of what selenium drivers and versions used. We usually use docker containers to run selenium and also tried a standalone version to see the page running.
  • selenium.log shows at the end that Mink is sending the keys with 0 length
  • requests to selenium show the local path to file but I am not sure if this is enough, see the last request with file /v3/features/assets/wrongCoverArt.jpg

Steps to reproduce -

1 - attach a file to the page 2 - the page should have a correct File object in the file input, with non zero sized value and also trigger the change event on the file element

I hope the description is comprehensive. If I have skipped something pls let me know. I understand this might be a chrome driver / selenium problem so I am trying to clarify where the bug/problem is

bizmate avatar Sep 09 '16 10:09 bizmate

IS this the same issue? https://github.com/minkphp/MinkSelenium2Driver/issues/187

bizmate avatar Sep 09 '16 13:09 bizmate

For anyone stepping into this problem, solution with selenium remote web driver is to Zip and encode the file before sending it as detailed here https://github.com/minkphp/MinkSelenium2Driver/issues/187#issuecomment-112106857

This is also how the facebook php webdriver does it. https://github.com/facebook/php-webdriver/blob/7cfa09f0a50b5e93087a9dc0eb669bc559eb9961/lib/Remote/RemoteWebElement.php#L329

The above is just a workaround, in my opinion selenium2driver package should be able to handle this transparently

bizmate avatar Sep 12 '16 09:09 bizmate