I'm trying to select month, year and date from calendar date-picker. I'm writing my script using pom & page factory approach. I'm not able to pass the date I selected to the variable named TodayDate. Can someone please tell me why TodayDate = null.
JSClickWithWaitTime(sf.StartDateEST_SF, 60); // clicked on date field waitForElementBeVisible(sf.CalendarDateReceived_SF, 100); //JSClickWithWaitTime(sf.StartDateEST_SF, 60); Assert.assertTrue(sf.CalendarDateReceived_SF.isDisplayed()); // asserted that the calendar is displayed. selectValueFromDD(sf.MonthFromDateReceived_SF, "Mar"); selectValueFromDD(sf.YearFromDateReceived_SF, "2020"); JSClickWithWaitTime(sf.DayFromStartDate_SF, 3000); click(sf.StartDateEST_SF); String TodayDate = sf.DayFromStartDate_SF.getAttribute("03/17/2020"); // Save the date into the variable TodayDate System.out.println("Today's date is = " +TodayDate);
The console will display the below result: Element is Clicked by the JS. Mar is selected 2020 is selected Element is Clicked by the JS. Today's date is = null