Skip to content

Commit fcbdbd2

Browse files
authored
Refactoring, Chrome headless support, Travis CI support (symfony#4)
* Add Travis CI * Enable Chrome's headless mode * Try with --no-sandbox * Refactor the ChromeManager, add a script to download bin * Throw error when process is terminated. * debug again * debug... * ps ax * add exec * Update README.md
1 parent 881749a commit fcbdbd2

18 files changed

+498
-191
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: php
2+
addons:
3+
chrome: stable
4+
5+
php:
6+
- 7.2
7+
8+
cache:
9+
directories:
10+
- $HOME/.composer/cache
11+
12+
before_script:
13+
- phpenv config-rm xdebug.ini
14+
- composer install
15+
16+
script:
17+
- phpunit

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Use [Composer](https://getcomposer.org/) to install Panthère in your project:
2828
```php
2929
<?php
3030

31-
require __DIR__.'/vendor/autoload.php';
31+
require __DIR__.'/vendor/autoload.php'; // Composer's autoloader
3232

33-
$client = new \Panthere\Client();
33+
$client = \Panthere\Client::createChromeClient();
3434
$crawler = $client->request('GET', 'http://api-platform.com'); // Yes, this website is 100% in JavaScript
3535

3636
$link = $crawler->selectLink('Support')->link();
@@ -41,8 +41,6 @@ $client->waitFor('.support');
4141

4242
echo $crawler->filter('.support')->text();
4343
$client->takeScreenshot('screen.png'); // Yeah, screenshot!
44-
45-
$client->quit();
4644
```
4745

4846
## Testing Usage
@@ -133,6 +131,23 @@ Because Panthère implements the API of popular, it already has an extensive doc
133131
* For the `Crawler` class, read [the DomCrawler's documentation](https://symfony.com/doc/current/components/dom_crawler.html)
134132
* For Webdriver, read [the Facebook's PHP WebDriver documentation](https://github.com/facebook/php-webdriver)
135133

134+
## Travis CI Integration
135+
136+
Panthère will work out of the box with Travis until you add the Chrome addon. Here is a minimal `.travis.yml` file to run
137+
Panthères tests:
138+
139+
```yaml
140+
language: php
141+
addons:
142+
chrome: stable
143+
144+
php:
145+
- 7.2
146+
147+
script:
148+
- phpunit
149+
```
150+
136151
## Limitations
137152
138153
The following features are not currently supported:
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
# External Vendors
1+
# Chromedriver Binaries
22

33
Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/downloads
4+
See [notes.txt](notes.txt).
Binary file not shown.
Binary file not shown.
Binary file not shown.

chromedriver-bin/notes.txt

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
----------ChromeDriver v2.37 (2018-03-16)----------
2+
Supports Chrome v64-66
3+
Resolved issue 2304: Test ChromeDriverSiteIsolation.testCanClickOOPIF fails on Chrome v66 for all desktop platforms [[Pri-1]]
4+
Resolved issue 1940: Many window command endpoints are unimplemented in Chromedriver [[Pri-2]]
5+
Resolved issue 1937: Get element rect is not implemented [[Pri-2]]
6+
Resolved issue 2329: ChromeDriver does not allow value of 0 for extensionLoadTimeout option [[Pri-2]]
7+
8+
----------ChromeDriver v2.36 (2018-03-02)----------
9+
Supports Chrome v63-65
10+
Resolved issue 1819: testIFrameWithExtensionsSource is failing on Chrome v60+ [[Pri-1]]
11+
Resolved issue 2221: Add command-line option to log INFO level to stderr [[Pri-2]]
12+
Resolved issue 450: ChromeDriver hangs when switching to new window whose document is being overwritten [[Pri-2]]
13+
Resolved issue 2235: Add option to control the wait for extension background pages [[Pri-2]]
14+
Resolved issue 2234: fixed webview_devtools_remote_ is not right [[Pri-2]]
15+
Resolved issue 2223: Unable to load extension if background page name starts with / [[Pri-2]]
16+
Resolved issue 2280: ChromeDriver should be more extensible [[Pri-]]
17+
Resolved issue 2231: Pixel 2 and Pixel 2 XL not working in Mobile Emulation [[Pri-]]
18+
Resolved issue 746266: Chromedriver does not support OOPIF
19+
20+
----------ChromeDriver v2.35 (2018-01-10)----------
21+
Supports Chrome v62-64
22+
Resolved issue 2191: Executing JavaScript code fails if the script returns no result [[Pri-1]]
23+
Resolved issue 2183: Connections Aren't Persistent [[Pri-2]]
24+
Resolved issue 2207: Some mobile emulation devices do not work [[Pri-2]]
25+
Resolved issue 2177: Get local storage returns command names in Chrome 63 [[Pri-2]]
26+
Resolved issue 2179: absolute time on log entries [[Pri-2]]
27+
28+
----------ChromeDriver v2.34 (2017-12-10)----------
29+
Supports Chrome v61-63
30+
Resolved issue 2025: Incorrect navigation on Chrome v63+ [['Pri-0']]
31+
Resolved issue 2034: Error looking for "Timeline.start" in Chrome [['Pri-2']]
32+
Resolved issue 1883: Unable to emulate android devices with Chromedriver 2.30 [['Pri-2']]
33+
Resolved issue 2103: Touch in mobile emulation doesn't work [[]]
34+
35+
----------ChromeDriver v2.33 (2017-10-03)----------
36+
Supports Chrome v60-62
37+
Resolved issue 2032: ChromeDriver crashes while creating DNS resolver [['Pri-1']]
38+
Resolved issue 1918: Get/SetWindowSize & Get/SetWindowPosition commands are failing on Chromev62+ [['Pri-1']]
39+
Resolved issue 2013: Android 8.0.0 webviews not supported [['Pri-2']]
40+
Resolved issue 2017: In mobileEmulation "element is not clickable" if it is outside the visible area [['Pri-2']]
41+
Resolved issue 1981: chromedriver does not respect excludeSwitches flag [['Pri-2']]
42+
Partially Resolved issue 2002: Add Cookie is not spec compliant [[]]
43+
Resolved issue 1985: FindElement raises the wrong error [[]]
44+
45+
----------ChromeDriver v2.32 (2017-08-30)----------
46+
Supports Chrome v59-61
47+
Resolved issue 1852: Error 'Element is not clickable at point' occurs on Chrome v61+ [['Pri-1']]
48+
Resolved issue 1950: DeleteCookie in Chrome v62 and Chromedriver v2.31 fails [['Pri-2']]
49+
Resolved issue 1942: ChromeDriver response in W3C mode is not standard compliant [['Pri-2']]
50+
Resolved issue 1910: Fails to retrieve default prompt text on Chrome v62+ [['Pri-2']]
51+
Resolved issue 1900: LaunchApp command throws UnknownError: cannot get automation extension on Mac and Windows Chrome v62+ [['Pri-2']]
52+
Resolved issue 1885: unknown error: Cannot use 'in' operator to search for 'String' in null [['Pri-2']]
53+
Resolved issue 1882: Chromedriver URI for Execute Async Script is not spec compliant [['Pri-3']]
54+
Resolved issue 1621: Implement session/<session id>/window/fullscreen command [['Pri-3']]
55+
Resolved issue 1896: Characters '3' and '#' are not being entered using SendKeys on Mac Chrome v62+ [[]]
56+
Resolved issue 1894: chromedriver 2.31 should be linked with glibc 2.17 [[]]
57+
Resolved issue 1740: ChromeDriver session handshake needs to be W3C compliant [[]]
58+
Resolved issue 1898: Wrong error is thrown while sending text to non prompt dialog. [[]]
59+
Resolved issue 1888: Chromedriver doesn't throw an exception when uploading an invalid file with selenium [[]]
60+
61+
----------ChromeDriver v2.31 (2017-07-21)----------
62+
Supports Chrome v58-60
63+
Resolved issue 1804: Flakiness when retrieving cookies using GetCookies command on Windows [['Pri-1']]
64+
Resolved issue 1879: Implement /session/{session id}/cookie/{name} command [['Pri-2']]
65+
Resolved issue 1860: WebDriverException: Message: unknown error: bad inspector message:"" when attempting to get page_source [['Pri-2']]
66+
Resolved issue 1293: Timed out receiving message from renderer on window.location change [['Pri-2']]
67+
Resolved issue 1849: ChromeDriver 2.30 AddCookie command uses incorrect default path [['Pri-2']]
68+
Resolved issue 1256: switchToFrame should throw StaleElementReferenceException in case the element is stale [['Pri-2']]
69+
Resolved issue 1786: Feature request: change chromeOptions to goog:chromeOptions [['Pri-3']]
70+
Resolved issue 1772: Chromedriver running against canary chrome w/ headless flag requires XVFB for sendKey interactions [[]]
71+
Resolved issue 727979: Failed to set Chrome's command line file on device for long command line [['Pri-3']]
72+
73+
----------ChromeDriver v2.30 (2017-06-07)----------
74+
Supports Chrome v58-60
75+
Resolved issue 644: ChromeDriver does not delete the profile & scoped_dir* folders after test exits [['Pri-1']]
76+
Resolved issue 1114: unknown error:Maximum call stack size exceeded on calling any webdriver command [['OS-All', 'Pri-1']]
77+
Resolved issue 1773: ChromeDriver crashes when using console.time on Chromev58+ [['OS-All', 'Pri-1']]
78+
Resolved issue 1526: mobileEmulation not working for the listed devices in the chrome [['Pri-2']]
79+
Resolved issue 1777: NoSuchFrameException is thrown when attempting to focus on a frame with protocol "chrome-extension://" within a page with protocol "https://" on Chrome 58 [['OS-All', 'Pri-2']]
80+
Resolved issue 1779: testWindowMaximize is failing on Mac for Chrome v60+ [['OS-Mac', 'Pri-2']]
81+
Resolved issue 1775: testShouldHandleNewWindowLoadingProperly failing on Chrome v60+ [['OS-All', 'Pri-2']]
82+
Resolved issue 1796: Chromedriver failed to connect to Chrome on CrOS with latest canary build [[]]
83+
Resolved issue 1353: Sending text to Alert / Confirm dialog should throw element not visible exception [[]]
84+
85+
----------ChromeDriver v2.29 (2017-04-04)----------
86+
Supports Chrome v56-58
87+
Resolved issue 1521: Assignment to Object.prototype.$family causes a crash [['Pri-1']]
88+
Resolved issue 1482: Chromedriver cannot handle the alert generated by onbeforeunload event [['OS-All', 'Pri-2']]
89+
Resolved issue 1315: |switch_to.window| does not visually switch tabs [['OS-All', 'Pri-3']]
90+
91+
----------ChromeDriver v2.28 (2017-03-09)----------
92+
Supports Chrome v55-57
93+
Resolved issue 1625: Error: cannot get automation extension on Chrome57+ [['OS-All', 'Pri-1', 'merge-merged-2987']]
94+
Resolved issue 1695: Chrome crashes on Linux32 bot [['OS-Linux', 'Pri-1']]
95+
Resolved issue 1467: A hang occurs when an alert dialog is displayed on Chrome 52+ [['OS-All', 'Pri-2']]
96+
Resolved issue 1688: Exported Netlog with --log-net-log is truncated [['OS-Linux', 'OS-Mac', 'Pri-2']]
97+
Resolved issue 1388: find Elements is failing [['Pri-2']]
98+
99+
----------ChromeDriver v2.27 (2016-12-23)----------
100+
Supports Chrome v54-56
101+
Resolved issue 1637: Getting window handles fails in the presence of shared workers on Chrome 55+ [['OS-All', 'Pri-1']]
102+
103+
----------ChromeDriver v2.26 (2016-12-09)----------
104+
Supports Chrome v53-55
105+
Resolved issue 1607: Chrome 57+ with perf logs enabled fails with "unexpected command response" [['OS-All', 'Pri-1']]
106+
Resolved issue 1502: sendKeys(): SPACE key does not work on Chrome 53 [['OS-All', 'Pri-1']]
107+
Resolved issue 984: Extend ChromeDriver capabilities to cover network throttling feature from Chrome DevTools [['OS-All', 'Pri-2']]
108+
Resolved issue 877: UnhandledAlertException not being propagated upwards [['OS-All', 'Pri-2']]
109+
Resolved issue 1578: Flash plugin blocked after updating Chrome browser [['OS-All', 'Pri-2']]
110+
Resolved issue 1617: Fullscreen command is not recognised [['OS-All', 'Pri-3']]
111+
Resolved issue 839: clear does not work on input type number with string value [['Pri-3']]
112+
Resolved issue 1500: "Could not handle JavaScript dialog" error occurs randomly when accepting confirmation dialogs. [[]]
113+
Resolved issue 1541: find element with empty tag is raising wrong exception in findElement [[]]
114+
Resolved issue 1540: empty tagname value should raise an error when doing findElements [[]]
115+
116+
----------ChromeDriver v2.25 (2016-10-25)----------
117+
Supports Chrome v53-55
118+
Resolved issue 1547: Chromedriver crashes during event Runtime.consoleAPICalled [['OS-All', 'Pri-1']]
119+
Resolved issue 1514: GetLog command times out if an alert is showing [['OS-All', 'Pri-1']]
120+
Resolved issue 1460: "Disable Developer Mode Extensions" exists on Mac, but not Windows [[]]
121+
122+
----------ChromeDriver v2.24 (2016-09-09)----------
123+
Supports Chrome v52-54
124+
Resolved issue 1497: GetLog fails when the current window is closed [['OS-All', 'Pri-0']]
125+
Resolved issue 1495: ChromeDriver crashes with "Check failed: !page_load_strategy_.empty()" [['OS-All', 'Pri-0']]
126+
Resolved issue 1463: SessionNotCreatedException: Runtime.evaluate missing 'wasThrown' on Chrome 54+ [['OS-All', 'Pri-0']]
127+
Resolved issue 1484: SendKeys of a Tab Key has no effect in Chrome 53 [['OS-All', 'Pri-1']]
128+
Resolved issue 1431: GetLog command does not work for Chrome 54+ [['OS-All', 'Pri-1']]
129+
Resolved issue 1411: sendKeys generates events that are missing some fields [['OS-All', 'Pri-1']]
130+
Resolved issue 1451: Chrome 54+ session not created exception: Runtime.executionContextCreated has invalid 'context' [['Pri-1']]
131+
Resolved issue 984: Extend ChromeDriver capabilities to cover network throttling feature from Chrome DevTools [['OS-All', 'Pri-2']]
132+
Resolved issue 1454: Net::ReadTimeout error on launching Canary v54 through RemoteWebDriver [[]]
133+
134+
----------ChromeDriver v2.23 (2016-08-04)----------
135+
Supports Chrome v51-53
136+
Resolved issue 1378: Android 6: Intitialization of Chrome driver fails when Chrome/Webview process is in running (R) state [['OS-Android', 'Pri-1']]
137+
Resolved issue 1379: Chromedriver does not catch all available browser console log entries [['OS-All', 'Pri-2']]
138+
139+
----------ChromeDriver v2.22 (2016-06-06)----------
140+
Supports Chrome v49-52
141+
Resolved issue 1348: Timeout error while navigating to URL on Chrome 51+ [['OS-All', 'Pri-0']]
142+
Resolved issue 1381: Timeout error occurs when alert dialog is displayed on Chrome 52+ [['OS-All', 'Pri-1', 'merge-merged-2743']]
143+
Resolved issue 1339: Failure when executing JS in a content script context [['OS-All', 'Pri-1']]
144+
Resolved issue 1387: ChromeDriver hangs when calling driver.get() for same-process navigations [['OS-All', 'Pri-1']]
145+
Resolved issue 1365: Touch emulation is not working under mobile emulation in Chrome 50+ [['OS-All', 'Pri-1']]
146+
Resolved issue 1224: Chrome WebDriver throws an exception when trying to click a button inside a frame [['OS-All', 'Pri-2']]
147+
Resolved issue 107: ChromeDriver Won't Switch To Frame inside nested frameset [['OS-All', 'Pri-2']]
148+
Resolved issue 1368: ExecuteScript returns "Cannot read property 'document' of null" [[]]
149+
Resolved issue 1355: Session not created exception when connecting to existing browser on localhost [[]]
150+
Resolved issue 1331: "chromeOptions.excludeSwitches" is not working on Android [[]]
151+
152+
----------ChromeDriver v2.21 (2016-01-28)----------
153+
Supports Chrome v46-50
154+
Resolved issue 1276: empty FindElement response is returned while trying to find element with tagname object/embed [['OS-All', 'Pri-1']]
155+
Resolved issue 1272: GET url returns "data:text/html,chromewebdata" [['OS-All', 'Pri-2']]
156+
Resolved issue 1310: ChromeDriver hangs (and times out) when inspecting inactive background pages [['OS-All', 'Pri-2']]
157+
Resolved issue 824: ChromeDriver creates two cookies when the cookie to add contains the domain [['OS-All', 'Pri-2']]
158+
Resolved issue 1274: ExecuteScript sends script to wrong execution context [['OS-All', 'Pri-2']]
159+
Resolved issue 1249: Change "get current URL" behavior in ChromeDriver [['OS-All', 'Pri-2']]
160+
Resolved issue 904: include Alert text in UnhandledAlertError stack trace [['OS-All', 'Pri-2']]
161+
Resolved issue 474: getAttribute() fails when attribute name has colon (:) character [['OS-All', 'Pri-3']]
162+
Resolved issue 1245: Unable to switch to 1st opened window in session [[]]
163+
Resolved issue 1290: Cannot access elements from subframes [[]]
164+
Resolved issue 1261: getTitle() should return empty string instead of page url when page title is empty [[]]
165+
Resolved issue 1238: testExecuteInRemovedFrame fails on waterfall bots [['OS-All']]
166+
Resolved issue 1246: Chromedriver version number is not displayed in logs/ getCapabilities() [['OS-All']]
167+
168+
----------ChromeDriver v2.20 (2015-10-08)----------
169+
Supports Chrome v43-48
170+
Resolved issue 1225: RESPONSE InitSession unknown error: Device <device_id> is not online [['OS-Android', 'Pri-0']]
171+
Resolved issue 960: ChromeDriver support to access WebView elements [['OS-All', 'Pri-2']]
172+
Resolved issue 1229: Spec violation: /sessions endpoint returns session ID at `sessionId` key instead of `id` key [['OS-All', 'Pri-2']]
173+
174+
----------ChromeDriver v2.19 (2015-08-28)----------
175+
Supports Chrome v43-47
176+
Resolved issue 1167: Various issues with ChromeDriver navigation tracker [['OS-All', 'Pri-1']]
177+
Resolved issue 1205: Chrome crashes when enabling touch emulation [['OS-Mac', 'OS-Windows', 'Pri-1']]
178+
Resolved issue 1142: cookies' httponly attribute is not returned [['Pri-2']]
179+
180+
----------ChromeDriver v2.18 (2015-08-19)----------
181+
Supports Chrome v43-46
182+
Resolved issue 1158: Unable to find elements after installing Chrome 44 [['ChromeDriver-2.17', 'OS-All', 'Pri-1']]
183+
Resolved issue 635: Implement touch actions for android chrome [['OS-Android', 'Pri-2']]
184+
Resolved issue 1194: unknown error: cannot determine loading status from disconnected: received Inspector.detached event [[]]

chromedriver-bin/update.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
# Author: Kévin Dunglas <[email protected]>
3+
# Download the last version of ChromeDriver binaries
4+
5+
latest=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
6+
7+
echo "Downloading ChromeDriver version ${latest}..."
8+
9+
declare -a binaries=("chromedriver_linux64" "chromedriver_mac64" "chromedriver_win32")
10+
for name in "${binaries[@]}"
11+
do
12+
curl -s https://chromedriver.storage.googleapis.com/${latest}/${name}.zip -O
13+
unzip -q -o ${name}.zip
14+
rm ${name}.zip
15+
if [ -f "chromedriver" ]; then
16+
mv chromedriver ${name}
17+
fi
18+
done
19+
curl -s https://chromedriver.storage.googleapis.com/${latest}/notes.txt -O
20+
echo "Done."

examples/basic.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,17 @@
1010
*/
1111

1212
declare(strict_types=1);
13-
require __DIR__.'/../vendor/autoload.php';
1413

15-
use Facebook\WebDriver\WebDriverBy;
16-
use Facebook\WebDriver\WebDriverExpectedCondition;
17-
use Panthere\Client;
14+
require __DIR__.'/../vendor/autoload.php'; // Composer's autoloader
1815

19-
$client = new Client();
16+
$client = \Panthere\Client::createChromeClient();
2017
$crawler = $client->request('GET', 'http://api-platform.com'); // Yes, this website is 100% in JavaScript
2118

2219
$link = $crawler->selectLink('Support')->link();
2320
$crawler = $client->click($link);
2421

25-
// Wait for an element
22+
// Wait for an element to be rendered
2623
$client->waitFor('.support');
27-
$client->wait()->until(
28-
WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::className('support'))
29-
);
3024

3125
echo $crawler->filter('.support')->text();
32-
$client->takeScreenshot('screen.png');
33-
34-
$client->quit();
26+
$client->takeScreenshot('screen.png'); // Yeah, screenshot!

0 commit comments

Comments
 (0)