Example #1
0
 protected function assertRelations(Accessor\AbstractAccessor $accessor, $selectorStart)
 {
     $con = $accessor->getConnection();
     $accessor1 = new Accessor\ByClassNameAccessor('some_class1', 'p', array(), $con);
     $accessor2 = new Accessor\ByClassNameAccessor('some_class2', 'span', array(), $con);
     $accessor->near($accessor1)->under($accessor2);
     $this->assertEquals($selectorStart . '_sahi._near(_sahi._byClassName("some_class1", "p")), ' . '_sahi._under(_sahi._byClassName("some_class2", "span")))', $accessor->getAccessor());
 }
Example #2
0
 /**
  * @dataProvider    getAccessors
  */
 public function testDragDropActions(Accessor\AbstractAccessor $accessor, $selector)
 {
     $aim = new Accessor\DomAccessor('document.formName', $accessor->getConnection());
     $this->assertActionStep('_sahi._dragDrop(' . $selector . ', _sahi._accessor("document.formName"))', array($accessor, 'dragDrop'), array($aim));
     $this->assertActionStep('_sahi._dragDropXY(' . $selector . ', 10, 15)', array($accessor, 'dragDropXY'), array(10, 15));
     $this->assertActionStep('_sahi._dragDropXY(' . $selector . ', 10, 15, true)', array($accessor, 'dragDropXY'), array(10, 15, true));
     $this->assertActionStep('_sahi._dragDropXY(' . $selector . ', 10, 15, false)', array($accessor, 'dragDropXY'), array(10, 15, false));
 }
    /**
     * Initialize Accessor.
     *
     * @param string     $text tag text
     * @param string     $tag  tag name
     * @param Connection $con  Sahi connection
     */
    public function __construct($text, $tag, Connection $con)
    {
        parent::__construct($con);

        $this->text = $text;
        $this->tag  = $tag;
    }
    /**
     * @dataProvider getAccessors
     */
    public function testGetEmptyAttr(Accessor\AbstractAccessor $accessor, $selector)
    {
        $connection = $this->getConnectionMock();
        $connection
            ->expects($this->once())
            ->method('evaluateJavascript')
            ->with($selector . '.getAttribute("test-attr")')
            ->will($this->returnValue(false));

        $accessor->setConnection($connection);

        $this->assertEquals('', $accessor->getAttr('test-attr'));
    }
Example #5
0
 /**
  * Initialize Accessor.
  *
  * @param   string      $string DOM expression
  * @param   Connection  $con    Sahi connection
  */
 public function __construct($string, Connection $con)
 {
     parent::__construct($con);
     $this->id = $string;
 }
Example #6
0
 /**
  * Initialize Accessor.
  *
  * @param   string      $id     element ID
  * @param   Connection  $con    Sahi connection
  */
 public function __construct($id, Connection $con)
 {
     parent::__construct($con);
     $this->id = $id;
 }
Example #7
0
 /**
  * Drag'n'Drop current element onto another.
  *
  * @param   AbstractAccessor    $to destination element
  */
 public function dragDrop(AbstractAccessor $to)
 {
     $this->con->executeStep(sprintf('_sahi._dragDrop(%s, %s)', $this->getAccessor(), $to->getAccessor()));
 }