Calender | Selenium Forum
M
Posted on 06/07/2016
Could you please check what was wrong .
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class date {

public static void main(String[] args) throws Exception {
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.makemytrip.com/");

String datetobeselected="29/7/2016";
SimpleDateFormat sf=new SimpleDateFormat("dd/MM/YYYY");
Date date=sf.parse(datetobeselected);
String day=new SimpleDateFormat("dd").format(date);
String month=new SimpleDateFormat("MMMM").format(date);
String year=new SimpleDateFormat("YYYY").format(date);
String monthyeartobeselected=month+" "+year;
System.out.println(monthyeartobeselected);

Date Currentdate=new Date();
System.out.println(Currentdate);
driver.findElement(By.xpath("//*[@id='start_date_sec']")).click();
String datedisplayed=driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div[1]/div/div")).getText();
System.out.println(datedisplayed);

if(datedisplayed.equalsIgnoreCase(monthyeartobeselected)){
System.out.println("date found");
}
else if(date.after(Currentdate)){
driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div[2]/div/a/span")).click();
}
else if(date.before(Currentdate)){
driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div[1]/div/a")).click();
}



}


}

M
Replied on 06/07/2016

watch he latest page object model with page factory framework date picker is explained in it.


M
Replied on 07/07/2016

Hello jyosh.maddy@gmail.com

I am also stuck here. Well we can work together. My number is this..whatsup me [color=#FF0000:2eixfdpi] (deleted)[/color:2eixfdpi]

looking forward to receiving your message.
Thanks


M
Replied on 07/07/2016

you should not post your number here it is public forum you will start getting spam.

i am removing your number. send him the details in a private message.


M
Replied on 07/07/2016

I am sorry. I was not aware of it .

THANKS heaps