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

browser teardown fix at session exit #1390

Merged

Conversation

pnovotny
Copy link
Contributor

Problem Statement

When nesting airgun.session.Session in multiple context managers (like robottelo session fixture does),
the __exit__ method, which handles browser teardown, is called mutliple times as well.

This causes that the second and further attempt to call webdriver.quit() will fail,
because the browser was already closed.

Solution

Execute the browser teardown only once.

Related Issues

Needed for SatelliteQE/robottelo#15050

The browser teardown in `airgun.session.Session.__exit__` should be executed only once.

Because when `Session` is nested in multiple context managers(*),
the `__exit__` method is called for each one
and this causes that the second and further `webdriver.quit()` call will fail,
because the browser session was already stopped.

(*) for example in the robottelo `session` fixture in `robottelo/pytest_fixtures/core/ui.py`.
@pnovotny pnovotny added 6.12.z CherryPick PR needs CherryPick to previous branches 6.13.z AutoMerge_Cherry_Picked Automatically merge the PR is PRT and all checks are passing 6.14.z 6.15.z labels May 21, 2024
@pnovotny pnovotny self-assigned this May 21, 2024
@pnovotny pnovotny requested review from pondrejk, lhellebr and a team May 21, 2024 20:52
@pnovotny pnovotny marked this pull request as ready for review May 22, 2024 09:50
@omkarkhatavkar
Copy link
Collaborator

This needs to be merged as it is highly dependent on the Robottelo PR.

@omkarkhatavkar omkarkhatavkar merged commit d9cfc90 into SatelliteQE:master May 23, 2024
10 of 12 checks passed
github-actions bot pushed a commit that referenced this pull request May 23, 2024
The browser teardown in `airgun.session.Session.__exit__` should be executed only once.

Because when `Session` is nested in multiple context managers(*),
the `__exit__` method is called for each one
and this causes that the second and further `webdriver.quit()` call will fail,
because the browser session was already stopped.

(*) for example in the robottelo `session` fixture in `robottelo/pytest_fixtures/core/ui.py`.

(cherry picked from commit d9cfc90)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.12.z 6.13.z 6.14.z 6.15.z AutoMerge_Cherry_Picked Automatically merge the PR is PRT and all checks are passing CherryPick PR needs CherryPick to previous branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants