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 <alexander.lussier-cullen@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexander Lussier-Cullen
2023-12-11 15:36:02 -05:00
committed by Richard Purdie
parent df5c8d6471
commit effe2498eb

View File

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