Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 27d5dfb

Browse files
authored
Merge pull request #471 from OndraM/feature/tests-navigation
Add functional tests for WebDriverNavigation
2 parents f6998eb + 7672fe4 commit 27d5dfb

10 files changed

+104
-5
lines changed

lib/Firefox/FirefoxDriver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
namespace Facebook\WebDriver\Firefox;
1717

18+
/**
19+
* @codeCoverageIgnore
20+
*/
1821
class FirefoxDriver
1922
{
2023
const PROFILE = 'firefox_profile';

lib/Firefox/FirefoxPreferences.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
/**
1919
* Constants of common Firefox profile preferences (about:config values).
2020
* @see http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries
21+
*
22+
* @codeCoverageIgnore
2123
*/
2224
class FirefoxPreferences
2325
{

lib/Remote/DriverCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* This list of command defined in the WebDriver json wire protocol.
20+
*
21+
* @codeCoverageIgnore
2022
*/
2123
class DriverCommand
2224
{

lib/Remote/WebDriverBrowserType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
namespace Facebook\WebDriver\Remote;
1717

1818
/**
19-
* All the browsers supported by selenium
19+
* All the browsers supported by selenium.
20+
*
21+
* @codeCoverageIgnore
2022
*/
2123
class WebDriverBrowserType
2224
{

lib/Remote/WebDriverCapabilityType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* WebDriverCapabilityType contains all constants defined in the WebDriver Wire Protocol.
20+
*
21+
* @codeCoverageIgnore
2022
*/
2123
class WebDriverCapabilityType
2224
{

lib/WebDriverNavigation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function refresh()
7575
/**
7676
* Navigate to the given URL.
7777
*
78+
* @see WebDriver::get()
7879
* @param string $url
7980
* @return WebDriverNavigation The instance.
8081
*/

lib/WebDriverPlatform.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/**
1919
* The platforms supported by WebDriver.
20+
*
21+
* @codeCoverageIgnore
2022
*/
2123
class WebDriverPlatform
2224
{

tests/functional/RemoteWebDriverTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ public function testShouldGetCurrentUrl()
4545
{
4646
$this->driver->get($this->getTestPageUrl('index.html'));
4747

48-
$this->assertContains(
49-
'/index.html',
50-
$this->driver->getCurrentURL()
51-
);
48+
$this->assertStringEndsWith('/index.html', $this->driver->getCurrentURL());
5249
}
5350

5451
/**
@@ -173,6 +170,7 @@ function(){document.getElementById("id_test").innerHTML = "Text changed by scrip
173170

174171
/**
175172
* @covers ::executeAsyncScript
173+
* @covers Facebook\WebDriver\WebDriverTimeouts::setScriptTimeout
176174
*/
177175
public function testShouldExecuteAsyncScriptAndWaitUntilItIsFinished()
178176
{
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
// Copyright 2004-present Facebook. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
namespace Facebook\WebDriver;
17+
18+
/**
19+
* @coversDefaultClass Facebook\WebDriver\WebDriverNavigation
20+
*/
21+
class WebDriverNavigationTest extends WebDriverTestCase
22+
{
23+
/**
24+
* @covers ::to
25+
* @covers ::__construct
26+
*/
27+
public function testShouldNavigateToUrl()
28+
{
29+
$this->driver->navigate()->to($this->getTestPageUrl('index.html'));
30+
31+
$this->assertStringEndsWith('/index.html', $this->driver->getCurrentURL());
32+
}
33+
34+
/**
35+
* @covers ::back
36+
* @covers ::forward
37+
*/
38+
public function testShouldNavigateBackAndForward()
39+
{
40+
$this->driver->get($this->getTestPageUrl('index.html'));
41+
$linkElement = $this->driver->findElement(WebDriverBy::id('a-form'));
42+
43+
$linkElement->click();
44+
45+
$this->driver->wait()->until(
46+
WebDriverExpectedCondition::urlContains('form.html')
47+
);
48+
49+
$this->driver->navigate()->back();
50+
51+
$this->driver->wait()->until(
52+
WebDriverExpectedCondition::urlContains('index.html')
53+
);
54+
55+
$this->driver->navigate()->forward();
56+
57+
$this->driver->wait()->until(
58+
WebDriverExpectedCondition::urlContains('form.html')
59+
);
60+
}
61+
62+
/**
63+
* @covers ::refresh
64+
*/
65+
public function testShouldRefreshPage()
66+
{
67+
$this->driver->get($this->getTestPageUrl('index.html'));
68+
69+
// Change input element content, to make sure it was refreshed (=> cleared to original value)
70+
$inputElement = $this->driver->findElement(WebDriverBy::name('test_name'));
71+
$inputElementOriginalValue = $inputElement->getAttribute('value');
72+
$inputElement->clear()->sendKeys('New value');
73+
$this->assertSame('New value', $inputElement->getAttribute('value'));
74+
75+
$this->driver->navigate()->refresh();
76+
77+
$this->driver->wait()->until(
78+
WebDriverExpectedCondition::stalenessOf($inputElement)
79+
);
80+
81+
$inputElementAfterRefresh = $this->driver->findElement(WebDriverBy::name('test_name'));
82+
83+
$this->assertSame($inputElementOriginalValue, $inputElementAfterRefresh->getAttribute('value'));
84+
}
85+
}

tests/functional/WebDriverTimeoutsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function testShouldFailGettingDelayedElementWithoutWait()
3636

3737
/**
3838
* @covers ::implicitlyWait
39+
* @covers ::__construct
3940
*/
4041
public function testShouldGetDelayedElementWithImplicitWait()
4142
{
@@ -49,6 +50,7 @@ public function testShouldGetDelayedElementWithImplicitWait()
4950

5051
/**
5152
* @covers ::pageLoadTimeout
53+
* @covers ::__construct
5254
*/
5355
public function testShouldFailIfPageIsLoadingLongerThanPageLoadTimeout()
5456
{

0 commit comments

Comments
 (0)