Module 26::BASICS OF CUCUMBER: Regular Expression | Selenium Forum
J
Jai Jagadeesha Posted on 26/05/2020

I am using [^\"]* regular expression.

@And("^I want to book from 10th Jan 2020 to 20th Jan 2020 $")
public void i_want_to_book_from_10th_jan_2020_to_20th_jan_2020() {
System.out.println("I want to book from 10th Jan 2020 to 20th Jan 2020");
}

Changed to (Make date as dynamic)

@And("^I want to book from ([^\"]*) to ([^\"]*) $")
public void i_want_to_book_from_10th_jan_2020_to_20th_jan_2020(String fromDate, String toDate) {
System.out.println("I want to book from 10th Jan 2020 to 20th Jan 2020");
}

Saved details. 

During TestRunner execution, execution failed and following information displayed on console.

I live inBangalore
I want to go on a holiday
we are30 adults

1 Scenarios ([33m1 undefined[0m)
8 Steps ([36m4 skipped[0m, [33m1 undefined[0m, [32m3 passed[0m)
0m0.421s


You can implement missing steps with the snippets below:

@Given("^I want to book from (\\d+)th Jan (\\d+) to (\\d+)th Jan (\\d+)$")
public void i_want_to_book_from_th_Jan_to_th_Jan(int arg1, int arg2, int arg3, int arg4) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}

Please let me know the solution for it

Thanks

 

 

 

 

 

 


J
Jai Jagadeesha Replied on 27/05/2020

Plz let me know solution for above query


J
Jai Jagadeesha Replied on 28/05/2020

Plz let me know solution for above query.

Shell i consider number with regular exp. \\d with int prameter.

Thanks


A
Ashish Thakur Replied on 28/05/2020

Yes you can use \\d for a digit with int


Related Posts