Question

Question may sound novice. But here i am everytime i try writing iphone5 in my cucumber feature file it parameterises the 5. I dont want this to happen and want it to just treat iphone5 as a string.

The line in my feature file causing this is: Then upload iPhone5 image "xxxx.png"

which then gets following step definition:

@And("^then upload iPhone(\\d+) image \"([^\"]*)\"$")
public void then_upload_iPhone_image(int arg1, String arg2) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}
Was it helpful?

Solution

Just remove regex for the digit and remove the parameter from the method.

@Given("^I upload to iphone5$")
public void I_upload_to_iphone() throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}

in your case

@And("^then upload iPhone5 image \"([^\"]*)\"$")
public void then_upload_iPhone_image(String arg2) throws Throwable {
    // Express the Regexp above with the code you wish you had
    throw new PendingException();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top