最佳答案
尝试使用以下 CSS 定位器来使用 aria-label
属性识别特定日期:
By.cssSelector("td[aria-label='Jan 1, 2018']") // (or any date that you want to identify)
如果您想要特定日期的 div
元素:
By.cssSelector("td[aria-label='Jan 1, 2018']>div") // (or any date that you want to identify)
您可以参数化日期值以使其更加通用:
public void selectDate(String date)
By.cssSelector("td[aria-label='" + date + "']") // using string concatenation. you can do Stirng.format method for better readability.
关于java - 如何在selenium java中识别 'mat-calendar-body-cell'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48392531/