Пример #1
0
 /**
  * Find the position and proportion of a DOM element, specified by it's ID.
  * The method inject the
  * JQuery Framework and uses the "noConflict"-mode to get the width, height and offset params.
  *
  * @param string $selector DOM ID/class of the element, which should be screenshotted
  * @return array coordinates of the element
  * @throws \Codeception\Exception\ElementNotFound
  */
 private function getCoordinates($selector = 'body')
 {
     try {
         $this->webDriverModule->waitForElementVisible($selector, 10);
         /** @var WebDriverElement|null $element */
         $element = $this->remoteWebDriver->findElement(WebDriverBy::cssSelector($selector));
     } catch (\Exception $e) {
         throw new ElementNotFound('Element ' . $selector . ' could not be located by WebDriver');
     }
     $elementSize = $element->getSize();
     $elementLocation = $element->getLocation();
     $imageCoords['x'] = $elementLocation->getX();
     $imageCoords['y'] = $elementLocation->getY();
     $imageCoords['width'] = $elementSize->getWidth();
     $imageCoords['height'] = $elementSize->getHeight();
     return $imageCoords;
 }
Пример #2
0
 public function testWebDriverWaits()
 {
     $fakeWd = Stub::make('\\Codeception\\Module\\WebDriver', ['wait' => Stub::exactly(12, function () {
         return new \Codeception\Util\Maybe();
     })]);
     $this->module->webDriver = $fakeWd;
     $this->module->waitForElement(WebDriverBy::partialLinkText('yeah'));
     $this->module->waitForElement(['id' => 'user']);
     $this->module->waitForElement(['css' => '.user']);
     $this->module->waitForElement('//xpath');
     $this->module->waitForElementVisible(WebDriverBy::partialLinkText('yeah'));
     $this->module->waitForElementVisible(['id' => 'user']);
     $this->module->waitForElementVisible(['css' => '.user']);
     $this->module->waitForElementVisible('//xpath');
     $this->module->waitForElementNotVisible(WebDriverBy::partialLinkText('yeah'));
     $this->module->waitForElementNotVisible(['id' => 'user']);
     $this->module->waitForElementNotVisible(['css' => '.user']);
     $this->module->waitForElementNotVisible('//xpath');
 }