Basically the UI code is written in Angular and I am automating using selenium java. I am facing difficulties in identifying the elements of a calendar. Below is the sample code. Plz let me know how to access the dates.
Asked
Active
Viewed 598 times
1
-
1Please give a screenshot of the UI of the calendar, and put HTML code in well formatted plain text, rather than screenshot. And what functionality you want do implement, like I want to input/read a date into/from calendar field – yong Jan 23 '18 at 02:04
-
Please read why a [**`screenshot of HTML or code or error is a bad idea`**](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Jan 23 '18 at 06:15
1 Answers
0
Try following CSS locator to identify a specific date using aria-label
attribute:
By.cssSelector("td[aria-label='Jan 1, 2018']") // (or any date that you want to identify)
If you want div
element of a specific date:
By.cssSelector("td[aria-label='Jan 1, 2018']>div") // (or any date that you want to identify)
You can parameterize the date value to make it more generic:
public void selectDate(String date)
By.cssSelector("td[aria-label='" + date + "']") // using string concatenation. you can do Stirng.format method for better readability.

Naveen Kumar R B
- 6,248
- 5
- 32
- 65