'Is there any way to run those two tests on same browser session?

Testcases--- I'm intending to run those test cases on same browser session but always a new session starts for individual tests.

Is there any one faced the same issue and solved or someone can share a solution would be much appreciated.

import allure
import pytest
from tests.base_test import BaseTest
from application_settings.application_settings import ApplicationSettings


class LoginPageTest(BaseTest):

    application_settings = ApplicationSettings()

    @allure.title("Login Page - smoke test")
    @allure.description("Check if login functionalities work properly")
    def test_01_login_functionality(self):
        login_data = self.application_settings.get_test_data_from_excel(sheet_name="login", table_name="login_data")
        login_page = self.page_factory.get_login_page()
        print("Starting to test login functionality")
        login_result = login_page.login(*login_data)
        assert login_result is True, "Login failed"

    @allure.title("test_login_functionality_negative")
    @allure.description("Check if login functionalities work properly")
    def test_02_home_functionality(self):
        login_page = self.page_factory.get_login_page()
        print("Starting to test login functionality")
        login_result = login_page.test_homepage()
        assert login_result is True, "Login failed"

Here is the BaseTest class

import sys
import os.path
import unittest
from browser_utility.browser import Browser
from pages.page_factory import PageFactory

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))


class BaseTest(unittest.TestCase):
    browser = Browser()
    driver = None
    page_factory = None

    def setUp(self):
        self.browser.launch_browser()
        self.browser.maximize_browser()
        self.browser.go_to_url()
        self.driver = self.browser.get_web_driver()
        self.page_factory = PageFactory(self.driver)

    def tearDown(self):
        self.browser.close_browser()


Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source