Skip to content

Commit e3155d2

Browse files
committed
Switch to Chrome headless for Selenium test
1 parent 92d65cb commit e3155d2

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ python:
1919
- '3.6'
2020
env:
2121
global:
22-
- DISPLAY=:99.0
2322
- GECKO_DRIVER_VERSION=v0.16.1
2423
- CHROME_DRIVER_VERSION=2.29
2524
matrix:
@@ -42,12 +41,10 @@ matrix:
4241
install:
4342
- pip install --upgrade pip tox
4443
- pip install -U coveralls
45-
- sh -e /etc/init.d/xvfb start
4644
before_script:
4745
- mkdir bin
4846
- curl -O https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip
4947
- unzip chromedriver_linux64.zip -d bin
50-
- curl -Lo - "https://github.com/mozilla/geckodriver/releases/download/${GECKO_DRIVER_VERSION}/geckodriver-${GECKO_DRIVER_VERSION}-linux64.tar.gz" | tar xzf - -C bin
5148
- PATH=$PATH:$PWD/bin
5249
- |
5350
if [[ -z $TOXENV ]]; then

tests/conftest.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import os
55
import tempfile
6-
from time import sleep
76

87
import pytest
98
from django.core.files.base import ContentFile
@@ -17,22 +16,17 @@
1716
}
1817

1918

20-
@pytest.yield_fixture(scope='session', params=sorted(browsers.keys()))
21-
def driver(request):
22-
if 'DISPLAY' not in os.environ:
23-
pytest.skip('Test requires display server (export DISPLAY)')
24-
19+
@pytest.yield_fixture(scope='session')
20+
def driver():
21+
chrome_options = webdriver.ChromeOptions()
22+
chrome_options.add_argument('headless')
23+
chrome_options.add_argument('window-size=1200x800')
2524
try:
26-
b = browsers[request.param]()
25+
b = webdriver.Chrome(chrome_options=chrome_options)
2726
except WebDriverException as e:
2827
pytest.skip(force_text(e))
2928
else:
30-
b.set_window_size(1200, 800)
31-
b.implicitly_wait(0.1)
3229
yield b
33-
if isinstance(b, webdriver.Chrome):
34-
# chrome needs a couple of seconds before it can be quit
35-
sleep(5)
3630
b.quit()
3731

3832

0 commit comments

Comments
 (0)