I am new learner on Selenium Python have created some Test Cases in different py file in Selenium Python. Each time a py file runs it opens the browser and navigates to the URL.
-Test (Package)
-Test_Login.py
-Test_Search.py
-Test_Create.py
How to execute the Test_Search.py and Test_Create.py using same instance browser with logged in ?
-Test_Login.py
import unittest
from selenium import webdriver
import time
class Test_Login( unittest.TestCase ):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome( '../Driver/chromedriver.exe' )
cls.driver.implicitly_wait( 10 )
cls.driver.get( "url...etc" )
def test_A_Login(self):
###login action ....etc
@classmethod
def tearDownClass(cls):
cls.driver.quit()
if __name__ == '__main_':
unittest.main()
-Test_Search.py
import unittest
from selenium import webdriver
import time
class Test_Search( unittest.TestCase ):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Chrome( '../Driver/chromedriver.exe' )
cls.driver.implicitly_wait( 10 )
cls.driver.get( "url...etc" )
def test_A_Search(self):
###Search testing ....etc
@classmethod
def tearDownClass(cls):
cls.driver.quit()
if __name__ == '__main_':
unittest.main()
question from:
https://stackoverflow.com/questions/65901457/selenium-python-run-test-cases-how-do-i-log-in-once-and-use-the-same-instance-br 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…