andycha28 / php-webdriver-bindings

Automatically exported from code.google.com/p/php-webdriver-bindings
0 stars 0 forks source link

Exception in log when connecting to a browser #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the example test
2. See selenium server logs

What is the expected output? What do you see instead?
No exceptions in the log. Actually I see exception on getting session 
capabilities request. See 
http://code.google.com/p/selenium/issues/detail?id=2091

What version of the product are you using? On what operating system?

webdriver-bindings-1.0.zip Yii extension on Linux with Selenium server 2.1.

It looks like a bug on selenium server side. Or may be it only happens for 
specific version of browser, but here's how we can avoid this erro if when 
creating the new session we don't allow curl to follow redirects:
public function connect($browserName="firefox", $version="", $caps=array()) {

...

    $this->preparePOST($session, $postargs);
    curl_setopt($session, CURLOPT_HEADER, true);
    curl_setopt( $this->_curl, CURLOPT_FOLLOWLOCATION, false);
    $response = curl_exec($session);
    $headers = explode("\r\n", $response);
    foreach ($headers as $h) {
        if (strpos($h, 'Location:') === 0) {
            $url = substr($h, strlen('Location:'));
            $this->requestURL = trim($url);
            break;
        }
    }
}

Original issue reported on code.google.com by sergey.t...@gmail.com on 20 Jul 2011 at 12:24

GoogleCodeExporter commented 8 years ago
I am experiencing the same issue.  Will there be a fix for this soon?

Original comment by mmical...@gmail.com on 26 Jul 2011 at 2:19

GoogleCodeExporter commented 8 years ago
This issue is detailed here:
http://code.google.com/p/selenium/issues/detail?id=2091

A fix:
In file WebDriver.php, look for:

   public function connect($browserName="firefox", $version="", $caps=array()) {
...
...
...
        $this->preparePOST($session, $postargs);
        curl_setopt($session, CURLOPT_HEADER, true);
ADD THIS LINE -> curl_setopt($session, CURLOPT_HTTPHEADER,  
array('application/json;charset=UTF-8', 'Accept: application/json'));
        $response = curl_exec($session);
        $header = curl_getinfo($session);
        $this->requestURL = $header['url'];
...

Original comment by jaruz...@gmail.com on 18 Apr 2012 at 1:13