public function run(array $context = []) { if (isset($context[self::CFG_DELAY_BASE]) && isset($context[self::CFG_DELAY_OFFSET]) && is_int($context[self::CFG_DELAY_BASE]) && is_int($context[self::CFG_DELAY_OFFSET])) { $this->delay->delayOffset($context[self::CFG_DELAY_BASE], $context[self::CFG_DELAY_OFFSET]); } else { $this->logger->warning('%s: No valid delay param found! Use default value instead.', [__CLASS__]); $this->delay->delayOffset(1000, 500); } }
/** * * @param array $assertion */ public function waitFor(array $assertion, $timeout = null, $delay = null) { Screen::assertRules($assertion); $timeout = is_int($timeout) && $timeout > 0 ? $timeout : $this->timeout; $delay = is_int($delay) && $delay > 0 ? $delay : $this->delay; $offset = intval($delay * 0.15); $waited = 0; while (!$this->screen->compareRules($assertion)) { $this->delay->delayOffset($delay, $offset); $waited += $delay; if ($waited > $timeout) { throw new \RuntimeException('Waiting for assertion timeout.'); } } }