Date selection in truclient protocol

Hi , 

I am working on truclient protocol scripting, where the script needs to select a date one day after the automatic popped-up date.. how to achieve it.

By default , application pops- up a particular date.( in the screenshot the date is 10/28/2024). I need to select one day after it. i.e., 10/29/2024 through the date picker

Whatever date it pop-ups, i need to select one day after it.. how to achieve it through truclient scripting. any leads would be appreciated.

  • Suggested Answer

    0  

    Hi Kani, 

    Please try add a testObject step with "Evaluate javascript" Action.

    put the following code to set the next day based on the current day.

    const dateInput = object
    const currentDate = new Date(dateInput.value);

    // Add one day
    currentDate.setDate(currentDate.getDate() + 1);

    // Format the date to YYYY-MM-DD
    const nextDay = currentDate.toISOString().split('T')[0];

    // Set the input value to the next day
    dateInput.value = nextDay;

    Regards,

    Ben

  • 0 in reply to   

    Hi Ben, 

    small correction here.,, i want to select next day based on the date popping up in the application( this date varies based on input date) so whatever date comes up, i need to select next day. not next day from current date. any changes has to be done

  • 0   in reply to 

    Hi Kani,

    "const dateInput = object"

    In the above code, the dateInput is the popped-up date element on the webpage, if the testObject of the current Step is the popped-up date element.

    Regards,
    Ben