minkphp / MinkZombieDriver

Zombie.js driver for Mink framework
41 stars 49 forks source link

Zombie return <html><head></head><body></body></html> #117

Closed bourg-ismael closed 9 years ago

bourg-ismael commented 9 years ago

Hi,

When I run my tests with zombie, my tests failed and return :

<html><head></head><body></body></html>

I tried without zombie and it work perfectly but when I use zombie I have this.

Here my behat.yml :

# behat.yml
default:
  extensions:
    Behat\MinkExtension\Extension:
      base_url: http://192.168.33.120/
      javascript_session: zombie
      goutte:
        guzzle_parameters:
          curl.options:
            CURLOPT_HTTPHEADER: ["Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4;"]
      selenium2: ~
      zombie: ~
aik099 commented 9 years ago

<html><head></head><body></body></html>

That is how blank page response looks like in Zombie.

I tried without zombie and it work perfectly but when I use zombie I have this.

Do you have access to Web Server access/error logs so you can see which pages Zombie is accessing and what he gets back. I'm wondering if Zombie isn't sending something or sending something extra that might force Web Server to return empty page back. Or maybe there is HTML parse error.

Any specific error you're getting back from Zombie on test fail?

bourg-ismael commented 9 years ago

This is my scenario result:

  @javascript
  Scenario: Login with clem_primary Then Logout                # features/CandidateMiniEval.feature:8
    Given I go to homepage                                     # FeatureContext::iAmOnHomepage()

|  http://192.168.33.120/
|  
|  <html><head></head><body></body></html>

    Then print last response                                   # FeatureContext::printLastResponse()
    When I fill in "login" with "test@domain.com" # FeatureContext::fillField()
      Form field with id|name|label|value "login" not found.

I checked my logs and I have no errors, I only checked apache2 logs and logs from the server that I registered

aik099 commented 9 years ago

So for that particular Zombie request the Web Server is returning 200 and valid HTML? Can you make curl/wget request to server to see what is returned?

bourg-ismael commented 9 years ago

Curl return : https://gist.github.com/bourg-ismael/4f3a325b6fb23d33a64d And Curl - I :

HTTP/1.1 200 OK
Date: Wed, 12 Nov 2014 14:26:54 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.13 ZendServer/7.0.0
Set-Cookie: PHPSESSID=j9im4pl1bs2j1m00bpb9vt2h0iimnmai; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html

To access to my website I have to add options :

curl -I 'http://192.168.33.120/register' -H 'Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4;'

This options are defined in Goutte

aik099 commented 9 years ago

I'm suspecting that web server might be responding differently to Zombie request, then to regular user request. It's like with RSS servers, they return HTML when asked by browser and return XML when asked by RSS reader.

Can you please try to log phpinfo() on that page when asked by Zombie and compare it to case, when asked by non-Zombie. Maybe something crucial is missing, that results in empty response that Zombie is getting.

aik099 commented 9 years ago

And you are adding that Accept-Language header in Zombie request as well?

bourg-ismael commented 9 years ago

I didn't ass Accept-Language to Zombie request ? How can I do this ? I just configured it goutte ? It's not enough ?

aik099 commented 9 years ago

I'm using Zombie directly through Mink, not via Behat, so I don't know. But at the end you make setRequestHeader call to the Zombie (https://github.com/Behat/MinkZombieDriver/blob/master/src/Behat/Mink/Driver/ZombieDriver.php#L209).

@stof , I haven't found any example in docs on how to set headers via .behat.yml either. Please help.

bourg-ismael commented 9 years ago

But I don't think that it's a problem with the Header, with goutte when I didn't set the header I had a connection refused not an empty return

aik099 commented 9 years ago

In other words: no header = empty response and you say it's not problem with a header. :smile:

bourg-ismael commented 9 years ago

Hum yeah your right :p

aik099 commented 9 years ago

Here is documentation page I was able to find: https://github.com/Behat/MinkExtension/blob/master/doc/index.rst but no mention about way of setting request headers in driver-agnostic way.

I recommend digging out into MinkExtension code in places where parameters are parsed from .behat.yml and session is started and add a way for adding headers and send a PR.

aik099 commented 9 years ago

Another way would to be create beforeScenario hook and just do

$this->getSession()->setRequestHeader('Accept-Language', 'value')
bourg-ismael commented 9 years ago

I will try it thanks a lot

bourg-ismael commented 9 years ago

I tried this :

    /**
     * @Given /^init curl$/
     */
    public function curlInit()
    {
        $this->getSession()->setRequestHeader('Accept-Language', 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4;');
    }

But I got this error :

Given init curl                                            # FeatureContext::curlInit()
      Request header "Accept-Language" manipulation is not supported by Behat\Mink\Driver\ZombieDriver
aik099 commented 9 years ago

Are you sure, that you're using the 1.2.0 driver version, that supports this?

bourg-ismael commented 9 years ago

Right I didn't had the right version of Zombie so now it's ok !

Now I have this error : https://gist.github.com/bourg-ismael/882160069ef30e77b968

aik099 commented 9 years ago

Right I didn't had the right version of Zombie so now it's ok !

Great.

Now I have this error: https://gist.github.com/bourg-ismael/882160069ef30e77b968

Please file separate task about this, because it's clearly a different issue. While you're at it also attach gist with HTML content of that page.