Automation - Goibibo script - Errors in Eclipse Oxygen 2

91 views
Skip to first unread message

Suhas Subbarao

unread,
Feb 25, 2018, 3:33:04 AM2/25/18
to Selenium Users
Hi,

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.

Assignment:

Karan’s wife Sandhya is currently on a business trip in Delhi. Their wedding anniversary is two weeks from now. So Kiran’s planning to surprise his wife by wishing her in person.

 

  1. Their anniversary is two weeks from today
  2. He’s also planning to take their 10 year old daughter as part of the surprise.
  3. They live in Bangalore.
  4. He’s looking for the cheapest, non-stop and first flight out of Bangalore.
  5. GoIbibo guarantees the cheapest flight tickets everyday from 7PM to 8PM.
  6. They’ll return the next day on the cheapest, non-stop and last flight out of Delhi.
  7. Since RBI requires OTP for online transactions, you can take him till the payment gateway and he’ll take it from there.



My code so far is as below:


//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;
}
}




//FlightBooking.Java is in the package goiBibo

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 stuck at a point where the function call is not happening:

FlightBooking x = new FlightBooking();
String ddatee = x.getSourceDate();

I am getting an error "The method getSourceDate() is undefined for the type FlightBooking"


Quick help is appreciated.






Maroof Ahmed Khan

unread,
Feb 25, 2018, 3:57:54 AM2/25/18
to seleniu...@googlegroups.com
make object of getdatesjava class and then invoke the method

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/d9734511-4a80-42a4-93a6-c58fcc06e63a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages