Example #1
0
 /**
  * Fill data to fields on tab
  *
  * @param array $fields
  * @param Element|null $element
  * @return $this
  */
 public function fillFormTab(array $fields, Element $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;
 }
Example #2
0
 /**
  * Get render instance by name
  *
  * @param string $renderName
  * @return BlockInterface|null
  */
 protected function getRenderInstance($renderName)
 {
     if (!isset($this->renderInstances[$renderName])) {
         $blockMeta = isset($this->config['renders'][$renderName]) ? $this->config['renders'][$renderName] : [];
         $class = isset($blockMeta['class']) ? $blockMeta['class'] : false;
         if ($class) {
             $element = isset($blockMeta['locator']) && isset($blockMeta['strategy']) ? $this->_rootElement->find($blockMeta['locator'], $blockMeta['strategy']) : $this->_rootElement;
             $config = ['renders' => isset($blockMeta['renders']) ? $blockMeta['renders'] : []];
             $block = $this->blockFactory->create($class, ['element' => $element, 'config' => $config]);
         } else {
             return null;
         }
         $this->renderInstances[$renderName] = $block;
     }
     return $this->renderInstances[$renderName];
 }
Example #3
0
 /**
  * Fill data to fields on tab
  *
  * @param array $fields
  * @param Element|null $element
  * @return $this
  */
 public function fillFormTab(array $fields, Element $element = null)
 {
     if (isset($fields['associated'])) {
         $options = $this->_rootElement->find($this->deleteButton)->getElements();
         if (count($options)) {
             foreach ($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;
 }
 /**
  *  Recursive walks tree
  *
  * @param Element $node
  * @param string $parentCssClass
  * @return array
  */
 protected function _getNodeContent($node, $parentCssClass)
 {
     $counter = 1;
     $nextNodeSelector = $parentCssClass . " > " . $this->nodeSelector . ":nth-of-type({$counter})";
     $nodeArray = [];
     //Get list of all children nodes to work with
     $newNode = $node->find($nextNodeSelector);
     while ($newNode->isVisible()) {
         $nextCheckedNodeSelector = $parentCssClass . " > " . $this->checkedNodeSelector . ":nth-of-type({$counter})";
         $nodesNames = $newNode->find($this->nodeName);
         $text = ltrim($nodesNames->getText());
         $childNodeSelector = $nextNodeSelector . $this->nodeCssClass;
         $nodesContents = $newNode->find($childNodeSelector);
         $subNodes = null;
         if ($nodesContents->isVisible()) {
             $subNodes = $this->_getNodeContent($nodesContents, $childNodeSelector);
         }
         $nodeArray[] = ['name' => $text, 'isChecked' => $node->find($nextCheckedNodeSelector)->isVisible() ? true : false, 'element' => $newNode, 'subnodes' => $subNodes];
         ++$counter;
         $nextNodeSelector = $parentCssClass . " > " . $this->nodeSelector . ":nth-of-type({$counter})";
         $newNode = $node->find($nextNodeSelector);
     }
     return $nodeArray;
 }
Example #5
0
 /**
  * Drag and drop element to(between) another element(s)
  *
  * @param ElementInterface $target
  * @return void
  */
 public function dragAndDrop(ElementInterface $target)
 {
     $this->_driver->moveto($this->_getWrappedElement());
     $this->_driver->buttondown();
     /** @var $target Element */
     $this->_driver->moveto($target->_getWrappedElement());
     $this->_driver->buttonup();
 }
Example #6
0
 /**
  * Click 'Add New Tax Rate' button
  *
  * @param Element $taxRateBlock
  * @return void
  */
 protected function clickAddNewButton(Element $taxRateBlock)
 {
     $addNewButton = $this->addNewButton;
     $taxRateBlock->waitUntil(function () use($taxRateBlock, $addNewButton) {
         return $taxRateBlock->find($addNewButton, Locator::SELECTOR_XPATH)->isVisible() ? true : null;
     });
     $taxRateBlock->find($this->addNewButton, Locator::SELECTOR_XPATH)->click();
 }
 /**
  * Find next param of condition for fill
  *
  * @param Element $context
  * @return Element
  * @throws \Exception
  */
 protected function findNextParam(Element $context)
 {
     do {
         if (!isset($this->mapParams[$this->findKeyParam])) {
             throw new \Exception("Empty map of params");
         }
         $param = $this->mapParams[$this->findKeyParam];
         $element = $context->find(sprintf($this->param, strlen($param), $param), Locator::SELECTOR_XPATH);
         $this->findKeyParam += 1;
     } while (!$element->isVisible());
     return $element;
 }
 /**
  * Get child optgroup
  *
  * @param string $value
  * @param Element $context
  * @return Element
  * @throws \Exception
  */
 protected function getChildOptgroup($value, Element $context)
 {
     $childOptgroup = null;
     $count = 1;
     while (!$childOptgroup) {
         $optgroup = $context->find(sprintf($this->nextOptgroup, $count), Locator::SELECTOR_XPATH);
         if (!$optgroup->isVisible()) {
             throw new \Exception("Can't find child group \"{$value}\"");
         }
         $childOptgroup = $context->find(sprintf($this->childOptgroup, $count, $value), Locator::SELECTOR_XPATH);
         if (!$childOptgroup->isVisible()) {
             $childOptgroup = null;
         }
         ++$count;
     }
     return $childOptgroup;
 }
Example #9
0
 /**
  * Active variation tab
  *
  * @param int $row
  * @param Element $variationsBlock
  * @return void
  */
 protected function openVariation($row, Element $variationsBlock)
 {
     $element = $variationsBlock->find(sprintf($this->rowSelector, $row) . $this->activeButtonSelector, Locator::SELECTOR_XPATH);
     if ($element->isVisible()) {
         $element->click();
     }
 }
Example #10
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;
 }
Example #11
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];
 }
Example #12
0
 /**
  * Get rating vote
  *
  * @param Element $rating
  * @return int
  */
 protected function getRatingVote(Element $rating)
 {
     $ratingVote = 5;
     $ratingVoteElement = $rating->find(sprintf($this->checkedRating, $ratingVote));
     while (!$ratingVoteElement->isVisible() && $ratingVote) {
         --$ratingVote;
         $ratingVoteElement = $rating->find(sprintf($this->checkedRating, $ratingVote));
     }
     return $ratingVote;
 }
Example #13
0
 /**
  * Waiting until option in list is visible
  *
  * @param Element $element
  * @param string $value
  * @return void
  */
 protected function waitUntilOptionIsVisible($element, $value)
 {
     $element->waitUntil(function () use($element, $value) {
         $productSavedMessage = $element->find(sprintf($this->optionMaskElement, $value), Locator::SELECTOR_XPATH);
         return $productSavedMessage->isVisible() ? true : null;
     });
 }
Example #14
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;
 }