Вопрос следующий:
имеется тест:
import time
import unittest
from ddt import ddt, data, unpack
from base.baseclass import BaseClass
from base.selenium_driver import SeleniumDriver
from pages.home_page import HomePage
from pages.login_page import LoginPage
from pages.notebook_page import NotebookPage
@ddt
class TestLogin(unittest.TestCase):
@data(('chrome', '59.0'), ('chrome', '67.0'), ('firefox', '57.0'), ('firefox', '60.0'))
@unpack
def test_valid_login_(self, browser, version):
# creating instance of Base class
self.bc = BaseClass()
# opening browser
self.driver = self.bc.open_browser_remote(browser, version)
# creating instance of Selenium Driver class
self.sw = SeleniumDriver(self.driver)
# creating instance of Login page
self.lp = LoginPage(self.driver)
# creating instance of Home page
self.hp = HomePage(self.driver)
# creating instance of Notebook page
self.np = NotebookPage(self.driver)
# opening website in browser
self.bc.open_go()
# signing in with credentials specified in config.ini file
self.lp.login(self.bc.get_username(), self.bc.get_password())
# verifying that sign in was successful and we are now located on the Home page
assert self.hp.located_on_homepage() == True
# getting handle of current window so later we can switch to new one
parentHandle = self.bc.get_window_handle()
# clicking on 'New' button
self.hp.click_new_button()
# switching to new opened window
self.bc.switch_to_new_window(parentHandle)
# click on text field
self.np.click_text_field()
# enter text to field in notebook
self.np.text_to_field("print('Hello')")
# run notebook
self.np.run_notebook()
# assert notebook run
result = self.np.verify_output()
assert result == True
# get name of current notebook so we can delete it later
notebook_name = self.np.get_name_notebook()
# click save button
self.np.click_save_button()
# switch back to parent window
self.driver.switch_to_window(parentHandle)
# refresh page
self.driver.refresh()
# click on checkbox of created notebook
self.hp.click_checkbox(notebook_name)
# delete notebook
self.hp.delete_notebook()
# log out
self.hp.click_logout_button()
# verifying that we logged out and that we are now located on Login page
assert self.lp.located_on_login_page() == True
# closing browser
self.driver.quit()
как правильно сделать инициализацию объектов страниц в методе setUp?
Получается так, что если просто перемещу туда:
# creating instance of Base class
self.bc = BaseClass()
# opening browser
self.driver = self.bc.open_browser_remote(browser, version)
# creating instance of Selenium Driver class
self.sw = SeleniumDriver(self.driver)
# creating instance of Login page
self.lp = LoginPage(self.driver)
# creating instance of Home page
self.hp = HomePage(self.driver)
# creating instance of Notebook page
self.np = NotebookPage(self.driver)
то метод запустится только один раз, а мне надо тесты провести на разных браузерах…