コード例 #1
0
 /**
  * Move to a frame element.
  * @param WebElement $frameElement
  * @return current WebDriver
  */
 public function getFrameByWebElement(WebElement $frameElement)
 {
     //We should validate that frameElement is string
     /*
     if (frameElement == null)
     {
     	throw new ArgumentNullException("frameElement", "Frame element cannot be null");
     }
     
     RemoteWebElement convertedElement = frameElement as RemoteWebElement;
     if (convertedElement == null)
     {
     	throw new ArgumentException("frameElement cannot be converted to RemoteWebElement", "frameElement");
     }
     */
     $frameId = $frameElement->getElementId();
     $target = array('ELEMENT' => $frameId);
     $this->_driver->getFrame($target);
     return $this->_driver;
 }
コード例 #2
0
 /**
  * Opens a new tab for the given URL
  * @param string $url The URL to open
  * @return string The handle of the previously active window
  * @see http://stackoverflow.com/a/9122450/650329
  * @throws SeleniumJavaScriptErrorException If unable to open tab
  */
 public function newTab($url)
 {
     $script = "var d=document,a=d.createElement('a');a.target='_blank';a.href='%s';a.innerHTML='.';d.body.appendChild(a);return a";
     $element = $this->_driver->executeScript(sprintf($script, $url));
     if (empty($element)) {
         throw new Exceptions\JavaScriptError('Unable to open tab');
     }
     $existingHandles = $this->_driver->getWindowHandles();
     $anchor = new WebElement($this->_driver, $element['ELEMENT']);
     $anchor->click();
     $this->_driver->executeScript('var d=document,a=arguments[0];a.parentNode.removeChild(a);', array($element));
     $newHandles = array_values(array_diff($this->_driver->getWindowHandles(), $existingHandles));
     $newHandle = $newHandles[0];
     $oldHandle = $this->_driver->getWindowHandle();
     $this->window($newHandle);
     return $oldHandle;
 }
コード例 #3
0
 /**
  * Test if two element refer to the same DOM element.
  * @param WebElement $webElementCompare
  * @return boolean
  */
 public function compareToOther(WebElement $webElementCompare)
 {
     $params = array('element_id' => $this->getElementId(), 'element_id_compare' => $webElementCompare->getElementId());
     $command = new Commands\Command($this->_driver, 'compare_to_other', null, $params);
     $results = $command->execute();
     return trim($results['value']) == "1";
 }