-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The "wait()" does not work, when Zombie has empty event loop #167
Comments
Works for me. I'm using following:
And there is a test that proves that it should work. |
I've constructed NodeJS code (Zombie only, no Mink) example that is executed from your example: var zombie = require('zombie'),
browser = new zombie();
var checkCondition = function () {
return browser.evaluate('false');
};
browser.visit('http://www.google.com');
var $start = (new Date()).getTime();
browser.wait({function: checkCondition, duration: 5000}, function () {
console.log('condition at the end of wait: ', checkCondition());
});
var $duration = (new Date()).getTime() - $start;
console.log('duration: ', $duration, 's'); No matter what duration (in place of 5000) I specify waiting takes 1 or 2 seconds at random. The wait function in Zombie doesn't really tell that it will wait for element to appear (or any constant given time) before returning: https://github.com/assaf/zombie/blob/master/src/index.js#L242 I've created an issue for Zombie about this: assaf/zombie#1032 |
According to assaf/zombie#696 the @stof , I'm proposing to add tests, that assert that waiting actually performed given amount of seconds and rewrite waiting implementation in this driver to work as in Selenium2 (just PHP cycle with usleep and JS call inside it). |
Here is solution in JS. I haven't tested it too much, but it seems to be working for me. The interval of execution of condition check is hardcoded 100ms, but it should be parameter of the wait function.
|
@Ventzy , I somehow missed your comment back then. Please send a PR with proposed solution. Not sure why you need to use both interval and timer at the same time. I suggest doing this:
This is better, because |
wait()
does not work, when Zombie has empty event loop
wait()
does not work, when Zombie has empty event loop
It seems that
wait()
does not work, or I expect different behavior. I could not find any docs for browser.wait method in Zombie.So... I expect when I do
$session->wait(10000);
php script to "sleep" for 10 seconds and then resume. But it does not happen. Am I missing something?My use case is exactly as comment in Mink wait method - "Waits some time or until JS condition turns true." And I have it like that:
I want, if
.some-selector
appears on the page in next 1 second to get true, and if not - get false. But it does not wait a second and returns right away with false.The text was updated successfully, but these errors were encountered: