Exemplo n.º 1
0
 /**
  * Returns the current language
  * Use this only for asserts. If you only need the current language, use Helper::getCurrentLanguage().
  * @return string
  */
 public function getCurrentLanguage()
 {
     $languageKeys = array(1 => 'de', 2 => 'en');
     $languages = $this->findAll('css', Helper::getRequiredSelector($this, 'languages'));
     /** @var Element $language */
     foreach ($languages as $language) {
         if ($language->getAttribute('selected')) {
             return $languageKeys[$language->getAttribute('value')];
         }
     }
     return 'de';
 }
Exemplo n.º 2
0
 /**
  * Checks, whether a captcha exists and has loaded correctly
  * @throws \Exception
  */
 public function checkCaptcha()
 {
     $placeholderSelector = Helper::getRequiredSelector($this, 'captchaPlaceholder');
     if (!$this->getSession()->wait(5000, "\$('{$placeholderSelector}').children().length > 0")) {
         $message = 'The captcha was not loaded or does not exist!';
         Helper::throwException($message);
     }
     $element = Helper::findElements($this, ['captchaPlaceholder', 'captchaImage', 'captchaHidden']);
     $captchaPlaceholder = $element['captchaPlaceholder']->getAttribute('data-src');
     $captchaImage = $element['captchaImage']->getAttribute('src');
     $captchaHidden = $element['captchaHidden']->getValue();
     if (strpos($captchaPlaceholder, '/widgets/Captcha/refreshCaptcha') === false || strpos($captchaImage, 'data:image/png;base64') === false || empty($captchaHidden)) {
         $message = 'The captcha was not loaded correctly!';
         Helper::throwException($message);
     }
 }
Exemplo n.º 3
0
 /**
  * @param string $locator
  * @param  bool $throwException
  * @return bool
  */
 public function noElement($locator, $throwException = true)
 {
     if (Helper::getRequiredSelector($this, $locator)) {
         //previous or next
         $result = Helper::countElements($this, $locator);
     } else {
         //page number (1, 2, 3, 4, ...)
         $result = !$this->hasLink($locator);
     }
     if ($result === true) {
         return true;
     }
     if ($throwException) {
         $message = sprintf('The Paging Link "%s" exists, but should not!', $locator);
         Helper::throwException($message);
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Returns the text preview of the blog article
  * @param NodeElement $article
  * @return null|string
  */
 public function getTextProperty(NodeElement $article)
 {
     $selector = Helper::getRequiredSelector($this, 'articleText');
     return $article->find('css', $selector)->getText();
 }
Exemplo n.º 5
0
 /**
  * Helper method checks the ESD articles
  * @param string $date
  * @param array $articles
  * @throws \Exception
  */
 private function checkEsdArticles($date, array $articles)
 {
     $esd = array();
     foreach ($articles as $key => $article) {
         if (empty($article['esd'])) {
             continue;
         }
         $esd[] = $article['product'];
     }
     if (empty($esd)) {
         return;
     }
     $language = Helper::getCurrentLanguage($this);
     Helper::clickNamedLink($this, 'myEsdDownloads', $language);
     $locators = array('esdDownloads');
     $elements = Helper::findAllOfElements($this, $locators);
     $locator = Helper::getRequiredSelector($this, 'esdDownloadName');
     $downloads = array();
     /** @var NodeElement $esdDownload */
     foreach ($elements['esdDownloads'] as $esdDownload) {
         if (strpos($esdDownload->getText(), $date) !== false) {
             $downloads[] = $this->find('css', $locator)->getText();
         }
     }
     foreach ($esd as $givenEsd) {
         foreach ($downloads as $download) {
             if ($givenEsd === $download) {
                 break;
             }
             if ($download === end($downloads)) {
                 $message = sprintf('ESD-Article "%s" not found in account!', $givenEsd);
                 Helper::throwException($message);
             }
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Default method to get a slide property
  * @param NodeElement $slide
  * @param string $property
  * @return null|string
  */
 public function getSlideProperty(NodeElement $slide, $property)
 {
     $selector = Helper::getRequiredSelector($this, 'slide' . $property);
     return $slide->find('css', $selector)->getText();
 }
Exemplo n.º 7
0
 /**
  * @param NodeElement $slide
  * @return string
  */
 public function getLinkProperty(NodeElement $slide)
 {
     $selector = Helper::getRequiredSelector($this, 'slideLink');
     return $slide->find('css', $selector)->getAttribute('href');
 }
 /**
  * Returns the price
  * @param NodeElement $slide
  * @return float
  */
 public function getPriceProperty(NodeElement $slide)
 {
     $selector = Helper::getRequiredSelector($this, 'slidePrice');
     $price = $slide->find('css', $selector)->getText();
     return Helper::floatValue($price);
 }
Exemplo n.º 9
0
 /**
  * Returns the title-attribute of the slide
  * @param NodeElement $slide
  * @return string|null
  */
 protected function getTitleProperty(NodeElement $slide)
 {
     $selector = Helper::getRequiredSelector($this, 'slideImage');
     return $slide->find('css', $selector)->getAttribute('title');
 }
Exemplo n.º 10
0
 /**
  * Returns the price
  * @param NodeElement $slide
  * @return float
  */
 public function getPriceProperty(NodeElement $slide)
 {
     $selector = Helper::getRequiredSelector($this, 'slidePrice');
     preg_match('(\\d+,\\d{2})', $slide->find('css', $selector)->getHtml(), $price);
     return Helper::floatValue(current($price));
 }