/** * 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; }
/** * Recursive walks tree * * @param Element $node * @param string $parentCssClass * @return array */ protected function _getNodeContent($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; }
/** * Assign product to variation matrix * * @param Element $variationRow * @param int $productId * @return void */ protected function assignProduct(Element $variationRow, $productId) { $variationRow->find($this->configurableAttribute)->click(); $this->_rootElement->find(sprintf($this->selectAssociatedProduct, $productId), Locator::SELECTOR_XPATH)->click(); }
/** * Get optional fields * * @param Element $context * @param array $fields * @return array */ protected function getOptionalFields(Element $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; }