Пример #1
0
 /**
  * Fill condition options
  *
  * @param array $fields
  * @param SimpleElement|null $element
  * @return void
  */
 public function fillFormTab(array $fields, SimpleElement $element = null)
 {
     $data = $this->dataMapping($fields);
     $conditionsBlock = Factory::getBlockFactory()->getMagentoCatalogRuleConditions($element->find($this->ruleConditions));
     $conditionsBlock->clickAddNew();
     $conditionsBlock->selectCondition($data['condition_type']['value']);
     $conditionsBlock->clickEllipsis();
     $conditionsBlock->selectConditionValue($data['condition_value']['value']);
 }
Пример #2
0
 /**
  * Get data options from 'Tier price' form.
  *
  * @param array $fields
  * @param SimpleElement|null $element
  * @return array
  */
 public function getDataOptions(array $fields = null, SimpleElement $element = null)
 {
     $data = [];
     if (isset($fields['value']) && is_array($fields['value'])) {
         foreach ($fields['value'] as $key => $option) {
             $data[$key++] = parent::getDataOptions($option, $element->find('tbody tr:nth-child(' . $key . ')'));
         }
     }
     return $data;
 }
Пример #3
0
 /**
  * Get rating vote
  *
  * @param SimpleElement $rating
  * @return int
  */
 protected function getRatingVote(SimpleElement $rating)
 {
     $ratingVote = 5;
     $ratingVoteElement = $rating->find(sprintf($this->checkedRating, $ratingVote));
     while (!$ratingVoteElement->isVisible() && $ratingVote) {
         --$ratingVote;
         $ratingVoteElement = $rating->find(sprintf($this->checkedRating, $ratingVote));
     }
     return $ratingVote;
 }
Пример #4
0
 /**
  * Fill data to labels fields on labels tab.
  *
  * @param array $fields
  * @param Element|null $element
  * @return $this
  */
 public function fillFormTab(array $fields, Element $element = null)
 {
     if (isset($fields['store_labels'])) {
         $count = 0;
         foreach ($fields['store_labels']['value'] as $storeLabel) {
             $element->find(sprintf(self::STORE_LABEL_NAME, $count))->setValue($storeLabel);
             ++$count;
         }
     }
     return $this;
 }
 /**
  * Fill data to fields on tab
  *
  * @param array $fields
  * @param SimpleElement|null $element
  * @return $this
  */
 public function fillFormTab(array $fields, SimpleElement $element = null)
 {
     if (isset($fields['grouped_products'])) {
         foreach ($fields['grouped_products']['value'] as $groupedProduct) {
             $element->find($this->addNewOption)->click();
             $searchBlock = $this->getSearchGridBlock();
             $searchBlock->searchAndSelect($groupedProduct['search_data']);
             $searchBlock->addProducts();
             $this->getListAssociatedProductsBlock()->fillProductOptions($groupedProduct['data']);
         }
     }
     return $this;
 }
Пример #6
0
 /**
  * Fill data to fields on tab
  *
  * @param array $fields
  * @param SimpleElement|null $element
  * @return $this
  */
 public function fillFormTab(array $fields, SimpleElement $element = null)
 {
     if (isset($fields['associated'])) {
         $options = $this->_rootElement->getElements($this->deleteButton);
         if (count($options)) {
             foreach (array_reverse($options) as $option) {
                 $option->click();
             }
         }
         foreach ($fields['associated']['value']['assigned_products'] as $key => $groupedProduct) {
             $element->find($this->addNewOption)->click();
             $searchBlock = $this->getSearchGridBlock();
             $searchBlock->searchAndSelect(['name' => $groupedProduct['name']]);
             $searchBlock->addProducts();
             $this->getListAssociatedProductsBlock()->fillProductOptions($groupedProduct, $key + 1);
         }
     }
     return $this;
 }
Пример #7
0
 /**
  * Return request details.
  *
  * @param SimpleElement $context
  * @return array
  */
 protected function getRequestDetails(SimpleElement $context)
 {
     $mapping = $this->dataMapping();
     $mappingDetails = $mapping['details']['value'];
     $data = [];
     unset($mappingDetails['composite']);
     foreach ($mappingDetails as $fieldName => $locator) {
         $element = $context->find($locator['selector'], $locator['strategy']);
         if ($element->isVisible()) {
             $data[$fieldName] = trim($element->getText());
         }
     }
     if (isset($data['entity_id'])) {
         $data['entity_id'] = str_replace('#', '', $data['entity_id']);
     }
     if (isset($data['order_id'])) {
         $data['order_id'] = str_replace('#', '', $data['order_id']);
     }
     return $data;
 }
 /**
  * @constructor
  * @param DriverInterface $driver
  * @param EventManagerInterface $eventManager
  * @param Locator $locator
  * @param ElementInterface $context
  */
 public function __construct(DriverInterface $driver, EventManagerInterface $eventManager, Locator $locator, ElementInterface $context = null)
 {
     parent::__construct($driver, $eventManager, $locator, $context);
     $this->attributeLabel = $this->getAttributeLabelFromPage();
 }
Пример #9
0
 /**
  * Fill data to content fields on content tab.
  *
  * @param array $fields
  * @param SimpleElement|null $element
  * @return $this
  */
 public function fillFormTab(array $fields, SimpleElement $element = null)
 {
     $element->find($this->content)->setValue($fields['content']['value']['content']);
     if (isset($fields['content_heading']['value'])) {
         $element->find($this->contentHeading)->setValue($fields['content_heading']['value']);
     }
     if (isset($fields['content']['value']['widget']['dataset'])) {
         foreach ($fields['content']['value']['widget']['dataset'] as $widget) {
             $this->clickInsertWidget();
             $this->getWidgetBlock()->addWidget($widget);
         }
     }
     if (isset($fields['content']['value']['variable'])) {
         $this->clickInsertVariable();
         $config = $this->getWysiwygConfig();
         $config->selectVariableByName($fields['content']['value']['variable']);
     }
     return $this;
 }
