screen icon indicating copy to clipboard operation
screen copied to clipboard

Timout function is not working

Open milen-penev opened this issue 8 years ago • 3 comments

In my php script setTimeout() function doesn't work. I tried everythink variant but the function doesn't work.

Here is my code

<?php

require_once '../autoload.php';

$websiteUrl = 'github.com';
$fileLocation = 'screen.png';


$screen = new Screen\Capture($websiteUrl);
$screen
    ->setWidth(1024)
    ->setHeight(500)
    ->setClipHeight(500)
	->setImageType('png')
	->setTimeout(6000)
    ->save($fileLocation, true);

Can someone to help me.

milen-penev avatar Dec 02 '16 14:12 milen-penev

How do you know that it does not work? Here is the definition of the timeout function

defines the timeout after which any resource requested will stop trying and proceed with other parts of the page.

So there might be many elements, one after another, each reaching the full timeout before passing along to the next function. In other words, it is not accumulative: if your timeout is set to 5 seconds, then you could have 12 separate elements, each successively reaching the timeout for a total of 60 seconds load time, and you are still working with a properly functioning script.

This is opposed to having a total timeout of 5 seconds for ALL elements, or for the entire page load time, which is what I thought it did when I posted #75

In the light of this, I would check the site that you are trying to load, or try to realize why PhantomJS is having a difficult time with it?

NOTE: You might want to consider being more specific when you raise an issue. Simply stating that:

setTimeout() function doesn't work

doesn't give anybody any real idea of what is actually happening with your situation, it limits what can be done for you, and might be why this issue has been so quiet.

joshp23 avatar Dec 16 '16 16:12 joshp23

I know this is an old issue, but I was looking for a way to wait before taking the screenshot. Turns out you have to use setDelay() and not setTimeout()

winkbrace avatar Jan 22 '19 17:01 winkbrace

Goto: \vendor\microweber\screen\src\Capture.php Goto Line 97: protected $timeout = 20000; //set this number in ms as you like Save!

alcogr avatar Apr 23 '19 19:04 alcogr