Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge-case when saving a screenshot for the logs when using multiple drivers in one test #857

Closed
mdmintz opened this issue Apr 9, 2021 · 1 comment
Assignees
Labels
bug Uh oh... Something needs to be fixed

Comments

@mdmintz
Copy link
Member

mdmintz commented Apr 9, 2021

Edge-case when saving a screenshot for the logs when using multiple drivers in one test.

There's a very specific edge case that can occur if a test opens a second browser driver using self.get_new_driver() and then the user navigates to an unresponsive page (or the browser window is closed) if there is also a custom tearDown() method that navigates back to the original driver. Currently, the screenshot that would appear in the logs would be of the original driver browser that is also open. The expected behavior here should be that if the screenshot can't be taken using self.save_teardown_screenshot() in the custom tearDown() (because a site is unresponsive or the browser window closed prematurely), then there should be no screenshot at all in the logs, because that would be misleading. The screenshot should match the page where a stack trace occurred.

Here's an example that reproduces the bug:

from seleniumbase import BaseCase

class MyTestClass(BaseCase):

    def tearDown(self):
        self.save_teardown_screenshot()
        self.switch_to_default_driver()
        super(MyTestClass, self).tearDown()

    def test_steps_to_reproduce_bug(self):
        self.open("https://xkcd.com/353/")
        self.get_new_driver()
        self.driver.quit()  # Simulate an unresponsive site
        self.assert_element("fake.item", timeout=1)

Adding a related error message in the page_source.html file in the logs would also be helpful.

@mdmintz mdmintz added the bug Uh oh... Something needs to be fixed label Apr 9, 2021
@mdmintz mdmintz self-assigned this Apr 9, 2021
@mdmintz mdmintz changed the title Edge-case when saving a screenshot for the failure logs when using multiple browser drivers in one test Edge-case when saving a screenshot for the logs when using multiple browser drivers in one test Apr 9, 2021
@mdmintz mdmintz changed the title Edge-case when saving a screenshot for the logs when using multiple browser drivers in one test Edge-case when saving a screenshot for the logs when using multiple drivers in one test Apr 9, 2021
@mdmintz
Copy link
Member Author

mdmintz commented Apr 10, 2021

@mdmintz mdmintz closed this as completed Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh oh... Something needs to be fixed
Projects
None yet
Development

No branches or pull requests

1 participant