-1

I am trying to find a common attribute in webpage calendar-dates like spicejet etc, to store. can anyone help me.

This is my code:

int count=driver.findElements(By.cssSelector("td[data-handler='selectDay']")).size();

I thought the css I have taken is was common but it didn't work

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Prashant
  • 1
  • 1
  • 1
    Please post the HTML of the date picker. The code you posted doesn't come close to picking dates. It just counts the number of elements that match the CSS selector. What have you tried so far? Is this it? – Greg Burghardt Jan 08 '20 at 13:50

1 Answers1

0

You were close. To collect and count all the webpage calendar-dates you you have to induce WebDriverWait for the visibilityOfAllElementsLocatedBy() and you can use either of the following Locator Strategies:

  • cssSelector:

    int count = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("td[data-handler='selectDay']"))).size();
    
  • xpath:

    int count = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//td[@data-handler='selectDay']"))).size();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352