/** * 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; }
/** * Get context for an element * * @param bool $waitForElementPresent * @return TestCase|\PHPUnit_Extensions_Selenium2TestCase_Element */ protected function getContext($waitForElementPresent) { return !empty($this->_context) ? $this->_context->_getWrappedElement($waitForElementPresent) : $this->_driver; }
/** * Return Wrapped Element. * If element was not created before: * 1. Context is defined. If context was not passed to constructor - test case (all page) is taken as context * 2. Attempt to get selenium element is performed in loop * that is terminated if element is found or after timeout set in configuration * * @param bool $waitForElementPresent * @return \PHPUnit_Extensions_Selenium2TestCase_Element|\PHPUnit_Extensions_Selenium2TestCase_Element_Select */ protected function _getWrappedElement($waitForElementPresent = true) { return Element::_getWrappedElement($waitForElementPresent); }
/** * 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; }
/** * Return Wrapped Element. * If element was not created before: * 1. Context is defined. If context was not passed to constructor - test case (all page) is taken as context * 2. Attempt to get selenium element is performed in loop * that is terminated if element is found or after timeout set in configuration * * @param bool $waitForElementPresent * @return \PHPUnit_Extensions_Selenium2TestCase_Element_Select * @throws \PHPUnit_Extensions_Selenium2TestCase_WebDriverException */ protected function _getWrappedElement($waitForElementPresent = true) { return $this->_driver->select(parent::_getWrappedElement($waitForElementPresent)); }