-
Notifications
You must be signed in to change notification settings - Fork 1.4k
two webdriver question #1235
-
hi.
If I start two webdrivers and the second driver reports an abnormal error, the screenshot at this time is still the default first driver page, then what if I can take a screenshot of the second driver?
Beta Was this translation helpful? Give feedback.
All reactions
Use the self.get_new_driver()
method when opening a new driver. If there's an error, the screenshot will be taken on the latest-used driver.
Example: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_multiple_drivers.py
from seleniumbase import BaseCase class MultipleDriversTest(BaseCase): def test_multiple_drivers(self): self.open("data:text/html,<h1>Driver 1</h1>") driver2 = self.get_new_driver() self.open("data:text/html,<h1>Driver 2</h1>") self.switch_to_default_driver() # Driver 1 self.highlight("h1") self.assert_text("Driver 1", "h1") self.switch_to_driver(driver2) # Driver 2 self.highlight("h1"
Replies: 1 comment
-
Use the self.get_new_driver()
method when opening a new driver. If there's an error, the screenshot will be taken on the latest-used driver.
Example: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_multiple_drivers.py
from seleniumbase import BaseCase class MultipleDriversTest(BaseCase): def test_multiple_drivers(self): self.open("data:text/html,<h1>Driver 1</h1>") driver2 = self.get_new_driver() self.open("data:text/html,<h1>Driver 2</h1>") self.switch_to_default_driver() # Driver 1 self.highlight("h1") self.assert_text("Driver 1", "h1") self.switch_to_driver(driver2) # Driver 2 self.highlight("h1") self.assert_text("Driver 2", "h1")
get_new_driver()
can be called with multiple options:
self.get_new_driver( browser=None, headless=None, locale_code=None, protocol=None, servername=None, port=None, proxy=None, proxy_bypass_list=None, agent=None, switch_to=True, cap_file=None, cap_string=None, recorder_ext=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, ad_block_on=None, block_images=None, chromium_arg=None, firefox_arg=None, firefox_pref=None, user_data_dir=None, extension_zip=None, extension_dir=None, external_pdf=None, is_mobile=None, d_width=None, d_height=None, d_p_r=None, )
Beta Was this translation helpful? Give feedback.