Skip to content

Commit cc13a35

Browse files
committed
[temp] Use Firefox for selenium test
1 parent d49a6fd commit cc13a35

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

openwisp_firmware_upgrader/tests/test_selenium.py

+26
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import os
12
from unittest.mock import patch
23

34
import swapper
5+
from django.conf import settings
46
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
57
from django.core.management import call_command
68
from django.urls.base import reverse
79
from reversion.models import Version
10+
from selenium import webdriver
811
from selenium.common.exceptions import TimeoutException, UnexpectedAlertPresentException
912
from selenium.webdriver.common.by import By
13+
from selenium.webdriver.firefox.options import Options as FirefoxOptions
1014
from selenium.webdriver.support import expected_conditions as EC
1115
from selenium.webdriver.support.ui import Select, WebDriverWait
1216

@@ -31,6 +35,28 @@ class TestDeviceAdmin(TestUpgraderMixin, SeleniumTestMixin, StaticLiveServerTest
3135
os = 'OpenWrt 19.07-SNAPSHOT r11061-6ffd4d8a4d'
3236
image_type = REVERSE_FIRMWARE_IMAGE_MAP['YunCore XD3200']
3337

38+
@classmethod
39+
def setUpClass(cls):
40+
StaticLiveServerTestCase.setUpClass()
41+
42+
firefox_options = FirefoxOptions()
43+
firefox_options.page_load_strategy = 'eager'
44+
if getattr(settings, 'SELENIUM_HEADLESS', True):
45+
firefox_options.add_argument('--headless')
46+
47+
FIREFOX_BIN = os.environ.get('FIREFOX_BIN', None)
48+
if FIREFOX_BIN:
49+
firefox_options.binary_location = FIREFOX_BIN
50+
51+
# Set window size
52+
firefox_options.add_argument('--width=1366')
53+
firefox_options.add_argument('--height=768')
54+
55+
# Ignore certificate errors
56+
firefox_options.accept_insecure_certs = True
57+
58+
cls.web_driver = webdriver.Firefox(options=firefox_options)
59+
3460
def _set_up_env(self):
3561
org = self._get_org()
3662
category = self._get_category(organization=org)

0 commit comments

Comments
 (0)