minkphp / MinkZombieDriver

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

Mink + Zombie Driver: Error while processing click and clickLink #145

Closed LogansUA closed 8 years ago

LogansUA commented 8 years ago

Hello everyone. I'm trying to do some thing using custom symfony console command. In console command i starting zombie session like in example:

/**
 * Start session
 */
public function startSession()
{
    $host = '127.0.0.1';
    $port = '8124';
    $node = '/home/oleg/.nvm/versions/io.js/v3.3.1/bin/iojs';

    $this->mink = new Mink([
        'zombie' => new Session(new ZombieDriver(new ZombieServer($host, $port, $node))),
    ]);

    $this->mink->setDefaultSessionName('zombie');
    $this->mink->getSession();
}

After that, i'm getting session and trying to execute some scenarios:

// Get session
$session = $this->scenarioService->getMink()->getSession('zombie');

// Scenario
$session->visit($site->getUrl());
$session->getPage()->clickLink('Some text');

HTML link view:

<li id="item-id">
     <a href="/some/specific/url?with=params">Some text</a>
</li>

And there come's error's: Sometimes getting this:

[Behat\Mink\Exception\DriverException]                                                                                                                                        
  Error while processing event 'click': "Error: Timeout: did not get to load all resources on this page
    at timeout (/usr/local/lib/node_modules/zombie/lib/eventloop.js:601:38)
    at Timer.listOnTimeout (timers.js:89:15)" 

And sometimes getting that:

[Behat\Mink\Exception\DriverException]                                                                                                                                        
  Error while processing event 'click': "TypeError: Cannot set property 'aborted' of null
    at XMLHttpRequest.abort (/usr/local/lib/node_modules/zombie/lib/xhr.js:57:23)
    at XMLHttpRequest.open (/usr/local/lib/node_modules/zombie/lib/xhr.js:74:12)
    at f (https://url.to.some.site/static/js/vendor/respond.min.js:6:748)
    at x (https://url.to.some.site/static/js/vendor/respond.min.js:6:3845)
    at Window.<anonymous> (https://url.to.some.site/static/js/vendor/respond.min.js:6:3923)
    at Window.window._evaluate (/usr/local/lib/node_modules/zombie/lib/document.js:253:155)
    at /usr/local/lib/node_modules/zombie/lib/eventloop.js:77:35
    at Immediate._onImmediate (/usr/local/lib/node_modules/zombie/lib/eventloop.js:676:13)
    at processImmediate [as _immediateCallback] (timers.js:371:17)" 

I have installed:

behat/mink-zombie-driver: ^1.3
behat/mink: ^1.7
iojs: v3.3.1
zombie: v4.2.1

Someone know what to do with this? :smile:

stof commented 8 years ago

this looks like errors in Zombie itself, so I suggest reporting them to zombie directly.

joelwurtz commented 8 years ago

This happens when the page load by the click takes more than 5 seconds to load (including assets like image / css / js)

We also got this issue because of a slow dependency.

However zombie supports an option when creating the browser to have a longer Timeout if needed: waitDuration.

AFAIK there is more options than timeout, maybe it would be nice to handle them when creating the browser instance in ZombieServer ?

Reference of options : https://github.com/assaf/zombie/blob/master/src/index.js#L30

aik099 commented 8 years ago

I see no problem in adding support for Zombie options on Server class (see https://github.com/minkphp/MinkZombieDriver/blob/master/src/NodeJS/Server.php#L73) by adding 7th constructor parameter. Then these options can be passed directly to created browser instances.

Unfortunately this alone won't make Behat users happier, because the MinkExtension part responsible for integration with Zombie needs to be updated as well so that zombie options can be specified via .behat.yml file.

Please send these PR's then (or at least one of them).

aik099 commented 8 years ago

Closing in favor of #154, where setting for zombie options is added.