• tahseenat

Selecting Dates in Web Calendar


When you need to automate an airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit difficult to select a specific date on the Datepicker or calendar. In this blog, we will learn how to deal with Datepickers with selenium.

Approach to handle calendar in Selenium Webdriver


Steps:

  1. Click on calendar

  2. Get all td of tables using findElements method

  3. Using for loop get the text of all elements

  4. Using if-else condition we will check specific date

  5. If the date is matched then click and break the loop.


Code to handle calendar in Selenium Webdriver


package Blog;

import java.util.List;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class CalendarHandling {

public static void main(String[] args)

{

System.setProperty("webdriver.firefox.marionette","G:\\Selenium\\Firefox driver\\geckodriver.exe");

WebDriver driver=new FirefoxDriver();

driver.get("http://seleniumpractise.blogspot.in/2016/08/how-to-handle-calendar-in-selenium.html");

driver.findElement(By.id("datepicker")).click();

List<WebElement> allDates=driver.findElements(By.xpath("//table[@class='ui-datepicker-calendar']//td"));

for(WebElement ele:allDates)

{

String date=ele.getText();

if(date.equalsIgnoreCase("28"))

{

ele.click();

break;

}

}

}

}

Wizdom QA has created an end to end course curriculum for the SDET profile. Our students will receive in-depth knowledge of the latest QA tools, techniques and programming languages.

As a registered student, you will learn Selenium WebDriver, Appium for Mobile App automation, API automation, CI/CD integration and many more.

We have studied the market carefully and understood that there is a huge demand for good SDET profiles, however, finding the right candidate is quite hard because of the lack of right skills and experience among job seekers.

 

Therefore we are here with 11+ years of hands-on and training 800+ students to experience to create one-stop-shop course content for Software Development Engineering in Test (SDETs).

Address

Belgard Square West, Tallaght,

Dublin, Ireland

Phone & WhatsApp

+353 894740999

Email

info@wizdomqa.com

support@wizdomqa.com

Additional Links

Wizdom QA Trainings | All rights reserved | 2019-20 ©

  • Facebook Social Icon