我读过示例规范和几篇 BDD 文章,它们都说要避免功能描述和场景中的特定表单字段之类的细节。但是,如果示例中没有说明我们需要哪些表单字段以及哪些验证是合适的,那么它在哪里呢?
我正在考虑将所有表单字段放入场景中,并为每个验证设置一个场景。看起来开销很大;有没有更好的办法?
编辑:例如,采用以下内容。
Feature: Add new product
In order to sell a new product on our website
As an internal user
I want to add the product to our catalog
Scenario: Successful addition
Given I am logged in
When I try to add a new product
And I provide "Widget" as the name
And I provide 1 lb. as the weight
And I provide 1 inch as the height
And I provide 2 inches as the width
And …
Run Code Online (Sandbox Code Playgroud) 我使用 Cucumber 与 ruby 和 capybara API 进行一些自动化测试。有一种情况,我需要模拟在其中一个文本框中输入内容以验证实时更改的值。我之前使用过“set(value)”。 “fill_in”对我不起作用,因为水豚无法找到我的文本框的 ID/名称。是否有任何方法可以模拟键入,然后将值设置为文本框,而不是设置值,因为这里的要求是验证实时更改。
提前致谢。
我们正在为我们的应用程序创建 Gherkin 功能文件,以创建可执行规范。目前我们的文件如下所示:
Given product <type> is found
When the product is clicked
Then detailed information on the product appears
And the field text has a value
And the field price has a value
And the field buy is available
Run Code Online (Sandbox Code Playgroud)
and
我们想知道验证字段在屏幕上是否可见的整个关键字列表是否是正确的方法,或者我们是否应该将其缩短为“验证输入”之类的内容。
我有一个包含超过 66 个场景的 Cucumber 功能文件!功能文件的标题确实代表了场景的全部内容。
但 66(200 步)感觉是一个相当大的数字。这是否表明我的专题标题过于宽泛?
单个功能文件中的最大场景数是多少(从最佳实践的角度来看)?
提前致谢 :)
我在浏览器堆栈上测试我的案例时遇到问题。我面临的问题重现不一致。
为了让我的代码等待元素加载,我使用如下:
gift_no_btn1 = Capybara.find('giftingNoButton')
gift_no_btn1.click
Run Code Online (Sandbox Code Playgroud)
这里的问题是屏幕卡在另一个模块中,我的预期元素未加载,因此我的脚本失败。我读到在 Capybara 2.0 中 find() 方法被替换为 wait_untill 方法。
我有一个 gradle + Serenity + RestAssured 自动检查套件设置,我通常通过 shell 会话中的 gradle 命令运行,但有时我需要使用 IntelliJ 运行单个场景。
当我在 IntelliJ 上运行 Scenarios 时,我通常会收到很多这样的警告:
8312 [main] WARN cucumber.runtime.SerenityBackend - It looks like you are
running a feature using @RunWith(Cucumber.class)
instead of @RunWith(CucumberWithSerenity.class).
Are you sure this is what you meant to do?
Run Code Online (Sandbox Code Playgroud)
我想知道在何处以及如何在 IntelliJ 中配置运行/调试配置,以便运行检查并CucumberWithSerenity.class
修复警告。
我正在使用以下依赖项:
serenity-rest-assured:1.9.31
serenity-core:1.9.31
serenity-cucumber:1.9.12
Run Code Online (Sandbox Code Playgroud)
IntelliJ版本2018.1.5(社区版)
运行 Runner 类时,钩子的 @Before 和 @After 方法没有运行。
我正在使用依赖项:黄瓜-java 4.3.0 黄瓜-jvm 4.3.0
除了钩子之外,stepdef 文件中的所有步骤都运行良好。最新的黄瓜版本有问题吗?
public class Hooks {
@Before
public void beforeHooks() {
System.out.println("Run Before Scenario");
}
@After
public void afterHooks() {
System.out.println("Run After Scenario");
}
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试创建我的第一个 Cucumber 测试。在 Java Eclipse 中,我创建了一个包含以下内容的“功能文件”:
Feature: Login functionality DemoQA.com
Scenario: Verify if user is able to login to the DemoQA website
Given A user is on DemoQA.com
When User clicks MyAccount link
Then User is taken to Login Page
When User enters valid username and password
Then User is able to login
Run Code Online (Sandbox Code Playgroud)
我还创建了以下 testrunner 文件:
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/Features/",
glue = {"Tests"}
)
public class CucumberRunner {
}
Run Code Online (Sandbox Code Playgroud)
我还创建了我的 Stepdefinitions:
公共类 LoginStepDefinitions {
@Given("A user is on DemoQA.com") …
Run Code Online (Sandbox Code Playgroud) 在 下@CucumberOptions
,同时使用标签选项仅执行一些测试集,例如:烟雾测试。我已经编写了如下所述的标签代码:
@CucumberOptions(
tags = {"@SmokeTest"} // <<< Type mismatch: cannot convert from String[] to String
)
Run Code Online (Sandbox Code Playgroud)
但我收到类型不匹配错误。