I am trying to pick two days after the current day of month. In my StepImplementation class, i wrote a function like this but it gives me an error:
@Step("pick two days after current day") public void getCurrentDayOfMonth(String day) throws InterruptedException { Calendar cal = Calendar.getInstance(); int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); int dayToPick = dayOfMonth + 2; day = String.valueOf(dayToPick); appiumDriver.findElement(By.xpath("//*[@text='" + day + "']")).click(); System.out.println("Element is clicked."); Thread.sleep(2000); }
For my String day
parameter, it shows me this error: Parameter count mismatch(found 1 expected 0) with step annotation : ‘pick two days after current day’
Basically, i am trying to pick a date for a flight from datepicker. I have to pick two days after the current day of month but i got a little bit confused.
Thanks for your help.
Advertisement
Answer
I wrote another method and works like a charm now:
@Step("read text value of the element with <id>") public void readTextValue(String id) throws InterruptedException { String currentDate = appiumDriver.findElement(By.id(id)).getText(); System.out.println("Element has been read."); int dayToPick = Integer.parseInt(currentDate) + 2; String dayToPickAsText = String.valueOf(dayToPick); appiumDriver.findElement(By.xpath("//*[@text='" + dayToPickAsText + "']")).click(); Thread.sleep(2000); }