Skip to content

Commit 1991398

Browse files
committed
Integrating Chrome testing with Travis
1 parent 3ba8904 commit 1991398

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

.travis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@ addons:
1111
- python-dev
1212
- libcurl4-openssl-dev
1313
- python-lxml
14+
- python-software-properties
15+
- chromium-browser
1416
firefox: "37.0"
1517
virtualenv:
1618
system_site_packages: true
1719
install:
1820
- pip install -r https-everywhere-checker/requirements.txt
1921
- pip install -r test/chromium/requirements.txt
20-
before_script:
21-
- sh -e /etc/init.d/xvfb start
2222
env:
2323
- DISPLAY=':99.0'
24+
before_script:
25+
- export DISPLAY=:99.0
26+
- sh -e /etc/init.d/xvfb start
27+
- wget https://chromedriver.storage.googleapis.com/2.12/chromedriver_linux64.zip
28+
- unzip chromedriver_linux64.zip
29+
- mv chromedriver test/chromium/chromedriver
2430
script:
2531
- ./test.sh
2632
sudo: false
@@ -34,4 +40,3 @@ notifications:
3440
- "irc.oftc.net#https-everywhere"
3541
on_success: change
3642
on_failure: change
37-

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ cd $(dirname $0)/$(dirname $(readlink $0))
1010

1111
./test/rules.sh
1212
./test/firefox.sh $@
13-
# ./test/chromium.sh $@
13+
./test/chromium.sh $@

test/chromium/script.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# of linux is required for the script to run correctly as well.
1111
# Otherwise, use pyvirtualdisplay.
1212

13-
import sys
13+
import sys, os
1414
from selenium import webdriver
1515
from selenium.common.exceptions import WebDriverException
1616

@@ -26,20 +26,27 @@ class bcolors:
2626

2727
chromeOps = webdriver.ChromeOptions()
2828
chromeOps.add_extension(sys.argv[1])
29+
chromeOps.add_argument("--disable-setuid-sandbox")
30+
31+
chromdriver_path = "chromedriver"
32+
33+
if 'TRAVIS' in os.environ:
34+
chromeOps.add_argument('--no-sandbox')
35+
chromdriver_path = os.path.abspath("test/chromium/chromedriver")
2936

3037
# First argument is optional, if not specified will search path.
3138

3239
try:
33-
driver = webdriver.Chrome('chromedriver', chrome_options=chromeOps)
40+
driver = webdriver.Chrome(chromdriver_path, chrome_options=chromeOps)
3441
except WebDriverException as e:
3542
error = e.__str__()
3643

3744
if "executable needs to be in PATH" in e.__str__():
3845
print "ChromeDriver isn't installed. Check test/chrome/README.md\
39-
for instructions on how to install ChromeDriver"
46+
for instructions on how to install ChromeDriver"
47+
4048
sys.exit(2)
4149
else:
42-
driver.quit()
4350
raise e
4451

4552
print '' #New line

0 commit comments

Comments
 (0)