我有以下用于Cucumber-jvm的步骤。如何转义步骤定义中的某些字符?
When user verifies if ABC widget exists
Then the 'The 7 Things $channel' label is displayed
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我需要将7和$作为常规字符串转义。
我可以在与黄瓜集成时运行testng脚本.我已按照http://automatictester.co.uk/2015/06/11/basic-cucumberjvm-selenium-webdriver-test-automation-framework/ link中定义的确切步骤进行操作.
现在我还有一个要求.你能解释一下如何从testng.xml的参数标签读取值.见下面的例子:
<test name="ascentis.LoginDemo.Firefox">
<parameter name="BrowserName" value="Firefox" />
<parameter name="Environment" value="local" />
<packages>
<package name="runnerFiles.*"/>
</packages>
</test>
Run Code Online (Sandbox Code Playgroud)
我将从parameters标签中读取BrowserName和Environment值.我已经尝试将@parameters用于黄瓜的@Before方法,但它没有成功并且给出了异常,即@Before钩子只接受一个类型场景的参数.你能解释一下如何从参数标签中读取值,以便在黄瓜的stepDefinations中访问.
testng cucumber cucumber-jvm selenium-webdriver cucumber-java
我想在黄瓜页上写一个数字。请让我知道我该怎么写这个。
场景大纲:输入无效的 URL
Given the context "Invalid URL" is open on "Market"
When user is on the error 404 page
Then page not found message is displayed
Run Code Online (Sandbox Code Playgroud)
但我观察到 404 被当作参数。
我目前在Java中使用硒,并且想要实现黄瓜来使测试脚本更具可读性。当前将参数传递给希望将Enum作为参数的java方法时遇到的问题。我还想知道,在迁移当前框架之前,是否有任何其他已知的黄瓜java局限性。
因为我是黄瓜的新手,如果有人知道黄瓜的详细信息,请给我一个链接。
我的一个测试会等到该步骤中发生事件Then。如果测试工作正常,则没有问题,但如果测试失败(即没有事件被触发),那么它就会挂起。
我怎样才能设置超时Cucumber?
我知道JUnit有一个可以在 中使用的超时参数@Test annotation,有类似的吗Cucumber?
我通过mvn命令行-Dcucumber.options运行测试以覆盖我的项目的选项:
mvn -f "pom.xml" -Dcucumber.options="--plugin json:report/cucumber.json,junit:target/junitreports.xml --tags @Login" test
Run Code Online (Sandbox Code Playgroud)
但是是显示错误:
Data provider mismatch
Method: runScenario([Parameter{index=0, type=cucumber.api.testng.PickleEventWrapper, declaredAnnotations=[]}, Parameter{index=1, type=cucumber.api.testng.CucumberFeatureWrapper, declaredAnnotations=[]}])
Arguments: [(cucumber.api.testng.CucumberExceptionWrapper)cucumber.api.testng.CucumberExceptionWrapper@a0bf272]
Run Code Online (Sandbox Code Playgroud) 尝试使用黄瓜/硒/java/intelliJ 运行场景,但在其中一个步骤中收到有关 DataTable 的错误。在我开始使用测试运行器并更改了一些东西之前,dataTable 工作正常并正确转换了步骤的参数,但我无法让它工作。
这是错误:
cucumber.runtime.CucumberException: Could not convert arguments for step [^I enter the following login details:$] defined at 'Steps.MaStepdefs.iEnterTheFollowingLoginDetails(DataTable) in file:/C:/Users/Kristian.Senior/Desktop/CukesReporting/target/test-classes/'.
It appears you did not register a data table type. The details are in the stacktrace below.
at cucumber.runner.PickleStepDefinitionMatch.registerTypeInConfiguration(PickleStepDefinitionMatch.java:59)
at cucumber.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:44)
at cucumber.runner.TestStep.executeStep(TestStep.java:63)
at cucumber.runner.TestStep.run(TestStep.java:49)
at cucumber.runner.PickleStepTestStep.run(PickleStepTestStep.java:43)
at cucumber.runner.TestCase.run(TestCase.java:45)
at cucumber.runner.Runner.runPickle(Runner.java:40)
at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:122)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:64)
at …Run Code Online (Sandbox Code Playgroud) Cucumber 无法识别 String 参数,我想将其用作货币。它只识别 int 值。(它找到步骤,因为其他步骤有效)
@When("I deposit {int} of {string}")
public void testDeposit(int value, String currency) throws ClientProtocolException, IOException {
Run Code Online (Sandbox Code Playgroud)
它显示以下错误消息:
There were undefined steps. You can implement missing steps with the snippets below:
@When("I deposit {int} of GBP")
public void i_deposit_of_GBP(Integer int1) {
// Write code here that turns the phrase above into concrete actions
throw new cucumber.api.PendingException();
}
@Then("My balance is {int} of GBP")
public void my_balance_is_of_GBP(Integer int1) {
// Write code here that turns the phrase …Run Code Online (Sandbox Code Playgroud) 所以我最近开始研究 Cucumber 并一直面临这个问题。
正如您所看到的,这是我的 Spring Boot 应用程序 (AcceptanceTests) 中的子模块,因此其中没有主要方法。
这是我的CucumberSpringContextConfiguration班级
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@CucumberContextConfiguration
public class CucumberSpringContextConfiguration {
}
Run Code Online (Sandbox Code Playgroud)
这是我的CucumberIntegrationTest班级
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src\test\resources\feature",
plugin = {"pretty", "html:target\\cucumber"},
glue = "com.#####.########.cucumberspringboot.cucumberglue"
)
public class CucumberIntegrationTest {}
Run Code Online (Sandbox Code Playgroud)
我尝试使用主类(src/main/java)运行此代码,代码编译成功。但由于这不是我的要求,我将其删除,现在我收到以下错误 -
SEVERE: Exception while executing pickle
java.util.concurrent.ExecutionException:
io.cucumber.core.backend.CucumberBackendException: Please annotate a
glue class with some context configuration.
For example:
@CucumberContextConfiguration
@SpringBootTest(classes = TestConfig.class)
public class CucumberSpringConfiguration { }
Or:
@CucumberContextConfiguration
@ContextConfiguration( ... )
public class CucumberSpringConfiguration { …Run Code Online (Sandbox Code Playgroud) 我正在使用来自 Karate API 框架的path关键字来连接字符串以形成一个 url。但是,我无法通过“?”。这是我在做什么:
Background:
* url 'https://api.cloud.abcde.com/animal/'
Scenario: Verify the get status
Given path 'herbivore?id=25'
When method get
Then status 200
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我看到“?” 作为 %3F 传递。我试图使用 \ 来逃避它,并尝试了其他一些答案,但没有成功。我需要使用 url 编码吗?任何指示或帮助将不胜感激。谢谢