Refactor default browser resolutions into a settings file

This commit is contained in:
Michael Mintz 2019-12-10 00:53:18 -05:00
parent ac5a0feb82
commit 28df69c2ac
3 changed files with 24 additions and 4 deletions

View File

@ -30,6 +30,14 @@ DISABLE_CSP_ON_CHROME = False
# If True and --proxy=IP_ADDRESS:PORT is invalid, then error immediately. # If True and --proxy=IP_ADDRESS:PORT is invalid, then error immediately.
RAISE_INVALID_PROXY_STRING_EXCEPTION = True RAISE_INVALID_PROXY_STRING_EXCEPTION = True
# Default browser resolutions when opening new windows for tests.
# (Headless resolutions take priority, and include all browsers.)
# (Firefox starts maximized by default when running in GUI Mode.)
CHROME_START_WIDTH = 1250
CHROME_START_HEIGHT = 840
HEADLESS_START_WIDTH = 1440
HEADLESS_START_HEIGHT = 1880
# Changing the default behavior of MasterQA Mode. # Changing the default behavior of MasterQA Mode.
MASTERQA_DEFAULT_VALIDATION_MESSAGE = "Does the page look good?" MASTERQA_DEFAULT_VALIDATION_MESSAGE = "Does the page look good?"
MASTERQA_WAIT_TIME_BEFORE_VERIFY = 0.5 MASTERQA_WAIT_TIME_BEFORE_VERIFY = 0.5

View File

@ -85,6 +85,14 @@ DISABLE_CSP_ON_CHROME = False
# (This applies when using --proxy=[PROXY_STRING] for using a proxy server.) # (This applies when using --proxy=[PROXY_STRING] for using a proxy server.)
RAISE_INVALID_PROXY_STRING_EXCEPTION = True RAISE_INVALID_PROXY_STRING_EXCEPTION = True
# Default browser resolutions when opening new windows for tests.
# (Headless resolutions take priority, and include all browsers.)
# (Firefox starts maximized by default when running in GUI Mode.)
CHROME_START_WIDTH = 1250
CHROME_START_HEIGHT = 840
HEADLESS_START_WIDTH = 1440
HEADLESS_START_HEIGHT = 1880
# #####>>>>>----- MasterQA SETTINGS -----<<<<<##### # #####>>>>>----- MasterQA SETTINGS -----<<<<<#####
# ##### (Used when importing MasterQA as the parent class) # ##### (Used when importing MasterQA as the parent class)

View File

@ -1457,8 +1457,10 @@ class BaseCase(unittest.TestCase):
self.driver = new_driver self.driver = new_driver
if self.headless: if self.headless:
# Make sure the invisible browser window is big enough # Make sure the invisible browser window is big enough
width = settings.HEADLESS_START_WIDTH
height = settings.HEADLESS_START_HEIGHT
try: try:
self.set_window_size(1440, 1880) self.set_window_size(width, height)
self.wait_for_ready_state_complete() self.wait_for_ready_state_complete()
except Exception: except Exception:
# This shouldn't fail, but in case it does, # This shouldn't fail, but in case it does,
@ -1467,8 +1469,8 @@ class BaseCase(unittest.TestCase):
pass pass
else: else:
if self.browser == 'chrome': if self.browser == 'chrome':
width = 1250 width = settings.CHROME_START_WIDTH
height = 840 height = settings.CHROME_START_HEIGHT
try: try:
if self.maximize_option: if self.maximize_option:
self.driver.maximize_window() self.driver.maximize_window()
@ -4198,10 +4200,12 @@ class BaseCase(unittest.TestCase):
self.testcase_manager.insert_testcase_data(data_payload) self.testcase_manager.insert_testcase_data(data_payload)
self.case_start_time = int(time.time() * 1000) self.case_start_time = int(time.time() * 1000)
if self.headless: if self.headless:
width = settings.HEADLESS_START_WIDTH
height = settings.HEADLESS_START_HEIGHT
try: try:
# from pyvirtualdisplay import Display # Skip for own lib # from pyvirtualdisplay import Display # Skip for own lib
from seleniumbase.virtual_display.display import Display from seleniumbase.virtual_display.display import Display
self.display = Display(visible=0, size=(1440, 1880)) self.display = Display(visible=0, size=(width, height))
self.display.start() self.display.start()
self.headless_active = True self.headless_active = True
except Exception: except Exception: