/** * 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(); }
/** * @throws \Exception */ private function pressShowResults() { $elements = Helper::findElements($this, ['filterShowResults']); /** @var NodeElement $showResults */ $showResults = $elements['filterShowResults']; $showResults->press(); }
/** * @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]; }
/** * 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(); }
/** * 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(); }
/** * @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; }
/** * @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; }
/** * @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); } }
/** * 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; }
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); } }
/** * 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]); } }
/** * @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(); } }
/** * 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); } }
/** * @return string */ public function getImageProperty() { $element = Helper::findElements($this, ['thumbnailImage']); return $element['thumbnailImage']->getAttribute('srcset'); }
/** * Returns the video code * @return array */ public function getCodeProperty() { $elements = Helper::findElements($this, ['code']); return $elements['code']->getAttribute('src'); }
/** * 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); }
/** * Remove the voucher from the cart * @throws \Behat\Mink\Exception\ResponseTextException */ public function removeVoucher() { $elements = Helper::findElements($this, ['removeVoucher']); $elements['removeVoucher']->click(); }
/** * 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() : ''; }
/** * 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(); }
/** * */ 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(); }
/** * @return float */ public function getStarsProperty() { $elements = Helper::findElements($this, ['stars']); return floatval($elements['stars']->getAttribute('content')) * 2; }
/** * Returns the category link * @return array */ public function getLinkProperty() { $elements = Helper::findElements($this, ['link']); return $elements['link']->getAttribute('href'); }
/** * @return string */ public function getRankingProperty() { $elements = Helper::findElements($this, ['stars']); $ranking = $elements['stars']->getAttribute('content'); return $ranking ? $ranking : '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); } }
/** * 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'); } }
/** * 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()); }