Exemplo n.º 1
0
 /**
  * Fills the notification form and submits it
  * @param string $email
  */
 public function submitNotification($email)
 {
     $data = [['field' => 'sNotificationEmail', 'value' => $email]];
     Helper::fillForm($this, 'notificationForm', $data);
     $elements = Helper::findElements($this, ['notificationSubmit']);
     $elements['notificationSubmit']->press();
 }
Exemplo n.º 2
0
 /**
  * @throws \Exception
  */
 private function pressShowResults()
 {
     $elements = Helper::findElements($this, ['filterShowResults']);
     /** @var NodeElement $showResults */
     $showResults = $elements['filterShowResults'];
     $showResults->press();
 }
Exemplo n.º 3
0
 /**
  * @param array $data
  */
 public function subscribeNewsletter(array $data)
 {
     Helper::fillForm($this, 'newsletterForm', $data);
     $locators = array('newsletterFormSubmit');
     $elements = Helper::findElements($this, $locators);
     $elements['newsletterFormSubmit']->press();
 }
 /**
  * Returns the current payment method
  * @return string
  */
 public function getPaymentMethodProperty()
 {
     $element = Helper::findElements($this, ['currentMethod']);
     $currentMethod = $element['currentMethod']->getText();
     $currentMethod = str_word_count($currentMethod, 1);
     return $currentMethod[0];
 }
Exemplo n.º 5
0
 /**
  * Submits the filters
  * @throws \Exception
  */
 private function pressShowResults()
 {
     $this->getSession()->wait(5000, "\$('.filter--btn-apply:not(.is--loading):not([disabled=disabled])').length > 0");
     $elements = Helper::findElements($this, ['filterShowResults']);
     /** @var NodeElement $showResults */
     $showResults = $elements['filterShowResults'];
     $showResults->press();
 }
Exemplo n.º 6
0
 /**
  * Fills the notification form and submits it
  * @param string $email
  */
 public function submitNotification($email)
 {
     $data = array(array('field' => 'sNotificationEmail', 'value' => $email));
     Helper::fillForm($this, 'notificationForm', $data);
     $locators = array('notificationSubmit');
     $elements = Helper::findElements($this, $locators);
     $elements['notificationSubmit']->press();
 }
Exemplo n.º 7
0
 /**
  * @param array $locators
  * @return array
  */
 public function getProperties(array $locators)
 {
     $return = array();
     $elements = Helper::findElements($this, $locators);
     foreach ($elements as $locator => $element) {
         $funcName = 'get' . ucfirst($locator);
         $return[$locator] = $this->{$funcName}($element);
     }
     return $return;
 }
Exemplo n.º 8
0
 /**
  * @param string $propertyName
  * @return bool
  */
 public function setProperty($propertyName)
 {
     $elements = Helper::findElements($this, ['properties']);
     /** @var NodeElement $propertyContainer */
     $propertyContainer = $elements['properties'];
     if (!$propertyContainer->hasLink($propertyName)) {
         return false;
     }
     $propertyContainer->clickLink($propertyName);
     return true;
 }
Exemplo n.º 9
0
 /**
  * @inheritdoc
  */
 protected function checkRating(BlogComment $blogComments, $average)
 {
     $elements = Helper::findElements($this, ['articleRating', 'articleRatingCount']);
     $check = ['articleRating' => [$elements['articleRating']->getAttribute('content'), $average], 'articleRatingCount' => [$elements['articleRatingCount']->getText(), count($blogComments)]];
     $check = Helper::floatArray($check);
     $result = Helper::checkArray($check);
     if ($result !== true) {
         $message = sprintf('There was a different value of the rating! (%s: "%s" instead of "%s")', $result, $check[$result][0], $check[$result][1]);
         Helper::throwException($message);
     }
 }
Exemplo n.º 10
0
 /**
  * Sets a property, returns false, if the property doesn't exist, otherwise true on success
  * @param string $propertyName
  * @return bool
  */
 public function setProperty($propertyName)
 {
     $this->expandProperties();
     $elements = Helper::findElements($this, ['properties']);
     /** @var NodeElement $propertyContainer */
     $propertyContainer = $elements['properties'];
     if (!$propertyContainer->hasField($propertyName)) {
         return false;
     }
     $propertyContainer->checkField($propertyName);
     return true;
 }
Exemplo n.º 11
0
 public function checkCaptcha()
 {
     $locators = array('captchaPlaceholder', 'captchaImage', 'captchaHidden');
     $element = Helper::findElements($this, $locators);
     $captchaPlaceholder = $element['captchaPlaceholder']->getAttribute('data-src');
     $captchaImage = $element['captchaImage']->getAttribute('src');
     $captchaHidden = $element['captchaHidden']->getValue();
     if ($captchaPlaceholder !== '/shopware/widgets/Captcha/refreshCaptcha' || strpos($captchaImage, 'data:image/png;base64') === false || empty($captchaHidden)) {
         $message = 'There is no capture in this form!';
         Helper::throwException($message);
     }
 }
Exemplo n.º 12
0
 /**
  * Checks if the robots meta exists and matches the expected content
  *
  * @param $content
  */
 public function checkRobots($content = [])
 {
     $elements = Helper::findElements($this, ['robots']);
     $robotsElement = $elements['robots'];
     $robotsValue = $robotsElement->getAttribute('content');
     $robotsParts = explode(',', $robotsValue);
     $robotsParts = array_map('trim', $robotsParts);
     if (empty($robotsParts)) {
         Helper::throwException(['Missing robots data']);
     }
     if ($robotsParts != $content) {
         $message = sprintf('Canonical link "%s" does not match expected value "%s"', implode(', ', $robotsParts), implode(', ', $content));
         Helper::throwException([$message]);
     }
 }
