Наследование: extends Container
    /**
     * Selects a value in a radio button group
     *
     * @param Element $element An element referencing one of the radio buttons of the group
     * @param string  $value   The value to select
     *
     * @throws DriverException when the value cannot be found
     */
    private function selectRadioValue(Element $element, $value)
    {
        // short-circuit when we already have the right button of the group to avoid XPath queries
        if ($element->attribute('value') === $value) {
            $element->click();
            return;
        }
        $name = $element->attribute('name');
        if (!$name) {
            throw new DriverException(sprintf('The radio button does not have the value "%s"', $value));
        }
        $formId = $element->attribute('form');
        try {
            if (null !== $formId) {
                $xpath = <<<'XPATH'
//form[@id=%1$s]//input[@type="radio" and not(@form) and @name=%2$s and @value = %3$s]
|
//input[@type="radio" and @form=%1$s and @name=%2$s and @value = %3$s]
XPATH;
                $xpath = sprintf($xpath, $this->xpathEscaper->escapeLiteral($formId), $this->xpathEscaper->escapeLiteral($name), $this->xpathEscaper->escapeLiteral($value));
                $input = $this->wdSession->element('xpath', $xpath);
            } else {
                $xpath = sprintf('./ancestor::form//input[@type="radio" and not(@form) and @name=%s and @value = %s]', $this->xpathEscaper->escapeLiteral($name), $this->xpathEscaper->escapeLiteral($value));
                $input = $element->element('xpath', $xpath);
            }
        } catch (NoSuchElement $e) {
            $message = sprintf('The radio group "%s" does not have an option "%s"', $name, $value);
            throw new DriverException($message, 0, $e);
        }
        $input->click();
    }
Пример #2
0
 /**
  * Close existing session
  *
  * @static
  * @return void
  */
 public static function closeSession()
 {
     if (self::activeSessionExists()) {
         Menta_Events::dispatchEvent('before_session_close', array('session' => self::$session));
         self::$session->close();
         self::$session = NULL;
         Menta_Events::dispatchEvent('after_session_close');
     }
 }
Пример #3
0
 /**
  * Continuously poll the page, until you find an element
  * with the given name or id.
  *
  * @param  string  $element
  * @param  integer $timeout
  * @return static
  */
 public function waitForElement($element, $timeout = 5000)
 {
     $this->session->timeouts()->postImplicit_wait(['ms' => $timeout]);
     try {
         $this->findByNameOrId($element);
     } catch (InvalidArgumentException $e) {
         throw new InvalidArgumentException("Hey, what's happening... Look, I waited {$timeout} milliseconds to see an element with " . "a name or id of '{$element}', but no luck. \nIf you could take a look, that'd be greaaattt...");
     }
     return $this;
 }
Пример #4
0
 /**
  * Set the dimensions of the window.
  *
  * @param integer $width set the window width, measured in pixels
  * @param integer $height set the window height, measured in pixels
  * @param string $name window name (null for the main window)
  */
 public function resizeWindow($width, $height, $name = null)
 {
     return $this->wdSession->window($name ? $name : '')->postSize(array('width' => $width, 'height' => $height));
 }
Пример #5
0
 /**
  * Resize current window
  *
  * Example:
  * ``` php
  * <?php
  * $I->resizeWindow(800, 600);
  *
  * ```
  *
  * @param int    $width
  * @param int    $height
  * @author Jaik Dean <*****@*****.**>
  */
 public function resizeWindow($width, $height)
 {
     $this->webDriverSession->window('current')->postSize(array('width' => $width, 'height' => $height));
 }
Пример #6
0
 public function dontSeeInTitle($title)
 {
     $this->assertNotContains($title, $this->webDriverSession->title(), "page title contains {$title}");
 }