Web Driver Curl Exception

2020-04-03 07:32发布

问题:

Trying to use Codeception Web Driver and Selenium to emulate ajax through an acceptance test. I was using PhpBrowser but when I was having issues with Ajax my friend suggested WebDriver.

After enabling it and downloading the selenium (and running it) I get the following error.

[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session 
with params: {"desiredCapabilities":{"browserName":"googlechrome"}}
Failed to connect to 127.0.0.1 port 4444: Connection Refused

I made sure I was running selenium on port 4444.

 java -jar selenium-server.jar -port 4444

acceptance.suite.yml below

 class_name: AcceptanceTester
 modules:
     enabled:
         - WebDriver
         - REST
     config:
         WebDriver:
             url: 'http://life1605.dev'
             browser: googlechrome
         REST:
             url: 'http://life1605.dev'

回答1:

I had the same problem, with the exact same error message. For some strange reason, it looked like starting the selenium server from command line did not work.

My solution turned out to be manually opening the selenium server through Windows Explorer, right click on the file, choose Open with -> Java Platform SE Binary.

Took me almost 3 hours to figure it out, so I hope this helps somebody.



回答2:

I had this problem and it turned out a new version of Firefox was incompatible with the addon that Selenium uses to communicate with Firefox.

When you start your tests you should see the new Firefox window appear, and have 30 seconds or so before it goes away again. Within this time, if you type about:addons into the URL field and then click on "Extensions", you should see the "Firefox WebDriver" addon there, and it should be enabled.

For me it was disabled as it was incompatible with the latest Firefox version. So the solution in this case was to either downgrade Firefox or wait for an updated Selenium.

Note that the addon is only installed in the Firefox instance under test, so you won't see it when you use Firefox outside of Selenium.



回答3:

I had this same problem, I forgot to run phantom.js before trying to do any browser tests. I ran phantomjs and it worked.



回答4:

I had this problem, and then I remembered that I need to run Xvfb -ac :0 -screen 0 1280x1024x16 & after every Homestead reload (before running Dusk tests).

Then Dusk works instead of saying:

Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}

Operation timed out after 30000 milliseconds with 0 bytes received

See https://stackoverflow.com/a/42630737/470749