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

[FEATURE] Run Browser once in TestClass #60

Open
akozyreva opened this issue Jun 14, 2021 · 2 comments
Open

[FEATURE] Run Browser once in TestClass #60

akozyreva opened this issue Jun 14, 2021 · 2 comments

Comments

@akozyreva
Copy link

Hi!
I have the following code:

class TestClass:
    def test_a(self, page):
        print("open site")
        self.page = page
        self.page.goto("https://microsoft.com")
    
    def test_b(self, page):
        print("check title of site")
        self.page = page
        page_title = self.page.title()#
        assert page_title == "Microsoft - Official Home Page"

The question is - how can I run browser once for 2 tests? Sequence should be the following - browser is starting, test_a is executing, then test_b is executing, then browser is closing.

@mxschmitt
Copy link
Member

Currently the test runner is optimised for method based tests: https://docs.pytest.org/en/latest/getting-started.html#create-your-first-test where the best support is given.

We might explore class based testing in the future, will mark it as "p3-collecting-feedback".

@mxschmitt mxschmitt changed the title Run Browser once in TestClass [FEATURE] Run Browser once in TestClass Jul 6, 2022
@storenth
Copy link

I suggest to spawn your own browser based custom_page or something because of its session implementation:
Screenshot 2024-02-19 at 23 35 17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants