1
+ import os
1
2
from unittest .mock import patch
2
3
3
4
import swapper
5
+ from django .conf import settings
4
6
from django .contrib .staticfiles .testing import StaticLiveServerTestCase
5
7
from django .core .management import call_command
6
8
from django .urls .base import reverse
7
9
from reversion .models import Version
10
+ from selenium import webdriver
8
11
from selenium .common .exceptions import TimeoutException , UnexpectedAlertPresentException
9
12
from selenium .webdriver .common .by import By
13
+ from selenium .webdriver .firefox .options import Options as FirefoxOptions
10
14
from selenium .webdriver .support import expected_conditions as EC
11
15
from selenium .webdriver .support .ui import Select , WebDriverWait
12
16
@@ -31,6 +35,28 @@ class TestDeviceAdmin(TestUpgraderMixin, SeleniumTestMixin, StaticLiveServerTest
31
35
os = 'OpenWrt 19.07-SNAPSHOT r11061-6ffd4d8a4d'
32
36
image_type = REVERSE_FIRMWARE_IMAGE_MAP ['YunCore XD3200' ]
33
37
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
+
34
60
def _set_up_env (self ):
35
61
org = self ._get_org ()
36
62
category = self ._get_category (organization = org )
0 commit comments