How to create multiple "sessions" or "contexts" #1166
-
I want to use seleniumbase to emulate two users logging in to the same site, then go back and forth having one user do something and the other How would this work? I thought about using windows and tabs, but I assume that the drives don't isolate sessions, cookies, etc by default? I looked through the docs and didn't see anything promising, but I'm sorry if this is a dumb question 😅 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hi @benjamin-kirkbride There is a way to do that. Here are some methods you may need: self.get_new_driver(
browser=None, headless=None, locale_code=None, protocol=None,
servername=None, port=None, proxy=None, agent=None, switch_to=True,
cap_file=None, cap_string=None, disable_csp=None, enable_ws=None,
enable_sync=None, use_auto_ext=None, no_sandbox=None, disable_gpu=None,
incognito=None, guest_mode=None, devtools=None, remote_debug=None,
swiftshader=None, block_images=None,
chromium_arg=None, firefox_arg=None, firefox_pref=None,
user_data_dir=None, extension_zip=None, extension_dir=None,
is_mobile=None, d_width=None, d_height=None, d_p_r=None)
self.switch_to_driver(driver)
self.switch_to_default_driver() If you call A sample script could look like this: from seleniumbase import BaseCase
class MyTestClass(BaseCase):
def test_two_drivers(self):
self.open("data:text/html,<p>Driver 1 is active</p>")
driver2 = self.get_new_driver()
self.open("data:text/html,<p>Driver 2 is active</p>")
self.switch_to_default_driver()
self.assert_text("Driver 1 is active")
self.switch_to_driver(driver2)
self.assert_text("Driver 2 is active") |
Beta Was this translation helpful? Give feedback.
Hi @benjamin-kirkbride There is a way to do that. Here are some methods you may need: