diff mbox series

bitbake: toaster: Add verbose printout for missing chrome(driver) dependencies

Message ID 20231211203602.31749-1-alexander.lussier-cullen@savoirfairelinux.com
State New
Headers show
Series bitbake: toaster: Add verbose printout for missing chrome(driver) dependencies | expand

Commit Message

Alexander Lussier-Cullen Dec. 11, 2023, 8:36 p.m. UTC
Signed-off-by: Alexander Lussier-Cullen <alexander.lussier-cullen@savoirfairelinux.com>
---
 .../tests/browser/selenium_helpers_base.py    | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
diff mbox series

Patch

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':