Skip to content

Instantly share code, notes, and snippets.

@kanaka
Last active December 15, 2018 19:32
Show Gist options
  • Save kanaka/aeca4b55ebd26be8d03ff13c888c5371 to your computer and use it in GitHub Desktop.
Save kanaka/aeca4b55ebd26be8d03ff13c888c5371 to your computer and use it in GitHub Desktop.
Brave headless webdriver test/bug
$ grep VER /etc/*release*
/etc/os-release:VERSION="16.04.2 LTS (Xenial Xerus)"
/etc/os-release:VERSION_ID="16.04"
/etc/os-release:VERSION_CODENAME=xenial
$ uname -a
Linux kanaka 4.4.0-43-generic #63-Ubuntu SMP Wed Oct 12 13:48:03 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ python3 -m http.server 9080 &
$ ./chromedriver --port=7002 &
Starting ChromeDriver 70.0.56.15 (ca97ba107095b2a88cf04f9135463301e685cbb0) on port 7002
Only local connections are allowed.
$ time ./load_test1.sh brave
resp: {"sessionId":"327aa07f1f4d0bf627b24bcc82c225db","status":33,"value":{"message":"session not created: Chrome version must be >= 67.0.3396.0\n (Driver info: chromedriver=70.0.56.15 (ca97ba107095b2a88cf04f9135463301e685cbb0),platform=Linux 4.4.0-43-generic x86_64)"}}
SESSIONID: 327aa07f1f4d0bf627b24bcc82c225db
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 7002 (#0)
> POST /session/327aa07f1f4d0bf627b24bcc82c225db/url HTTP/1.1
> Host: localhost:7002
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Length: 42
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 42 out of 42 bytes
< HTTP/1.1 200 OK
< Content-Length:224
< Content-Type:application/json; charset=utf-8
< Connection:close
<
* Closing connection 0
{"sessionId":"327aa07f1f4d0bf627b24bcc82c225db","status":6,"value":{"message":"invalid session id\n (Driver info: chromedriver=70.0.56.15 (ca97ba107095b2a88cf04f9135463301e685cbb0),platform=Linux 4.4.0-43-generic x86_64)"}} % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 7002 (#0)
> GET /session/327aa07f1f4d0bf627b24bcc82c225db/screenshot HTTP/1.1
> Host: localhost:7002
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length:224
< Content-Type:application/json; charset=utf-8
< Connection:close
<
{ [224 bytes data]
100 224 100 224 0 0 38310 0 --:--:-- --:--:-- --:--:-- 44800
* Closing connection 0
base64: invalid input
real 1m0.099s
user 0m0.020s
sys 0m0.008s
$ time ./load_test1.sh
resp: {"sessionId":"62ea9f34ad8a899b4a1169808bb4a940","status":0,"value":{"acceptInsecureCerts":false,"acceptSslCerts":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"70.0.56.15 (ca97ba107095b2a88cf04f9135463301e685cbb0)","userDataDir":"/tmp/.org.chromium.Chromium.7HPOF4"},"cssSelectorsEnabled":true,"databaseEnabled":false,"goog:chromeOptions":{"debuggerAddress":"localhost:40670"},"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platform":"Linux","rotatable":false,"setWindowRect":true,"takesHeapSnapshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"70.0.3538.110","webStorageEnabled":true}}
SESSIONID: 62ea9f34ad8a899b4a1169808bb4a940
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 7002 (#0)
> POST /session/62ea9f34ad8a899b4a1169808bb4a940/url HTTP/1.1
> Host: localhost:7002
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Length: 42
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 42 out of 42 bytes
< HTTP/1.1 200 OK
< Content-Length:72
< Content-Type:application/json; charset=utf-8
< Connection:close
<
* Closing connection 0
{"sessionId":"62ea9f34ad8a899b4a1169808bb4a940","status":0,"value":null} % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 7002 (#0)
> GET /session/62ea9f34ad8a899b4a1169808bb4a940/screenshot HTTP/1.1
> Host: localhost:7002
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Length:11258
< Content-Type:application/json; charset=utf-8
< Connection:close
<
{ [11258 bytes data]
100 11258 100 11258 0 0 139k 0 --:--:-- --:--:-- --:--:-- 140k
* Closing connection 0
real 0m0.470s
user 0m0.008s
sys 0m0.012s
#!/bin/bash
if [ "${1}" = "brave" ]; then
caps='{"desiredCapabilities":{"chromeOptions":{"binary":"/usr/bin/brave-browser","args":["--headless","--disable-gpu"]}}}'
else
caps='{"desiredCapabilities":{"chromeOptions":{"args":["--headless"]}}}'
fi
resp=$(curl -X POST -d "${caps}" http://localhost:7002/session)
echo "resp: ${resp}"
SESSIONID=$(echo "${resp}" | jq -r ".sessionId")
echo "SESSIONID: ${SESSIONID}"
curl -v -X POST -d '{"url": "http://localhost:9080/test.html"}' http://localhost:7002/session/${SESSIONID}/url
curl -v http://localhost:7002/session/${SESSIONID}/screenshot | jq -r ".value" | base64 -d > test.png
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
...
joelm 10176 0.0 0.0 26144 8876 pts/10 Ss Dec13 0:00 \_ bash
joelm 4022 4.5 0.0 104976 9460 pts/10 Sl+ 11:03 0:01 | \_ ./chromedriver --port=7002
joelm 4072 1.0 0.6 726784 76428 pts/10 Sl+ 11:04 0:00 | \_ /opt/brave.com/brave/brave --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-gpu --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --headless --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.OrMYX1/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.MjnBR9 data:,
joelm 4078 0.0 0.0 7448 660 pts/10 S+ 11:04 0:00 | \_ cat
joelm 4079 0.0 0.0 7448 724 pts/10 S+ 11:04 0:00 | \_ cat
joelm 4083 0.0 0.3 417244 47724 pts/10 S+ 11:04 0:00 | \_ /opt/brave.com/brave/brave --type=zygote --enable-logging --headless --log-level=0 --headless
joelm 4085 0.0 0.0 417244 11480 pts/10 S+ 11:04 0:00 | | \_ /opt/brave.com/brave/brave --type=zygote --enable-logging --headless --log-level=0 --headless
joelm 4102 0.0 0.4 674464 61072 pts/10 Sl+ 11:04 0:00 | | \_ /opt/brave.com/brave/brave --type=renderer --enable-automation --enable-logging --log-level=0 --test-type=webdriver --use-gl=swiftshader-webgl --disable-gpu-compositing --service-pi
joelm 4104 0.1 0.4 456140 54212 pts/10 Sl+ 11:04 0:00 | \_ /opt/brave.com/brave/brave --type=gpu-process --enable-logging --headless --log-level=0 --headless --gpu-preferences=KAAAAAAAAACAAABAAQAAAAAAAAAAAGAAAAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAA --use-gl=swiftshader-webgl --override-use-software-gl-for-tests --headless --enable-logging --log-level=0 --service-request-channel-token=10655509899470837681
joelm 4118 0.0 0.0 423352 12276 pts/10 S+ 11:04 0:00 | \_ /opt/brave.com/brave/brave --type=-broker
...
<html><body style="background: #12890f">
<div>This is a test of the emergency broadcast system.</div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment