-
Notifications
You must be signed in to change notification settings - Fork 844
Expand file tree
/
Copy pathWebDriverWindowTest.php
More file actions
135 lines (110 loc) · 3.68 KB
/
Copy pathWebDriverWindowTest.php
File metadata and controls
135 lines (110 loc) · 3.68 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php declare(strict_types=1);
namespace Facebook\WebDriver;
/**
* @covers \Facebook\WebDriver\WebDriverWindow
*/
class WebDriverWindowTest extends WebDriverTestCase
{
/**
* @group exclude-saucelabs
*/
public function testShouldGetPosition(): void
{
$position = $this->driver->manage()
->window()
->getPosition();
$this->assertGreaterThanOrEqual(0, $position->getX());
$this->assertGreaterThanOrEqual(0, $position->getY());
}
public function testShouldGetSize(): void
{
$size = $this->driver->manage()
->window()
->getSize();
$this->assertGreaterThan(0, $size->getWidth());
$this->assertGreaterThan(0, $size->getHeight());
}
public function testShouldMaximizeWindow(): void
{
$sizeBefore = $this->driver->manage()
->window()
->getSize();
$this->driver->manage()
->window()
->maximize();
$sizeAfter = $this->driver->manage()
->window()
->getSize();
$this->assertGreaterThanOrEqual($sizeBefore->getWidth(), $sizeAfter->getWidth());
$this->assertGreaterThanOrEqual($sizeBefore->getHeight(), $sizeAfter->getHeight());
}
/**
* @group exclude-edge
* @group exclude-safari
* @group exclude-saucelabs
*/
public function testShouldFullscreenWindow(): void
{
self::skipForJsonWireProtocol('"fullscreen" window is not supported in JsonWire protocol');
$this->driver->manage()
->window()
->setSize(new WebDriverDimension(400, 300));
$this->driver->manage()
->window()
->fullscreen();
$sizeAfter = $this->driver->manage()
->window()
->getSize();
// Note: Headless browsers see no effect.
$this->assertGreaterThanOrEqual(400, $sizeAfter->getWidth());
$this->assertGreaterThanOrEqual(300, $sizeAfter->getHeight());
}
/**
* @see https://bugs.chromium.org/p/chromium/issues/detail?id=1038050
* @group exclude-chrome
* @group exclude-safari
* @group exclude-saucelabs
*/
public function testShouldMinimizeWindow(): void
{
self::skipForJsonWireProtocol('"minimize" window is not supported in JsonWire protocol');
$this->assertSame('visible', $this->driver->executeScript('return document.visibilityState;'));
$this->driver->manage()
->window()
->minimize();
$this->assertSame('hidden', $this->driver->executeScript('return document.visibilityState;'));
}
/**
* @group exclude-saucelabs
*/
public function testShouldSetSize(): void
{
$sizeBefore = $this->driver->manage()
->window()
->getSize();
$this->assertNotSame(500, $sizeBefore->getWidth());
$this->assertNotSame(666, $sizeBefore->getHeight());
$this->driver->manage()
->window()
->setSize(new WebDriverDimension(500, 666));
$sizeAfter = $this->driver->manage()
->window()
->getSize();
$this->assertSame(500, $sizeAfter->getWidth());
$this->assertSame(666, $sizeAfter->getHeight());
}
/**
* @todo Skip when running headless mode
*/
public function testShouldSetWindowPosition(): void
{
$this->driver->manage()
->window()
->setPosition(new WebDriverPoint(33, 66));
$positionAfter = $this->driver->manage()
->window()
->getPosition();
$this->assertSame(33, $positionAfter->getX());
$this->assertSame(66, $positionAfter->getY());
}
}