-
Notifications
You must be signed in to change notification settings - Fork 844
Expand file tree
/
Copy pathWebDriverTimeoutsTest.php
More file actions
58 lines (48 loc) · 1.88 KB
/
Copy pathWebDriverTimeoutsTest.php
File metadata and controls
58 lines (48 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php declare(strict_types=1);
namespace Facebook\WebDriver;
use Facebook\WebDriver\Exception\NoSuchElementException;
use Facebook\WebDriver\Exception\ScriptTimeoutException;
use Facebook\WebDriver\Exception\TimeoutException;
use Facebook\WebDriver\Remote\RemoteWebElement;
/**
* @coversDefaultClass \Facebook\WebDriver\WebDriverTimeouts
*/
class WebDriverTimeoutsTest extends WebDriverTestCase
{
/**
* @group exclude-saucelabs
*/
public function testShouldFailGettingDelayedElementWithoutWait(): void
{
$this->driver->get($this->getTestPageUrl(TestPage::DELAYED_ELEMENT));
$this->expectException(NoSuchElementException::class);
$this->driver->findElement(WebDriverBy::id('delayed'));
}
/**
* @covers ::__construct
* @covers ::implicitlyWait
*/
public function testShouldGetDelayedElementWithImplicitWait(): void
{
$this->driver->get($this->getTestPageUrl(TestPage::DELAYED_ELEMENT));
$this->driver->manage()->timeouts()->implicitlyWait(2);
$element = $this->driver->findElement(WebDriverBy::id('delayed'));
$this->assertInstanceOf(RemoteWebElement::class, $element);
}
/**
* @group exclude-saucelabs
* @covers ::__construct
* @covers ::pageLoadTimeout
*/
public function testShouldFailIfPageIsLoadingLongerThanPageLoadTimeout(): void
{
$this->driver->manage()->timeouts()->pageLoadTimeout(1);
try {
$this->driver->get($this->getTestPageUrl(TestPage::SLOW_LOADING));
$this->fail('ScriptTimeoutException or TimeoutException exception should be thrown');
} catch (TimeoutException $e) { // thrown by Selenium 3.0.0+
} catch (ScriptTimeoutException $e) { // thrown by Selenium 2
}
$this->assertTrue(true); // To generate coverage, see https://github.com/sebastianbergmann/phpunit/issues/3016
}
}