/** * Delete saved credit card. * * @param ElementInterface $creditCard */ public function deleteCreditCard(ElementInterface $creditCard) { $creditCard->click(); $this->browser->selectWindow(); $this->browser->find($this->deleteButton, Locator::SELECTOR_XPATH)->click(); $this->browser->selectWindow(); }
/** * Get element data. * * @param ElementInterface $element * @return string */ protected function getData(ElementInterface $element) { $selectedElement = $this->find($this->advancedSelect); $selectedElement->click(); $text = trim($element->getText()); $selectedElement->click(); return $text; }
/** * Recursive walks tree * * @param ElementInterface $node * @param string $parentCssClass * @return array */ protected function _getNodeContent(ElementInterface $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; }
/** * Get bundle options block. * * @param int $rowNumber * @param ElementInterface $element * @return Option */ private function getBundleOptionBlock($rowNumber, ElementInterface $element) { return $this->blockFactory->create('Magento\\Bundle\\Test\\Block\\Adminhtml\\Catalog\\Product\\Edit\\Section\\Bundle\\Option', ['element' => $element->find(sprintf($this->bundleOptionRow, $rowNumber), Locator::SELECTOR_XPATH)]); }
/** * Recursive walks tree * * @param ElementInterface $node * @param string $parentCssClass * @return array */ protected function getNodeContent(ElementInterface $node, $parentCssClass) { $nodeArray = []; $nodeList = []; $counter = 1; $newNode = $node->find($parentCssClass . ' > ' . $this->nodeSelector . ':nth-of-type(' . $counter . ')'); //Get list of all children nodes to work with while ($newNode->isVisible()) { $nodeList[] = $newNode; ++$counter; $newNode = $node->find($parentCssClass . ' > ' . $this->nodeSelector . ':nth-of-type(' . $counter . ')'); } //Write to array values of current node foreach ($nodeList as $currentNode) { /** @var Element $currentNode */ $nodesNames = $currentNode->find($this->nodeName); $nodesContents = $currentNode->find($this->nodeCssClass); $text = ltrim($nodesNames->getText()); $nodeArray[] = ['name' => $text, 'element' => $currentNode, 'subnodes' => $nodesContents->isVisible() ? $this->getNodeContent($nodesContents, $this->nodeCssClass) : null]; } return $nodeArray; }
/** * Find next param of condition for fill. * * @param ElementInterface $context * @return ElementInterface * @throws \Exception */ protected function findNextParam(ElementInterface $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; }
/** * Assign product to variation matrix * * @param ElementInterface $variationRow * @param string $productSku * @return void */ protected function assignProduct(ElementInterface $variationRow, $productSku) { $variationRow->find($this->actionMenu)->hover(); $variationRow->find($this->actionMenu)->click(); $variationRow->find($this->chooseProduct)->click(); $this->getTemplateBlock()->waitLoader(); $this->getAssociatedProductGrid()->searchAndSelect(['sku' => $productSku]); }
/** * Get option type data. * * @param array $options * @param string $type * @param ElementInterface $element * @return array */ private function getOptionTypeData(array $options, $type, ElementInterface $element) { $formDataItem = []; /** @var AbstractOptions $optionsForm */ $optionsForm = $this->blockFactory->create(__NAMESPACE__ . '\\Options\\Type\\' . $this->optionNameConvert($type), ['element' => $element]); $context = $element->find($this->addValue)->isVisible() ? $this->dynamicDataRow : $this->staticDataRow; foreach ($options as $key => $option) { if (isset($option['sort_order'])) { $currentSortOrder = (int) $option['sort_order']; unset($option['sort_order']); } $formDataItem['options'][$key] = $optionsForm->getDataOptions($option, $element->find(sprintf($context, $key + 1))); if (isset($currentSortOrder)) { $formDataItem['options'][$key]['sort_order'] = $key; } } return $formDataItem; }
/** * Get element data. * * @param ElementInterface $element * @return string */ protected function getData(ElementInterface $element) { return trim($element->getValue(), chr(0xc2) . chr(0xa0)); }
/** * Get element data. * * @param ElementInterface $element * @return string */ protected function getData(ElementInterface $element) { $this->find($this->advancedSelect)->click(); return trim($element->getText()); }
/** * Get review's title. * * @param ElementInterface $titleElement * @return string */ protected function getReviewTitle(ElementInterface $titleElement) { return strtolower($titleElement->getText()); }
/** * Param wait loader * * @return void */ protected function waitForCondition(ElementInterface $element) { $this->waitUntil(function () use($element) { if ($element->getAttribute('class') == 'rule-param-wait') { $this->driver->selectWindow(); return null; } return true; }); }
/** * Get element data. * * @param ElementInterface $element * @return string */ protected function getData(ElementInterface $element) { return trim($element->getAttribute('label'), chr(0xc2) . chr(0xa0)); }
/** * Param wait loader. * * @param ElementInterface $element */ protected function waitForCondition(ElementInterface $element) { $this->waitUntil(function () use($element) { return $element->getAttribute('class') == 'rule-param-wait' ? null : true; }); }
/** * Get the value * * @param ElementInterface $element * @return null|string */ public function getValue(ElementInterface $element) { $this->eventManager->dispatchEvent(['get_value'], [__METHOD__, $element->getAbsoluteSelector()]); return $this->getNativeElement($element)->value(); }
/** * Waiter for load children. * * @param ElementInterface $element * @return void */ protected function waitLoadChildren(ElementInterface $element) { $selector = $this->childLoader; $this->waitUntil(function () use($element, $selector) { return $element->find($selector)->isVisible() ? true : null; }); }
/** * Get child optgroup * * @param string $value * @param ElementInterface $context * @return ElementInterface * @throws \Exception */ protected function getChildOptgroup($value, ElementInterface $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; }
/** * Get element label. * * @param ElementInterface $element * @return string */ protected function getElementLabel(ElementInterface $element) { $value = $element->getText(); preg_match($this->regPatternLabel, $value, $matches); return trim($matches[1]); }
/** * Get element label. * * @param ElementInterface $element * @return string */ protected function getElementLabel(ElementInterface $element) { return trim($element->getText()); }
/** * Get column value. * * @param ElementInterface $element * @param array $attributes * @return string */ protected function getColumnValue(ElementInterface $element, array $attributes = []) { $search = isset($attributes['replace']) ? $attributes['replace'] : ['$', '%']; return trim(str_replace($search, '', $element->getText())); }