Skip to content

Commit

Permalink
Added options to Firefox driver like Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
rofrano committed Dec 9, 2024
1 parent ef1e63e commit 541b9df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"Rofrano",
"sqlalchemy",
"psycopg",
"wsgi",
"dotenv",
"pytest",
"tekton",
"creds",
Expand Down Expand Up @@ -64,7 +66,6 @@
"njpwerner.autodocstring",
"wholroyd.jinja",
"redhat.vscode-yaml",
"redhat.fabric8-analytics",
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"inercia.vscode-k3d",
Expand Down
22 changes: 14 additions & 8 deletions features/environment.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
"""
Environment for Behave Testing
"""

from os import getenv
from selenium import webdriver

WAIT_SECONDS = int(getenv('WAIT_SECONDS', '30'))
BASE_URL = getenv('BASE_URL', 'http://localhost:8080')
DRIVER = getenv('DRIVER', 'firefox').lower()
WAIT_SECONDS = int(getenv("WAIT_SECONDS", "30"))
BASE_URL = getenv("BASE_URL", "http://localhost:8080")
DRIVER = getenv("DRIVER", "firefox").lower()


def before_all(context):
""" Executed once before all tests """
"""Executed once before all tests"""
context.base_url = BASE_URL
context.wait_seconds = WAIT_SECONDS
# Select either Chrome or Firefox
if 'firefox' in DRIVER:
if "firefox" in DRIVER:
context.driver = get_firefox()
else:
context.driver = get_chrome()
Expand All @@ -24,15 +25,18 @@ def before_all(context):


def after_all(context):
""" Executed after all tests """
"""Executed after all tests"""
context.driver.quit()


######################################################################
# Utility functions to create web drivers
######################################################################


def get_chrome():
"""Creates a headless Chrome driver"""
print("Running Behave using the Chrome driver...\n")
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
Expand All @@ -42,7 +46,9 @@ def get_chrome():

def get_firefox():
"""Creates a headless Firefox driver"""
print("Running Behave using the Firefox driver...\n")
options = webdriver.FirefoxOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
return webdriver.Firefox(options=options)

return webdriver.Firefox(options=options)

0 comments on commit 541b9df

Please sign in to comment.