Skip to content

Commit

Permalink
Set timeout for page load
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon Medeiros committed Dec 28, 2019
1 parent 072c8ff commit 6e7220f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions uiTests/pages/kimchi_project/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import utils

from selenium.common.exceptions import TimeoutException

# locators by ID
USERNAME = "username"
PASSWORD = "password"
Expand Down Expand Up @@ -35,14 +37,19 @@ def __init__(self, browser):
assert ENV_HOST in os.environ, f"{ENV_HOST} is a required environment var"

# get values
host = os.environ[ENV_HOST]
port = os.environ.get(ENV_PORT) or "8001"
self.host = os.environ[ENV_HOST]
self.port = os.environ.get(ENV_PORT) or "8001"
self.user = os.environ[ENV_USER]
self.password = os.environ[ENV_PASS]

self.browser.get(f"https://{host}:{port}/login.html")

def login(self):
try:
url = f"https://{self.host}:{self.port}/login.html"
self.browser.get(url)
except TimeoutException as e:
logging.error(f"Cannot reach kimchi at {url}")
return False

# fill user and password
utils.fillTextIfElementIsVisibleById(self.browser,
USERNAME,
Expand Down
4 changes: 3 additions & 1 deletion uiTests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def getBrowser(headless=True):
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')

return webdriver.Chrome(options=options)
driver = webdriver.Chrome(options=options)
driver.set_page_load_timeout(WAIT * 2)
return driver

def waitElementByCondition(browser, condition, searchMethod, searchString, errorMessage, time=WAIT):
try:
Expand Down

0 comments on commit 6e7220f

Please sign in to comment.