From effe2498ebecfc2065993a290c1a50b9c6adfca0 Mon Sep 17 00:00:00 2001 From: Alexander Lussier-Cullen Date: Mon, 11 Dec 2023 15:36:02 -0500 Subject: bitbake: toaster: Add verbose printout for missing chrome(driver) dependencies If the chrome driver binary is missing dependencies, it was near impossible to work out which ones from just the logs. Add code to help debug things if this happens by including the ldd output. (Bitbake rev: 0ffe5fccbb7db5aca5c409fe00be2be69a6e37d9) Signed-off-by: Alexander Lussier-Cullen Signed-off-by: Richard Purdie --- .../toaster/tests/browser/selenium_helpers_base.py | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'bitbake/lib/toaster/tests/browser/selenium_helpers_base.py') 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 from selenium.webdriver.common.by import By from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.common.exceptions import NoSuchElementException, \ - StaleElementReferenceException, TimeoutException + StaleElementReferenceException, TimeoutException, \ + SessionNotCreatedException def create_selenium_driver(cls,browser='chrome'): # set default browser string based on env (if available) @@ -39,7 +40,25 @@ def create_selenium_driver(cls,browser='chrome'): options.add_argument('--disable-dev-shm-usage') options.add_argument('--no-sandbox') options.add_argument('--remote-debugging-port=9222') - return webdriver.Chrome(options=options) + try: + return webdriver.Chrome(options=options) + except SessionNotCreatedException as e: + # check if chrome / chromedriver exists + chrome_path = os.popen("find ~/.cache/selenium/chrome/ -name 'chrome' -type f -print -quit").read().strip() + if not chrome_path: + raise SessionNotCreatedException("Failed to install/find chrome") + chromedriver_path = os.popen("find ~/.cache/selenium/chromedriver/ -name 'chromedriver' -type f -print -quit").read().strip() + if not chromedriver_path: + raise SessionNotCreatedException("Failed to install/find chromedriver") + # check if depends on each are fulfilled + depends_chrome = os.popen(f"ldd {chrome_path} | grep 'not found'").read().strip() + if depends_chrome: + raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chrome}") + depends_chromedriver = os.popen(f"ldd {chromedriver_path} | grep 'not found'").read().strip() + if depends_chromedriver: + raise SessionNotCreatedException(f"Missing chrome dependencies\n{depends_chromedriver}") + # raise original error otherwise + raise e elif browser == 'firefox': return webdriver.Firefox() elif browser == 'marionette': -- cgit v1.2.3-54-g00ecf