написала тест и хочу определить фикстуру. но после определения код перестает работать
ниже рабочий код:
from selenium.webdriver.chrome.webdriver import WebDriver
import unittest
from test_V1_app import Application
import pytest
@pytest.fixture()
def app(request):
fixture = Application()
request.addfinalizer(fixture.destroy)
return fixture
class test_v1(unittest.TestCase):
def setUp(self):
self.app = Application()
def test_v2(self):
self.app.open_log("login:Password")
self.app.open_page_files()
self.app.click_add(".jss203.jss255.jss257.jss221")
self.app.test_tax_version(".jss456")
self.app.test_instance_type("input[name='instanceType'][value='BFO']")
self.app.test_period_type("input[name='periodType'][value='YEAR']")
self.app.test_change_year("input[name='year'][value='2018']")
self.app.test_change_entry_point("input[name='entryPointUuid'][value='CC2FAC60-0B06-35AC-94AE-6396F82393E2']")
self.app.click_next(".jss203.jss255.jss260.jss261.jss284")
self.app.click_start_report(".jss203.jss255.jss260.jss261.jss284")
if __name__ == '__main__':
unittest.main()
вот методы в отдельном файл.
from selenium.webdriver.chrome.webdriver import WebDriver
class Application:
def open_page_files(self):
wd.get("http://....")
wd.implicitly_wait(10)
def open_log(self, pwd):
global wd
url = 'http://' + pwd + 'link'
wd = WebDriver()
response = wd.get(url)
def click_add(self,cl_add):
element = wd.find_element_by_css_selector(cl_add)
wd.execute_script("arguments[0].click();", element)
def test_tax_version(self,ver_tax):
element3 = wd.find_element_by_css_selector(ver_tax)
wd.execute_script("arguments[0].click();", element3)
def test_instance_type(self,ins_type):
element1 = wd.find_element_by_css_selector(ins_type)
wd.execute_script("arguments[0].click();", element1)
def test_period_type(self,per_type):
element2 = wd.find_element_by_css_selector(per_type)
wd.execute_script("arguments[0].click();", element2)
def test_change_year(self,change_period):
element4 = wd.find_element_by_css_selector(change_period)
wd.execute_script("arguments[0].click();", element4)
def test_change_entry_point(self,change_en_point):
element5 = wd.find_element_by_css_selector(change_en_point)
wd.execute_script("arguments[0].click();", element5)
def click_next(self,cl_next):
element6 = wd.find_element_by_css_selector(cl_next)
wd.execute_script("arguments[0].click();", element6)
def click_start_report(self,cl_start_report):
element7 = wd.find_element_by_css_selector(cl_start_report)
wd.execute_script("arguments[0].click();", element7)
def destroy(self):
self.wd.quit()
но если удалить класс, чтобы осталась фикстура, то тест не проходит
from selenium.webdriver.chrome.webdriver import WebDriver
from test_V1_app import Application
import pytest
@pytest.fixture()
def app(request):
fixture = Application()
request.addfinalizer(fixture.destroy)
return fixture
def test_v2(app):
app.open_log("login:Password")
app.open_page_files()
app.click_add(".jss203.jss255.jss257.jss221")
app.test_tax_version(".jss456")
app.test_instance_type("input[name='instanceType'][value='BFO']")
app.test_period_type("input[name='periodType'][value='YEAR']")
app.test_change_year("input[name='year'][value='2018']")
app.test_change_entry_point("input[name='entryPointUuid'][value='CC2FAC60-0B06-35AC-94AE-6396F82393E2']")
app.click_next(".jss203.jss255.jss260.jss261.jss284")
app.click_start_report(".jss203.jss255.jss260.jss261.jss284")
выходит сообщение в pycharm:
Process finished with exit code 0