test_homepage.py
def test_insurance_pages_open_successfully_using_fixtures(page_object,load_home_page,insurance_data):
page_object.open_insurance(insurance_data)
assert page_object.ui.contains_text('Buying two-wheeler insurance from Coverfox is simple')
页面对象open_insurance
中的 home_page.py
函数
def open_insurance(self,insurance):
self._ui.move_to(locators.drp_dwn_insurance)
self._ui.click(format_locator(locators.lnk_insurance,insurance))
move_to
在另一个file.py
def move_to(self,locator):
to_element = self.find_element(locator)
print("element value",to_element)
self.action.move_to_element(to_element).perform()
我要在这里尝试的是
test_insurance_pages_open_successfully_using_fixtures
以3个装置作为参数 1 。
page_object
,它在会话级 2 上提供页面对象。
load_home_page
,以在会话级 3 上再次加载主页。
insurance_data fixture
中的conftest.py
,哪个供应商从一些CSV文件中读取了链接文本
因此,从本质上讲,它将加载页面并逐个打开网站的所有链接-https://www.coverfox.com/
第一个测试用例通过了链接两轮保险,但是对于第二个测试数据运行,它在尝试移动到{move_to
函数)的点上给出了陈旧元素引用,但失败了/ strong>保险链接。
我不在任何地方存储元素,并且编写函数时会再次找到该元素。
是什么原因造成的?或者Pytest在后台进行某种元素缓存