Exemplo n.º 13
0
 /**
  * @param $direction
  * @param int $steps
  */
 public function moveDirection($direction, $steps = 1)
 {
     $locator = array(strtolower($direction));
     $elements = Helper::findElements($this, $locator);
     for ($i = 0; $i < $steps; $i++) {
         $result = Helper::countElements($this, $direction, 1);
         if ($result !== true) {
             $result = Helper::countElements($this, $direction, 2);
         }
         if ($result !== true) {
             Helper::throwException(array(sprintf('There is no more "%s" button! (after %d steps)', $direction, $i)));
         }
         $elements[$direction]->click();
     }
 }
Exemplo n.º 14
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.º 15
0
 /**
  * @return string
  */
 public function getImageProperty()
 {
     $element = Helper::findElements($this, ['thumbnailImage']);
     return $element['thumbnailImage']->getAttribute('srcset');
 }
Exemplo n.º 16
0
 /**
  * Returns the video code
  * @return array
  */
 public function getCodeProperty()
 {
     $elements = Helper::findElements($this, ['code']);
     return $elements['code']->getAttribute('src');
 }
Exemplo n.º 17
0
 /**
  * Returns the link to the product
  * @return string
  */
 public function getLinkProperty()
 {
     $elements = Helper::findElements($this, ['name', 'thumbnailLink', 'detailLink']);
     $names = array('articleNameLink' => $elements['name']->getAttribute('href'), 'articleThumbnailLink' => $elements['thumbnailLink']->getAttribute('href'), 'articleDetailLink' => $elements['detailLink']->getAttribute('href'));
     return Helper::getUnique($names);
 }
Exemplo n.º 18
0
 /**
  * Remove the voucher from the cart
  * @throws \Behat\Mink\Exception\ResponseTextException
  */
 public function removeVoucher()
 {
     $elements = Helper::findElements($this, ['removeVoucher']);
     $elements['removeVoucher']->click();
 }
Exemplo n.º 19
0
 /**
  * Remove the voucher from the cart
  * @throws \Behat\Mink\Exception\ResponseTextException
  */
 public function removeVoucher()
 {
     $locator = array('removeVoucher');
     $elements = Helper::findElements($this, $locator);
     $elements['removeVoucher']->click();
 }
 /**
  * Returns the shop owners answer to customers evaluation
  * @return string
  */
 public function getAnswerProperty()
 {
     $elements = Helper::findElements($this, ['answer'], false);
     return $elements['answer'] ? $elements['answer']->getText() : '';
 }
Exemplo n.º 21
0
 /**
  * Returns the order number
  * @return string
  */
 public function getNumberProperty()
 {
     $elements = Helper::findElements($this, ['number', 'footerNumber']);
     $numbers = ['orderNumber' => $elements['number']->getText(), 'footerNumber' => $elements['footerNumber']->getText()];
     return Helper::getUnique($numbers);
 }
 public function getPaymentMethodProperty()
 {
     $element = Helper::findElements($this, ['currentMethod']);
     return $element['currentMethod']->getText();
 }
Exemplo n.º 23
0
 /**
  *
  */
 public function clickCart()
 {
     $element = Helper::findElements($this, 'link');
     $element['link']->click();
 }
 /**
  * Default method to get an element property
  * @param string $property
  * @return null|string
  */
 public function getProperty($property)
 {
     $element = Helper::findElements($this, array($property));
     return $element[$property]->getText();
 }
Exemplo n.º 25
0
 /**
  * @return float
  */
 public function getStarsProperty()
 {
     $elements = Helper::findElements($this, ['stars']);
     return floatval($elements['stars']->getAttribute('content')) * 2;
 }
Exemplo n.º 26
0
 /**
  * Returns the category link
  * @return array
  */
 public function getLinkProperty()
 {
     $elements = Helper::findElements($this, ['link']);
     return $elements['link']->getAttribute('href');
 }
Exemplo n.º 27
0
 /**
  * @return string
  */
 public function getRankingProperty()
 {
     $elements = Helper::findElements($this, ['stars']);
     $ranking = $elements['stars']->getAttribute('content');
     return $ranking ? $ranking : '0';
 }
Exemplo n.º 28
0
 public function checkPayment($payment)
 {
     $locators = array('payment');
     $elements = Helper::findElements($this, $locators);
     if (strcmp($elements['payment']->getText(), $payment) !== 0) {
         $message = sprintf('The current payment method is %s! (should be %s)', $elements['payment']->getText(), $payment);
         Helper::throwException($message);
     }
 }
Exemplo n.º 29
0
 /**
  * Sets the configuration of a configurator article
  * @param array[] $configuration
  */
 public function configure(array $configuration)
 {
     $configuratorType = '';
     if ($this->getSession()->getDriver() instanceof GoutteDriver) {
         $element = Helper::findElements($this, ['configuratorForm']);
         $configuratorClass = $element['configuratorForm']->getAttribute('class');
         $configuratorType = array_search($configuratorClass, $this->configuratorTypes);
     }
     foreach ($configuration as $group) {
         $field = sprintf('group[%d]', $group['groupId']);
         $this->selectFieldOption($field, $group['value']);
         if ($configuratorType === 'select') {
             $this->pressButton('recalc');
         }
     }
     if ($configuratorType === 'select') {
         return;
     }
     if ($this->getSession()->getDriver() instanceof GoutteDriver) {
         $this->pressButton('recalc');
     }
 }
Exemplo n.º 30
0
 /**
  * Helper method to read a float property
  * @param string $propertyName
  * @return float
  */
 protected function getFloatProperty($propertyName)
 {
     $element = Helper::findElements($this, [$propertyName]);
     return Helper::floatValue($element[$propertyName]->getText());
 }