How to Select first enable date in calendar in selenium java without hard coded any value and if enable date not available in current month then how we will move to next month and select first enable date.
accepting to select first enable date only
How to Select first enable date in calendar in selenium java without hard coded any value and if enable date not available in current month then how we will move to next month and select first enable date.
accepting to select first enable date only
You can try to follow these steps and modify as per your requirements.
If clicking value from current month
Step 1. Focus on it's date values since each date will have a different value.
Step 2. Use that value and call click() on it.
If selecting date from another month
Step 1: Find common class name for all the months and use findElements() to get all the month names in List<String> str.
Step 2: Run for loop on the str.length(), then in next step implement if() to compare your desired month vs actual month.
Step 3: When string matches, then you can select the date by this way:
Step a.1: Run for loop and get all the dates values in a string using common class name.
Step a.2: Again run if() to compare strings to check for desired date vs actual date.
Step a.3: When string matches, then call click() on date value.
Check if there is some HTML attribute inside the date which indicates that it's enabled (e.g. available='yes' or something similar). If yes, then get list of all available elements (e.g. using xpath) and select first one.
If there is no available date within current month, select another month and do the first point again.