Skip to content

two webdriver question #1235

Answered by mdmintz
c350147221 asked this question in Q&A
Discussion options

You must be logged in to vote

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

Comment options

You must be logged in to vote
0 replies
Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants