selenium - 使用相同的浏览器实例如何运行测试套件
问题描述
我有一个测试套件(4 个课程),所有课程都有共同的登录名。当我运行测试套件时,仅第一类具有登录功能并评论其余 3 个类的登录代码(重定向 url ),它只运行第一类,其余 3 个类都失败了!
<classes>
<class name="testcases.TestClass1"></class>
<class name="testcases.TestClass2"></class>
<class name="testcases.TestClass3"></class>
<class name="testcases.TestClass4"></class>
</classes>
请帮忙
解决方案
You can try using before suite annotation available in TestNG.
@BeforeSuite: The annotated method will be run before all tests in this suite have run.
Create the driver instance as part of before suite and access it across.
Refer to TestNG documentation for more information on the annotation.
推荐阅读
- ios - 如何使用 API 中的数据搜索 tableview?
- c# - 检查数据是否存在后如何从数据库中获取数据
- node.js - 通过 npm 在 windows 中升级到最新的节点版本
- python - df.apply(ValueError:无法设置没有定义索引的框架和无法转换为系列的值
- oracle - 如何识别正在访问 Oracle 中我自己的数据库中的表的数据库
- android - 取消删除和基于 SQL 的应用程序
- ruby-on-rails - “bundle install --deployment”和“bundle install --path vendor/bundle”之间的区别?
- css - 将导航选项卡添加到 Tailwind CSS 导航栏
- python - 按下 Enter 后,如何在 If/Else 语句中使用 Text 小部件中的最后一个用户输入?
- jquery - 单击图像时如何更改缩放图标?