import minium
@minium.ddt_class(testNameFormat="%(name)s_%(index)s")
class TestPageGetElement(minium.MiniTest):
@classmethod
def setUpClass(cls):
super(TestPageGetElement, cls).setUpClass()
cls.page = cls.app.navigate_to("/pages/index/index")
@minium.ddt_case(
# 多个用例
# 展开后为: 选择器, 预期是否存在
("image[mode='scaleToFill']", True),
(".testclass2", False),
)
def test_element_is_exists(self, args):
[selector, is_exists] = args
self.assertEqual(is_exists, self.page.element_is_exists(selector, max_timeout=5))
下图加入 setUpClass 运行会不成功
下图为去掉 setUpClass,则能运行成功
参考代码: