I am trying to automate the below assignment. I am stuck at a place where my function call is'nt working. I am using the Ecipse Oxygen 2 & the updated Firefox version 58.0.2.
//GetDatesJava class is in the package Demo
package demo;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class GetDatesJava {
Date date = new Date();
public String getSourceDate() throws ParseException
{
// Create object of SimpleDateFormat class and decide the format
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy ");
//get current date time with Date()
//Date date = new Date();
DateFormat df = new SimpleDateFormat("yyyyMMdd");
String srcdate = df.format(date);
System.out.println("Source Date string in right format:" + srcdate);
return srcdate;
}
public String getDestinationDate() throws ParseException
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, 14); // add 14 days
date = cal.getTime();
DateFormat df2 = new SimpleDateFormat("yyyyMMdd");
String destdate = df2.format(date);
System.out.println("Destination Date string in right format:" + destdate);
return destdate;
}
}
package GoIbibo;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import demo.GetDatesJava;
public class FlightBooking {
public static void main(String[] args) throws InterruptedException {
//TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver","C:\\Users\\suhas.subbarao\\Downloads\\Applications\\Eclipse Package\\geckodriver.exe");
WebDriver browser=new FirefoxDriver();
System.setProperty("webdriver.chrome.driver", "C:\\Selenium3\\chromedriver.exe");
browser.manage().window().maximize();
//Locate & Input the From City
WebElement RTrip=browser.findElement(By.xpath("//input[@id=('gi_roundtrip_label')]"));
RTrip.click();
//Locate & Input From City
WebElement From_City = browser.findElement(By.id("gosuggest_inputSrc"));
From_City.sendKeys("Bangalore (BLR)");
From_City.sendKeys(Keys.RETURN);
Thread.sleep(4000);
//Locate & Input the To City
WebElement To_City = browser.findElement(By.id("gosuggest_inputDest"));
To_City.sendKeys("Delhi (DEL)");
To_City.sendKeys(Keys.RETURN);
Thread.sleep(4000);
//Get the Depart & Return Date from GetDateinJava
WebElement Dep=browser.findElement(By.xpath("//i[@class=('icon-calendar1 ico22 widgetCalIcon ')]"));
Dep.click();
FlightBooking x = new FlightBooking();
String ddatee = x.getSourceDate();
WebElement DepDate=browser.findElement(By.xpath("//spanid[@id=('price_'+dday)]"));
//Locate & Enter the Depart Date
//Locate & Enter the Return Date
//Click on Get Set Go
//
}
}
I am getting an error "The method getSourceDate() is undefined for the type FlightBooking"
Quick help is appreciated.