Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Session interaction timing out for a particular site #55

Open
jcjmcclean opened this issue Jan 28, 2015 · 4 comments
Open

Session interaction timing out for a particular site #55

jcjmcclean opened this issue Jan 28, 2015 · 4 comments

Comments

@jcjmcclean
Copy link

I'm experiencing an issue using Mink to control Firefox through Sahi where when I try to interact with the session in any way (e.g. running getPage()->getContent() or simply wait(2000)) I don't get the expected response and Mink eventually times out.

I've used the exact same code for various other websites and it works perfectly. This one single website seems to be stopping either Mink or Sahi from providing a response. I can't seem to find any reliable way of debugging the issue, all I can do is wait for the timeout to occur.

The code I'm using to retrieve the markup from a page is as follows:

// Configure driver
$this->driver = new \Behat\Mink\Driver\SahiDriver('firefox',
    new \Behat\SahiClient\Client(
        new \Behat\SahiClient\Connection(null, CRAWL_SERVER, 9999)
    )
);

// Init session:
$this->session = new \Behat\Mink\Session($this->driver);

// Start session:
$this->session->start();

// Open the url
$this->session->visit($config['url']);

// Get the markup from the page
$markup = $this->session->getPage()->getContent();

The page I'm trying to scrape is: https://www.o2.co.uk/shop/phones/

I also have a post up on on Stack Overflow here.

I'm using Mink 1.6 - installed using composer on 27/11/2014

tl;dr Why is Mink/Sahi timing out on this site?

@aik099
Copy link
Member

aik099 commented Jan 28, 2015

This might as well be Sahi only issue. In fact you can debug Sahi communications and requests made to SahiClient. Can you do that?

@aik099
Copy link
Member

aik099 commented Jan 28, 2015

What I need to know is actual API call that is made to Sahi that causes that error. Then we can Google that and see if anybody else had similar problem.

@jcjmcclean
Copy link
Author

@aik099 I'm pretty new to Sahi and Mink and I'm not sure how to debug Sahi communications/requests made to SahiClient. Could you point me in the right direction?

@aik099
Copy link
Member

aik099 commented Jan 28, 2015

Have you considered changing driver in in Mink from Sahi to say Selenium2? If you've not using Sahi-specific functionality, then this should be pretty easy.

I guess that you need to start with is creating a standalone reproducible test case in driver's test suite:

  1. clone the repo of the driver
  2. install Composer dependencies
  3. add test to the https://github.com/minkphp/MinkSahiDriver/blob/master/tests/Custom/ExtraTest.php class ( open page > get it's contents > assert something in the content)
  4. run tests

You should see your test fails due timeout or exception about that timeout. Then you can place breakpoint in getContent method call and debug the test safely.

You should have sahi running somewhere for all that to work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants