【发布时间】:2018-08-28 12:35:08
【问题描述】:
我们使用 Selenium WebDriver 和 Cucumber 进行验收测试。我们有一组要测试的功能,每个功能都有多个场景,下面是一个示例:
Scenario Outline: Unsuccessful login with W3ID credentials
Given I navigate to the Bluecost Spreadsheet Upload Web url and receive a login screen
When I login using invalid credentials: "<user_id>" and "<user_pwd>"
Then the W3ID will reject my credentials, produce an error message and I will not proceed to BCSUW
Examples:
| user_id | user_pwd |
| baduserid | badpass |
我想用我们需要支持的每种浏览器测试这些场景中的每一个:FireFox、Edge 和 Chrome。如何为这 3 种浏览器中的每一种运行这些功能和场景?
【问题讨论】:
-
我是否必须使用我在每个场景实例上提供的“browser_type”变量来编写每个场景?还是有别的办法?
-
您应该能够将“browser_type”作为变量传递给实例化驱动程序并运行相同场景的方法。 if (browser_type.equals("firefox")) { //为 firefox 实例化驱动程序} 和类似的其他浏览器。
-
是的,所以这意味着我必须在“示例”部分中为每种浏览器类型重复相同的场景。希望有另一种方式。
-
对于 Selenium Webdriver,您不必拥有功能文件,但是对于像黄瓜这样的 BDD,您可以在此处查看类似问题 stackoverflow.com/questions/43446922/…
标签: selenium-webdriver cucumber-junit