diff options
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index d9ea7fd108..46ced5a167 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |||
| @@ -24,7 +24,8 @@ from selenium.webdriver.support.ui import WebDriverWait | |||
| 24 | from selenium.webdriver.common.by import By | 24 | from selenium.webdriver.common.by import By |
| 25 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | 25 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities |
| 26 | from selenium.common.exceptions import NoSuchElementException, \ | 26 | from selenium.common.exceptions import NoSuchElementException, \ |
| 27 | StaleElementReferenceException, TimeoutException | 27 | StaleElementReferenceException, TimeoutException, \ |
| 28 | SessionNotCreatedException | ||
| 28 | 29 | ||
| 29 | def create_selenium_driver(cls,browser='chrome'): | 30 | def create_selenium_driver(cls,browser='chrome'): |
| 30 | # set default browser string based on env (if available) | 31 | # set default browser string based on env (if available) |
| @@ -39,7 +40,25 @@ def create_selenium_driver(cls,browser='chrome'): | |||
| 39 | options.add_argument('--disable-dev-shm-usage') | 40 | options.add_argument('--disable-dev-shm-usage') |
| 40 | options.add_argument('--no-sandbox') | 41 | options.add_argument('--no-sandbox') |
| 41 | options.add_argument('--remote-debugging-port=9222') | 42 | options.add_argument('--remote-debugging-port=9222') |
| 42 | return webdriver.Chrome(options=options) | 43 | try: |
| 44 | return webdriver.Chrome(options=options) | ||
| 45 | except SessionNotCreatedException as e: | ||
| 46 | # check if chrome / chromedriver exists | ||
| 47 | chrome_path = os.popen("find ~/.cache/selenium/chrome/ -name 'chrome' -type f -print -quit").read().strip() | ||
| 48 | if not chrome_path: | ||
| 49 | raise SessionNotCreatedException("Failed to install/find chrome") | ||
| 50 | chromedriver_path = os.popen("find ~/.cache/selenium/chromedriver/ -name 'chromedriver' -type f -print -quit").read().strip() | ||
| 51 | if not chromedriver_path: | ||
| 52 | raise SessionNotCreatedException("Failed to install/find chromedriver") | ||
| 53 | # check if depends on each are fulfilled | ||
| 54 | depends_chrome = os.popen(f"ldd {chrome_path} | grep 'not found'").read().strip() | ||
| 55 | if depends_chrome: | ||
| 56 | raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chrome}") | ||
| 57 | depends_chromedriver = os.popen(f"ldd {chromedriver_path} | grep 'not found'").read().strip() | ||
| 58 | if depends_chromedriver: | ||
| 59 | raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chromedriver}") | ||
| 60 | # raise original error otherwise | ||
| 61 | raise e | ||
| 43 | elif browser == 'firefox': | 62 | elif browser == 'firefox': |
| 44 | return webdriver.Firefox() | 63 | return webdriver.Firefox() |
| 45 | elif browser == 'marionette': | 64 | elif browser == 'marionette': |
