protected function setUp()
 {
     if (is_null($this->collectionClass)) {
         $this->collectionClass = '\\tests\\QATools\\QATools\\HtmlElements\\Fixture\\Element\\TypifiedElementCollectionChild';
         $this->collectionElementClass = '\\QATools\\QATools\\HtmlElements\\Element\\TextInput';
     }
     $this->webElement = m::mock(self::WEB_ELEMENT_CLASS);
     $this->webElement->shouldReceive('getSession')->withNoArgs()->andReturn($this->session);
     parent::setUp();
 }
 public function testToString()
 {
     $element = $this->createElement();
     $this->webElement->shouldReceive('getXpath')->andReturn('XPATH');
     $expected = 'element (class: ' . get_class($element) . '; xpath: XPATH)';
     $this->assertEquals($expected, (string) $element);
 }
 /**
  * Initializes html element.
  *
  * @param array        $selenium_selector Element selector.
  * @param IPageFactory $page_factory      Page factory.
  */
 public function __construct(array $selenium_selector, IPageFactory $page_factory)
 {
     parent::__construct($selenium_selector, $page_factory->getSession());
     $this->_pageFactory = $page_factory;
     $this->_pageFactory->initElementContainer($this);
     $this->_pageFactory->initElements($this, $this->_pageFactory->createDecorator($this));
 }
 /**
  * Creates Element instance based on existing NodeElement instance.
  *
  * @param NodeElement  $node_element Node element.
  * @param IPageFactory $page_factory Page factory.
  *
  * @return static
  * @throws TypifiedElementException When page factory is missing.
  */
 public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory = null)
 {
     if (!isset($page_factory)) {
         throw new TypifiedElementException('Page factory is required to create this element', TypifiedElementException::TYPE_PAGE_FACTORY_REQUIRED);
     }
     $wrapped_element = WebElement::fromNodeElement($node_element);
     return new static($wrapped_element, $page_factory);
 }
예제 #5
0
 /**
  * Locates object inside proxy.
  *
  * @return void
  */
 protected function locateObject()
 {
     if (is_object($this->object)) {
         return;
     }
     $web_element = WebElement::fromNodeElement($this->locateElement());
     $this->object = new $this->className($this->getName(), $web_element);
 }
예제 #6
0
 /**
  * Example of dynamic method.
  *
  * @param string $method    Method to proxy.
  * @param array  $arguments Method arguments.
  *
  * @return mixed
  */
 public function __call($method, array $arguments)
 {
     if ($method === 'dynamicMethod') {
         return 'OK';
     } elseif ($method == 'dynamicExceptionalMethod') {
         $this->exceptionalMethod();
     }
     return parent::__call($method, $arguments);
 }
예제 #7
0
파일: Form.php 프로젝트: qa-tools/qa-tools
 /**
  * Create AbstractTypifiedElement from a given NodeElements.
  *
  * @param array|NodeElement[] $node_elements Node Elements.
  *
  * @return ITypifiedElement
  * @throws FormException When unable to create typified element.
  */
 public function typify(array $node_elements)
 {
     $node_element = $node_elements[0];
     $tag_name = $node_element->getTagName();
     if ($tag_name == 'input') {
         $input_type = $node_element->getAttribute('type');
         if ($input_type == self::CHECKBOX_INPUT) {
             return Checkbox::fromNodeElement($node_element, $this->getPageFactory());
         } elseif ($input_type == self::RADIO_INPUT) {
             return RadioGroup::fromNodeElements($node_elements, null, $this->getPageFactory());
         } elseif ($input_type == self::FILE_INPUT) {
             return FileInput::fromNodeElement($node_element, $this->getPageFactory());
         } else {
             /*if ( is_null($input_type)
             			|| ($input_type == self::TEXT_INPUT)
             			|| ($input_type == self::PASSWORD_INPUT)
             		) {*/
             return TextInput::fromNodeElement($node_element, $this->getPageFactory());
         }
     } elseif ($tag_name == 'select') {
         return Select::fromNodeElement($node_element, $this->getPageFactory());
     } elseif ($tag_name == 'textarea') {
         return TextInput::fromNodeElement($node_element, $this->getPageFactory());
     }
     $web_element = WebElement::fromNodeElement($node_element, $this->getPageFactory());
     throw new FormException('Unable create typified element for ' . (string) $web_element, FormException::TYPE_UNKNOWN_FIELD);
 }
 /**
  * Creates Element instance based on existing NodeElement instance.
  *
  * @param NodeElement  $node_element Node element.
  * @param IPageFactory $page_factory Page factory.
  *
  * @return static
  */
 public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory = null)
 {
     $wrapped_element = WebElement::fromNodeElement($node_element);
     return new static($wrapped_element);
 }
 /**
  * Mocks getAttribute in the web element.
  *
  * @param array $attributes Mocked attributes.
  *
  * @return void
  */
 protected function expectWebElementGetAttribute(array $attributes)
 {
     foreach ($attributes as $attribute => $value) {
         $this->webElement->shouldReceive('getAttribute')->with($attribute)->andReturn($value)->byDefault();
     }
 }