Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  *  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;
 }
Ejemplo n.º 5
0
 /**
  * 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();
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * 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));
 }