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

Commit 1ad0697

Browse files
committed
Improve screenshot tests
1 parent 060af76 commit 1ad0697

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

lib/WebDriverOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function deleteAllCookies()
7676
}
7777

7878
/**
79-
* Delete the cookie with the give name.
79+
* Delete the cookie with the given name.
8080
*
8181
* @param string $name
8282
* @return WebDriverOptions The current instance.

tests/functional/RemoteWebDriverTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,18 @@ public function testShouldSaveScreenshotToFile()
270270
$this->assertGreaterThan(0, imagesx($image));
271271
$this->assertGreaterThan(0, imagesy($image));
272272

273+
// Validate expected red box is present on the screenshot
274+
$this->assertSame(
275+
['red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 0],
276+
imagecolorsforindex($image, imagecolorat($image, 5, 5))
277+
);
278+
279+
// And whitespace has expected background color
280+
$this->assertSame(
281+
['red' => 250, 'green' => 250, 'blue' => 255, 'alpha' => 0],
282+
imagecolorsforindex($image, imagecolorat($image, 15, 5))
283+
);
284+
273285
unlink($screenshotPath);
274286
rmdir(dirname($screenshotPath));
275287
}

tests/functional/web/index.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,22 @@
33
<head>
44
<meta charset="utf-8">
55
<title>php-webdriver test page</title>
6+
<style>
7+
#red-box {
8+
position: absolute;
9+
top: 5px;
10+
left: 5px;
11+
width: 5px;
12+
height: 5px;
13+
background-color: #ff0000;
14+
}
15+
</style>
616
</head>
7-
<body>
8-
<h1 id='welcome'>Welcome to the facebook/php-webdriver testing page.</h1>
17+
<body style="background-color: #fafaff;">
18+
19+
<div id="red-box"></div>
20+
21+
<h1 id="welcome">Welcome to the facebook/php-webdriver testing page.</h1>
922

1023
<a href="form.html" id="a-form">Form test page</a>
1124
|

0 commit comments

Comments
 (0)