Пример #10
0
 /**
  * Click "Pay Now" button.
  *
  * @param SimpleElement $element
  * @return void
  */
 public function clickPayNow(SimpleElement $element)
 {
     $element->find($this->continue)->click();
     $this->browser->selectWindow();
 }
Пример #11
0
 /**
  * Assign product to variation matrix
  *
  * @param SimpleElement $variationRow
  * @param int $productId
  * @return void
  */
 protected function assignProduct(SimpleElement $variationRow, $productId)
 {
     $variationRow->find($this->configurableAttribute)->click();
     $this->getTemplateBlock()->waitLoader();
     $this->_rootElement->find(sprintf($this->selectAssociatedProduct, $productId), Locator::SELECTOR_XPATH)->click();
 }
Пример #12
0
 /**
  * Get optional fields
  *
  * @param SimpleElement $context
  * @param array $fields
  * @return array
  */
 protected function getOptionalFields(SimpleElement $context, array $fields = [])
 {
     $data = [];
     $fields = empty($fields) ? $this->mappingGetFields : $fields;
     foreach ($fields as $name => $params) {
         $data[$name] = $context->find($params['selector'], $params['strategy'])->getText();
     }
     return $data;
 }
Пример #13
0
 /**
  * Get label for notice message.
  *
  * @param Element $element
  * @return string
  */
 protected function getNoticeLabel(Element $element)
 {
     $noticeLabel = str_replace(' ', '', strtolower($element->find($this->noticeLabel, Locator::SELECTOR_XPATH)->getText()));
     return str_replace('*', '', $noticeLabel);
 }
Пример #14
0
 /**
  * Find <tag1><tag2><tagN> ... </tagN></tag2></tag1> tag structure in element.
  *
  * @param SimpleElement $element
  * @param string $selector
  * @return SimpleElement
  */
 protected function checkHtmlTagStructure(SimpleElement $element, $selector)
 {
     return $element->find($selector);
 }
Пример #15
0
 /**
  * Get price from page.
  *
  * @param SimpleElement $infoBlock
  * @param string $currency
  * @param string $selector
  * @return string
  */
 protected function getPriceFromPage(SimpleElement $infoBlock, $currency, $selector)
 {
     return $this->preparePrice($infoBlock->find($selector, Locator::SELECTOR_XPATH)->getText(), $currency);
 }
Пример #16
0
 /**
  * Get sub options.
  *
  * @param Element $element
  * @return array
  */
 protected function getSubOptions(Element $element)
 {
     $optionType = $element->find($this->checkedOptionType)->getText();
     $optionType = str_replace([' ', '&', '-'], '', $optionType);
     return $this->getSubOptionsBlock($optionType, $element)->getOptions();
 }
Пример #17
0
 /**
  * Click 'Add New' button.
  *
  * @param SimpleElement $element
  * @return void
  */
 protected function clickAddNewButton(SimpleElement $element)
 {
     $element->waitUntil(function () use($element) {
         return $element->find($this->addNewButton)->isVisible() ? true : null;
     });
     $element->find($this->addNewButton)->click();
 }
Пример #18
0
 /**
  * Get data from option of select and multiselect.
  *
  * @param Element $element
  * @param int $firstOption
  * @return array
  */
 protected function getSelectOptionsData(Element $element, $firstOption = 1)
 {
     $listOptions = [];
     $count = $firstOption;
     $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH);
     while ($selectOption->isVisible()) {
         $listOptions[] = $this->parseOptionText($selectOption->getText());
         ++$count;
         $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH);
     }
     return ['options' => $listOptions];
 }
Пример #19
0
 /**
  * Get price options block.
  *
  * @param string $priceType
  * @param Element $context
  * @return AbstractSelectOptions
  */
 protected function getOptionBlock($priceType, Element $context)
 {
     return $this->blockFactory->create(__NAMESPACE__ . '\\Prices\\Option' . ucfirst(str_replace('_price', '', $priceType)), ['element' => $context->find(sprintf($this->priceType, $this->childrenForm[$priceType]['selector']))]);
 }
Пример #20
0
 /**
  * Get notice of option by number.
  *
  * @param Element $option
  * @param int $number
  * @return mixed
  */
 protected function getOptionNotice(Element $option, $number)
 {
     $note = $option->find(sprintf($this->noteByNumber, $number), Locator::SELECTOR_XPATH);
     return $note->isVisible() ? $note->getText() : null;
 }
Пример #21
0
 /**
  * Click on "Edit" link.
  *
  * @param SimpleElement $rowItem
  * @return void
  */
 protected function clickEditLink(SimpleElement $rowItem)
 {
     $rowItem->find($this->editLink)->click();
 }
Пример #22
0
 /**
  * Get element of particular class if defined in xml configuration or of one of framework classes otherwise
  *
  * @param Element $context
  * @param array $field
  * @return Element
  * @throws \Exception
  */
 protected function getElement(Element $context, array $field)
 {
     if (isset($field['class'])) {
         $element = $context->find($field['selector'], $field['strategy'], $field['class']);
         if (!$element instanceof Element) {
             throw new \Exception('Wrong Element Class.');
         }
     } else {
         $element = $context->find($field['selector'], $field['strategy'], $field['input']);
     }
     return $element;
 }