0% found this document useful (0 votes)
9 views

Code Calender

Uploaded by

SuprinAhluwalia
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Code Calender

Uploaded by

SuprinAhluwalia
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class calendar {

public static void main(String[] args) {


// TODO Auto-generated method stub

System.setProperty("webdriver.chrome.driver", "C://work//chromedriver.exe");
ChromeDriver driver=new ChromeDriver();
driver.get("https://www.path2usa.com/travel-companions");
//April 23
driver.findElementByXPath(".//*[@id='travel_date']").click();

while(!driver.findElement(By.cssSelector("[class='datepicker-days']
[class='datepicker-switch']")).getText().contains("May"))
{
driver.findElement(By.cssSelector("[class='datepicker-days']
th[class='next']")).click();
}

List<WebElement> dates= driver.findElements(By.className("day"));


//Grab common attribute//Put into list and iterate
int count=driver.findElements(By.className("day")).size();

for(int i=0;i<count;i++)
{
String text=driver.findElements(By.className("day")).get(i).getText();
if(text.equalsIgnoreCase("21"))
{
driver.findElements(By.className("day")).get(i).click();
break;
}

}
}

Fullscreen
Go to Previous lecture93. Solved example on calendar methods

You might also like