【发布时间】:2019-11-08 11:29:20
【问题描述】:
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 in conftest.py 从某个 CSV 文件中读取的链接文本供应商列表
因此,本质上,它将加载页面并为网站一一打开所有链接 - https://www.coverfox.com/
第一个测试用例通过了链接两轮车保险,但对于第二个测试数据运行它失败了,在它试图移动到(move_to 函数)的点上给出过时元素引用的异常 再次保险链接。
我没有在任何地方存储元素,并且函数的编写方式可以再次找到该元素。
这是什么原因造成的?或者 Pytest 在后台做某种元素缓存
【问题讨论】:
-
能否分享一下例外情况?
标签: python-3.x selenium pytest ui-automation