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

File Upload - Invalid argument supplied for foreach() #170

Closed
ssfinney opened this issue Oct 20, 2014 · 10 comments
Closed

File Upload - Invalid argument supplied for foreach() #170

ssfinney opened this issue Oct 20, 2014 · 10 comments

Comments

@ssfinney
Copy link

I'm using Codeception with the Facebook WebDriver module, Selenium 2, and PhantomJS on a Jenkins server that runs builds for me. The errors only occur on the Jenkins server (an Ubuntu box), not on my local Mac OS X machine.

I'm getting Invalid argument supplied for foreach(). Here's the stack trace:

#1  /var/lib/jenkins/workspace/project-name-feature__/vendor/facebook/webdriver/lib/WebDriverKeys.php:104
#2  /var/lib/jenkins/workspace/project-name-feature__/vendor/facebook/webdriver/lib/remote/RemoteWebElement.php:266
#3  /var/lib/jenkins/workspace/project-name-feature__/app/tests/acceptance/AcceptanceTester.php:1427
#4  /var/lib/jenkins/workspace/project-name-feature__/app/tests/acceptance/FooBarCest.php:54

I'm using the attachFile method in Codeception, which simply passes a CSS selector and a file path.

I've traced this back as far as it will go. The problem originates when the WebDriver sends the "sendFile" command inside webdriver/lib/remote/HttpCommandExecutor.php , which sends a POST through curl to /session/<session_id>/file, but the response returns with a value and session_id of null.

The null value gets passed back up to the upload method in webdriver/lib/remote/RemoteWebElement.php. Those values get passed back to the sendKeys method in the same file, which calls WebDriverKeys::encode. In the encode method, the foreach fails because of null values.

I've been chasing this bug for days. Do you have any ideas?

Here's the JSON response of the curl POST.

Array
(
    [value] =>
    [info] => Array
    (
        [url] => http://127.0.0.1:4444/wd/hub/session/8cbe52b0-5887-11e4-b0cf-8dd06ef908a2/file
        [content_type] => text/plain
        [http_code] => 405
        [header_size] => 100
        [request_size] => 213
        [filetime] => -1
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 2.004951
        [namelookup_time] => 2.5E-5
        [connect_time] => 0.000275
        [pretransfer_time] => 0.000276
        [size_upload] => 3614
        [size_download] => 4215
        [speed_download] => 2102
        [speed_upload] => 1802
        [download_content_length] => 4215
        [upload_content_length] => 3614
        [starttransfer_time] => 2.002198
        [redirect_time] => 0
        [certinfo] => Array
        (
        )

        [primary_ip] => 127.0.0.1
        [primary_port] => 4444
        [local_ip] => 127.0.0.1
        [local_port] => 57884
        [redirect_url] =>
    )
    [sessionId] =>
)
@leex
Copy link

leex commented Nov 4, 2014

I have the same issue, also on ubuntu. I've only tried using PhantonJS.

@whhone
Copy link
Contributor

whhone commented Nov 5, 2014

I am looking. It would be very helpful If there is a way for reproducing. The HTTP code is 405 Method Not Allowed.

@leex
Copy link

leex commented Nov 5, 2014

whhone if I get spare time I will try to reproduce, I'm using Webdriver via Codeception.

phantomjs version 1.9.7 x86

If this helps:

https://gist.github.com/anonymous/078807e20e053ee594d8

@whhone
Copy link
Contributor

whhone commented Nov 5, 2014

@leex What is the version of PHP you are using?

@leex
Copy link

leex commented Nov 5, 2014

@ssfinney
Copy link
Author

ssfinney commented Nov 5, 2014

@whhone I'm on PHP 5.4.27

@ssfinney
Copy link
Author

Is there any update on this, or can I provide any more information for you?

@alvaxet
Copy link

alvaxet commented Dec 4, 2014

I'm having the same issue. If I can help somehow to fix, please let me know

@gfosco
Copy link
Contributor

gfosco commented May 12, 2015

Closing this as it is over 6 months old. If it is still an issue, please create a new issue with as much current reproduction information as possible. Thanks.

@gfosco gfosco closed this as completed May 12, 2015
@ssfinney
Copy link
Author

With the newest versions of Selenium, PhantomJS, and the webdriver module in Codeception, this issue seems to have been fixed along the way.

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

5 participants