cucumber-java

How to Iterate Datatable with type List<Class> in Cucumber

China☆狼群 提交于 2019-12-24 18:19:30
问题 I have below feature file with Given annotation Given user have below credentials |user |password | |cucumber1 |cucumber | |cucumber2 |cucumber | And i'm created below datamodel public Class DataModel{ public string user; public String password; } Trying to fetch data into the cucumber stepdefinition as below Public Class stepdefinition { @Given("^user have below credentials$") Public void user_have_below_credintials(List<DataModel> dm){ //Iterator or foreach is required to fetch row,column

How to read csv file based on scenario outline

北城余情 提交于 2019-12-24 12:27:41
问题 I am using cucumber and trying to read row from my csv file based on scenario name. Feature file : Scenario Outline: Verify content of my probblem1 Scenario, Title1, Title2, Title3, Title4, Title5 Verify content of my probblem1, Text1, Text2, Text3, Text4, Text5, Verify content of my probblem2, Text1, Text2, Text3, Text4, Text5, 回答1: The short answer is that reading CSV files from a Scenario written in Gherkin is not supported. If you want to read data from an Excel file, you have to

How to have multiple Cucumber step definitions in the same project for testing product variants

二次信任 提交于 2019-12-24 08:25:39
问题 I'm working on an automation project for a mobile app in ios and android. I'm using Java-Appium-Cucumber framework for writing tests. Below shows my project structure src android features step_definitions ios features step_definitions I need a step "User logins to the app" for both android and ios. But the implementation in android and ios are different. So I wrote two step definitions in android > step_definitions and in ios > step_definitions. But this results in duplicate step definition

Cucumber Stopping Execution after Time in Steps

青春壹個敷衍的年華 提交于 2019-12-24 04:56:10
问题 One of my tests waits until an event happens in the Then step. If the test works fine there is no issue but if the test is failing (i.e. no event is triggered) then it just hangs. How can I set a timeout in Cucumber ? I know JUnit has a timeout parameter you can use in the @Test annotation, is there something similar for Cucumber ? 回答1: Cucumber has followed the JUnit pattern and offers a timeout parameter in its steps annotations. This takes a long value specifying the number of milliseconds

Cucumber `--tags` options from command line?

我是研究僧i 提交于 2019-12-23 11:46:10
问题 What i would like to do is to pass cucumber options from command line to execute scenarios with tag name @extecuteThese but also i wanted to exclude scenarios that are with tag name @WIP so what am i doing so far is -Dcucumber.options='--tags @executeThese --tags ~@WIP' But unfortunately, it's not considering ~@WIP tag option Any help, much appreciated!! 回答1: Lets pretend this is your feature: Feature ABC @executeThese Scenario: abc1 @WIP @executeThese Scenario: abc2 What you are currently

Karate 0.9.1 is not generating cucumber.json which is used for cucumber reports

牧云@^-^@ 提交于 2019-12-23 04:19:25
问题 When using Karate 0.6.1 with cucumber. It is generating test result outputs to cucumber.json file in the path specified in the code. It is then used for generating the cucumber reports using Masterthought. @RunWith(Karate.class) @CucumberOptions(monochrome = true, features = "SampleFeature.feature", plugin = {"pretty", "html:target/site/cucumber-pretty", "json:target/cucumber-html-reports/cucumber.json" }) But when we migrated to Karate 0.9.1 to read inputs from csv file. Now, it is failing

Reusable/Generic Examples table in Cucumber

岁酱吖の 提交于 2019-12-22 11:23:58
问题 Is it possible for multiple scenarios to use the same Examples table? So instead of having something like the following: Scenario Outline: First Scenario Given I am viewing "<url>" Then I assert that the current URL "<url>" Examples: | url | | https://google.com | | https://twitter.com| Scenario Outline: Second Scenario Given I am viewing "<url>" with route "</contactus>" Then I assert that "<url>" contains "contactus" Examples: | url | | https://google.com | | https://twitter.com| I can do

Cucumber Java screenshots

我的梦境 提交于 2019-12-21 21:17:32
问题 Is there a way to take screenshots in between steps in Java Cucumber ? I have the following scenario : @Scenario_1 Given I log into url And I see the home page is displayed in English //Take screenshot And I click on 'Edit Profile' And I see the language set to 'English' When I change the language to Chinese //Take screenshot And I navigate to home page Then everything is displayed in Chinese //Take screenshot I want to take screenshots for certain steps of the scenario. I am currently taking

How to run cucumber feature file from java code not from JUnit Runner

不羁岁月 提交于 2019-12-18 06:51:41
问题 I want to run cucumber feature file from java code. currently we are running form JUnit Runner package com.compareglobalgroup.testscript; import cucumber.api.CucumberOptions; import cucumber.api.testng.AbstractTestNGCucumberTests; @CucumberOptions(features = { "src/test/resources/feature/BB" }, glue = { "com.compareglobalgroup.stepdefs.BB", "com.compareglobalgroup.cucumber.hooks" }, plugin = { "json:cucumberreport/json/cucumberreport.json" }, tags = { "" + "@Test" }) public class TestRunnerBB

What is the best way to pass information from one steps def class to another?

ぐ巨炮叔叔 提交于 2019-12-13 07:42:12
问题 Injecting one Steps def into another can rapidly lead to dependency bloat as the amount of re-use among steps defs grows. Furthermore it couples steps defs very tightly to each-other. There must be a better way. Any suggestions? Is passing information between steps defs an anti-pattern that should be avoided anyway? 回答1: If your question is about sharing state between different Step Definition classes, you can do this with Dependency Injection frameworks like Spring. Here's a blog that