Add option to disable headless mode

This commit is contained in:
3wc 2021-01-15 15:05:40 +02:00
parent 07da641a12
commit e24ef80272

15
main.py
View File

@ -14,7 +14,7 @@ from selenium.webdriver.support.ui import WebDriverWait
class BaseTester: class BaseTester:
def __init__(self, user: str, passwd: str, dev: bool): def __init__(self, user: str, passwd: str, dev: bool, show_browser: bool):
self.user = user self.user = user
self.passwd = passwd self.passwd = passwd
if dev: if dev:
@ -23,7 +23,7 @@ class BaseTester:
self.base_url = "https://crm.caat.org.uk" self.base_url = "https://crm.caat.org.uk"
firefox_options = webdriver.FirefoxOptions() firefox_options = webdriver.FirefoxOptions()
firefox_options.headless = True firefox_options.headless = not show_browser
self.browser = webdriver.Firefox(options=firefox_options) self.browser = webdriver.Firefox(options=firefox_options)
self.wait = WebDriverWait(self.browser, 20) self.wait = WebDriverWait(self.browser, 20)
@ -170,6 +170,13 @@ if __name__ == "__main__":
action="store_true", action="store_true",
help="Test dev site instead of production" help="Test dev site instead of production"
) )
parser.set_defaults(dev=False) parser.add_argument(
"--show_browser",
"-s",
dest="show_browser",
action="store_true",
help="Show the web browser"
)
parser.set_defaults(dev=False, show_browser=False)
arguments = parser.parse_args() arguments = parser.parse_args()
ContactExport(arguments.user, arguments.passwd, arguments.dev).test("John") ContactExport(arguments.user, arguments.passwd, arguments.dev, arguments.show_browser).test("John")