/** * Execute debugging * * @param callback|null $callback * @param int $timeout Timeout between checks */ public function execute(callable $callback = null, $timeout = 500000) { $this->originWindow = $this->driver->getWindowHandle(); $this->showPopup(); do { $isDebugging = true; try { $this->processDebugActions($callback); } catch (WebDriver\Exception\WebDriverException $e) { $isDebugging = false; } if ((bool) $this->executeScriptFunction('isCheckRequested()')) { $this->executeScriptFunction('unmarkCheckRequest()'); $placeholders = $this->executeScriptFunction('getPlaceholders()'); $this->driver->switchTo()->window($this->originWindow); $this->revertHighlighting(); $missedLocators = array(); $isSingleChecker = $this->executeScriptFunction('isSingleChecker()'); foreach ($this->getDebuggingLocators($placeholders) as $key => $locator) { try { if (count($this->driver->findElements($locator))) { $elements = $isSingleChecker ? array($this->driver->findElement($locator)) : $this->driver->findElements($locator); foreach ($elements as $element) { $this->addHighlightingElement($key, $locator, $element); } } else { $missedLocators[] = $key; } } catch (WebDriver\Exception\WebDriverException $e) { $missedLocators[] = $key; } } $this->highlightElements(); $this->executeScriptFunction('highlightLocators(' . json_encode($missedLocators) . ')'); } usleep($timeout); $isDebugging = $isDebugging && ($this->isPopupFocused() || self::WINDOW_NAME == (string) $this->driver->executeScript('return window.' . self::WINDOW_VARIABLE . '.name')); } while ($isDebugging); }
/** * Switch to another frame on the page. * * Example: * ``` html * <iframe name="another_frame" src="http://example.com"> * * ``` * * ``` php * <?php * # switch to iframe * $I->switchToIFrame("another_frame"); * # switch to parent page * $I->switchToIFrame(); * * ``` * * @param string|null $name */ public function switchToIFrame($name = null) { if (is_null($name)) { $this->webDriver->switchTo()->defaultContent(); } else { $this->webDriver->switchTo()->frame($name); } }