Skip to content

Commit

Permalink
Add some more tests for RemoteWebElement
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Jan 10, 2017
1 parent dea337f commit 0979f55
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 5 deletions.
58 changes: 53 additions & 5 deletions tests/functional/RemoteWebElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,59 @@ class RemoteWebElementTest extends WebDriverTestCase
public function testShouldGetText()
{
$this->driver->get($this->getTestPath('index.html'));
$element = $this->driver->findElement(WebDriverBy::id('welcome'));
$elementWithSimpleText = $this->driver->findElement(WebDriverBy::id('text-simple'));
$elementWithTextWithSpaces = $this->driver->findElement(WebDriverBy::id('text-with-spaces'));

$this->assertEquals(
'Welcome to the facebook/php-webdriver testing page.',
$element->getText()
);
$this->assertEquals('Foo bar text', $elementWithSimpleText->getText());
$this->assertEquals('Multiple spaces are stripped', $elementWithTextWithSpaces->getText());
}

public function testShouldGetAttributeValue()
{
$this->driver->get($this->getTestPath('index.html'));

$element = $this->driver->findElement(WebDriverBy::id('text-simple'));

$this->assertSame('note', $element->getAttribute('role'));
$this->assertSame('height: 5em; border: 1px solid black;', $element->getAttribute('style'));
$this->assertSame('text-simple', $element->getAttribute('id'));
}

public function testShouldGetLocation()
{
$this->driver->get($this->getTestPath('index.html'));

$element = $this->driver->findElement(WebDriverBy::id('element-with-location'));

$elementLocation = $element->getLocation();
$this->assertInstanceOf(WebDriverPoint::class, $elementLocation);
$this->assertSame(33, $elementLocation->getX());
$this->assertSame(500, $elementLocation->getY());
}

public function testShouldGetSize()
{
$this->driver->get($this->getTestPath('index.html'));

$element = $this->driver->findElement(WebDriverBy::id('element-with-location'));

$elementSize = $element->getSize();
$this->assertInstanceOf(WebDriverDimension::class, $elementSize);
$this->assertSame(333, $elementSize->getWidth());
$this->assertSame(66, $elementSize->getHeight());
}

public function testShouldGetCssValue()
{
$this->driver->get($this->getTestPath('index.html'));

$elementWithBorder = $this->driver->findElement(WebDriverBy::id('text-simple'));
$elementWithoutBorder = $this->driver->findElement(WebDriverBy::id('text-with-spaces'));

$this->assertSame('solid', $elementWithBorder->getCSSValue('border-left-style'));
$this->assertSame('none', $elementWithoutBorder->getCSSValue('border-left-style'));

$this->assertSame('rgba(0, 0, 0, 1)', $elementWithBorder->getCSSValue('border-left-color'));
$this->assertSame('rgba(0, 0, 0, 1)', $elementWithoutBorder->getCSSValue('border-left-color'));
}
}
12 changes: 12 additions & 0 deletions tests/functional/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@ <h1 id='welcome'>Welcome to the facebook/php-webdriver testing page.</h1>
<li>Second</li>
<li>Third</li>
</ul>

<p id="text-simple" role="note" style="height: 5em; border: 1px solid black;">Foo bar text</p>
<p id="text-with-spaces">
Multiple spaces are
stripped
</p>

<div id="element-with-location" style="position: absolute; top: 500px; left: 33px; width: 333px; height: 66px;">
Foo
</div>


</body>
</html>

0 comments on commit 0979f55

Please sign in to comment.