0

I have got a scenario outline

Scenario Outline:
  When I type "<text>" in the search bar

With examples

Examples:
  |text|
  |laptop|
  |camera|

And its Step Definition

@When("^I type \"([^\"]*)\" in the search bar$")
public void iTypeInTheSearchBar(String text){
    try {
        homepage.searchForItem(text);
    }
    catch (NullPointerException e){
        logger.debug("Exception",e);
    }
}

But when I run the test, in each iteration, instead of entering the parameters defined in examples (laptop,camera....), it literally keeps entering "text" in the search bar. I have also tried re-writing the scenario outline and examples as follows

Scenario Outline:
  When I type <text> in the search bar

Examples:
  |text|
  |"laptop"|
  |"camera"|

But still no luck. I have never faced this issue before, does anyone know what I am doing wrong? Following are the libraries I am using (JDK is 1.8)

dependencies {
compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
// https://mvnrepository.com/artifact/info.cukes/cucumber-java
compile group: 'info.cukes', name: 'cucumber-java8', version: '1.2.5'
}

I am calling the test through Junit class

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources",glue=  "StepDefinitions",plugin = "pretty")
ltcolumb
  • 73
  • 1
  • 7
  • Anyone? I am still looking for a solution to this. – ltcolumb Oct 10 '16 at 10:00
  • Can you try to find the element where you want to send this text as parameter and then using send keys, send that text in your step definition. something as below: driver.findElement(By.id("where u want to send the text")).sendKeys(text); – Priya P Nov 17 '16 at 06:39

1 Answers1

0

Try to use below, without quotes for the parameter. Scenario Outline: When I type in the search bar