public function __construct(WebDriverElement $element) { $tag_name = $element->getTagName(); if ($tag_name !== 'select') { throw new UnexpectedTagNameException('select', $tag_name); } $this->element = $element; $value = $element->getAttribute('multiple'); $this->isMulti = $value === 'true'; }
/** * Switch to the iframe by its id or name. * * @param WebDriverElement|string $frame The WebDriverElement, the id or the name of the frame. * @return WebDriver The driver focused on the given frame. */ public function frame($frame) { if ($frame instanceof WebDriverElement) { $id = array('ELEMENT' => $frame->getID()); } else { $id = (string) $frame; } $params = array('id' => $id); $this->executor->execute(DriverCommand::SWITCH_TO_FRAME, $params); return $this->driver; }
/** * Switch to the iframe by its id or name. * * @param WebDriverElement|string $frame The WebDriverElement, the id or the name of the frame. * @return WebDriver The driver focused on the given frame. */ public function frame($frame) { if ($frame instanceof WebDriverElement) { $id = array('ELEMENT' => $frame->getID()); } else { $id = (string) $frame; } $params = array('id' => $id); $this->executor->execute('focusFrame', $params); return $this->driver; }
/** * Test if two element IDs refer to the same DOM element. * * @param WebDriverElement $other * @return boolean */ public function equals(WebDriverElement $other) { try { return $this->element->equals($other); } catch (WebDriverException $exception) { $this->dispatchOnException($exception); } }
/** * Test if two element IDs refer to the same DOM element. * * @param WebDriverElement $other * @return bool */ public function equals(WebDriverElement $other) { return $this->executor->execute(DriverCommand::ELEMENT_EQUALS, array(':id' => $this->id, ':other' => $other->getID())); }
/** * Wait until an element is no longer attached to the DOM. * * @param WebDriverElement $element The element to wait for. * @return WebDriverExpectedCondition<bool> false if the element is still * attached to the DOM, true otherwise. */ public static function stalenessOf(WebDriverElement $element) { return new WebDriverExpectedCondition(function ($driver) use($element) { try { $element->isEnabled(); return false; } catch (StaleElementReferenceException $e) { return true; } }); }
/** * An helper function to ensure the new page is load after a click. * * @param WebDriverElement $webDriverElement the element to click. * * @return void */ public function clickToLoadNewPage($webDriverElement) { $webDriverElement->click(); try { while (true) { $webDriverElement->getText(); } } catch (StaleElementReferenceException $e) { return; } }
/** * Test if two element IDs refer to the same DOM element. * * @param WebDriverElement $other * @return bool */ public function equals(WebDriverElement $other) { return $this->executor->execute('elementEquals', array(':id' => $this->id, ':other' => $other->getID())); }
/** * @param WebDriverElement $element * @param int $xoffset * @param int $yoffset * * @return RemoteTouchScreen The instance. */ public function scrollFromElement(WebDriverElement $element, $xoffset, $yoffset) { $this->executor->execute(DriverCommand::TOUCH_SCROLL, array('element' => $element->getID(), 'xoffset' => $xoffset, 'yoffset' => $yoffset)); return $this; }
/** * Wait until an element is no longer attached to the DOM. * * @param WebDriverElement $element The element to wait for. * @return bool false if the element is still attached to the DOM, true * otherwise. */ public static function stalenessOf(WebDriverElement $element) { return new WebDriverExpectedCondition( function ($driver) use ($element) { try { $element->isEnabled(); return false; } catch (ObsoleteElementWebDriverError $e) { return true; } } ); }
/** * @return RemoteTouchScreen The instance. */ public function scrollFromElement(WebDriverElement $element, $xoffset, $yoffset) { $this->executor->execute('touchScroll', array('element' => $element->getID(), 'xoffset' => $xoffset, 'yoffset' => $yoffset)); return $this; }