-
I recently updated chromededriver to 136 and package requirements (selenium==4.32.0, seleniumbase==4.38.2). I'm using a BaseTestCase to handle setUp and tearDown for multiple tests but I get an error for a test that should pass. The chromedriver opens an instance of Chrome locally and runs through everything correctly. Printing out
from selenium import webdriver
from app.config.app import app_config
class BaseTestCase(BaseCase):
def get_new_driver(self, *args, **kwargs):
""" This method overrides get_new_driver() from BaseCase. """
options = webdriver.ChromeOptions()
if self.headless:
options.add_argument("--headless")
user_dir_chrome_data = app_config.dir_chrome_data
user_dir_profile = app_config.dir_chrome_profile
if user_dir_chrome_data in kwargs:
user_dir_chrome_data = kwargs[user_dir_chrome_data]
if user_dir_profile in kwargs:
user_dir_profile = kwargs[user_dir_profile]
options.add_argument(f"user-data-dir={user_dir_chrome_data}")
options.add_argument(f"profile-directory={user_dir_profile}")
driver = webdriver.Chrome(options=options)
return driver |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Good catch. For now, override the
Full example: from selenium import webdriver
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class BaseTestCase(BaseCase):
def get_new_driver(self, *args, **kwargs):
"""This method overrides get_new_driver() from BaseCase."""
options = webdriver.ChromeOptions()
options.add_argument("--disable-notifications")
if self.headless:
options.add_argument("--headless=new")
options.add_argument("--disable-gpu")
options.add_experimental_option(
"excludeSwitches", ["enable-automation", "enable-logging"],
)
prefs = {
"credentials_enable_service": False,
"profile.password_manager_enabled": False,
}
options.add_experimental_option("prefs", prefs)
return webdriver.Chrome(options=options)
def is_connected(self, *args, **kwargs):
return True
def test_driver_override(self):
self.open("https://seleniumbase.io/demo_page")
self.type("#myTextInput", "This is Automated")
self.set_value("input#mySlider", "100")
self.select_option_by_text("#mySelect", "Set to 100%")
self.click("#checkBox1")
self.drag_and_drop("img#logo", "div#drop2")
self.click('button:contains("Click Me")')
self.assert_text("SeleniumBase") I'll have a real fix in the next release, which may be delayed slightly because I'm at PyCon this week: But the workaround should be fine until then if you're overriding |
Beta Was this translation helpful? Give feedback.
Good catch. For now, override the
is_connected()
method as a workaround:Full example: