-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar
187 lines (120 loc) · 5.09 KB
/
calendar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package com.check.flights;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;
import org.testng.Reporter;
public class Testexpedia {
//public WebDriver driver;
// Initialize browser
@Test
public void openexpedia() throws InterruptedException {
// Reporter.log("=====Browser Session Started=====", true);
Reporter.log("=====Browser Session Started=====", true);
Map<String, Object> prefs = new HashMap<String, Object>();
// Set the notification setting it will override the default setting
prefs.put("profile.default_content_setting_values.notifications", 2);
// Create object of ChromeOption class
ChromeOptions options = new ChromeOptions();
// Set the experimental option
options.setExperimentalOption("prefs", prefs);
// pass the options object in Chrome driver
System.setProperty("webdriver.chrome.driver", "C:\\chrome\\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
//WebDriver driver=new ChromeDriver();
String baseurl = " https://www.expedia.co.in/";
Thread.sleep(5000);
driver.get(baseurl);
driver.manage().window().maximize();
Thread.sleep(5000);
WebElement flights= driver.findElement(By.xpath("//span[@class='tab-label' and contains (text(),'Flights')]"));
System.out.println("Check if flight radio button is present " + flights.isSelected());
flights.click();
Thread.sleep(5000);
//System.out.println("Check if flight radio button is present " + flights.isSelected());
WebElement RoundTrip=driver.findElement(By.xpath("//label[@id='flight-type-roundtrip-label']"));
//System.out.println("Check if flight radio button is present " + RoundTrip.isSelected());
RoundTrip.click();
//System.out.println("Check if flight radio button is present " + RoundTrip.isSelected());
Thread.sleep(5000);
Reporter.log("=====select the origin =====", true);
//String partialText ="che";
String expectedStation ="Chennai, India (MAA-Chennai Intl.)";
WebElement OriginStation=driver.findElement(By.id("flight-origin"));
OriginStation.sendKeys(expectedStation);
/*
WebElement SuggestionBox = driver.findElement(By.xpath("//UL[@id='typeaheadDataPlain']"));
List<WebElement> Suggestions =SuggestionBox.findElements(By.tagName("li"));
Thread.sleep(3000);
int size= Suggestions.size();
for (int i=0;i<size;i++)
{
System.out.println("the suggestions in the box based on the partial text "+ Suggestions.get(i).getText());
}
for (WebElement expectedResult:Suggestions)
{
if(expectedResult.getText().equals(expectedStation))
{
System.out.println("the origin is " + expectedStation);
expectedResult.click();
}
}*/
WebElement DestStation=driver.findElement(By.id("flight-destination"));
DestStation.sendKeys("DEL");
Reporter.log("=====click on the dates=====", true);
WebElement StartingDate=driver.findElement(By.id("flight-departing"));
StartingDate.click();
WebElement startingMonth =driver.findElement(By.xpath("(//DIV[@class='datepicker-cal-month'])[1]"));
List<WebElement> validStartdates = startingMonth.findElements(By.tagName("button"));
for (WebElement date:validStartdates)
{
if(date.getText().equals("15"))
{
date.click();
break;
}
}
Thread.sleep(2000);
//driver.findElement(By.xpath("(//BUTTON[@type='button'][text()='29'][text()='29'])[1]")).click();
WebElement ReturningDate=driver.findElement(By.id("flight-returning"));
ReturningDate.click();
WebElement returningMonth =driver.findElement(By.xpath("(//DIV[@class='datepicker-cal-month'])[2]"));
List<WebElement> returnValidDate = returningMonth.findElements(By.tagName("button"));
for(WebElement Journeydate:returnValidDate)
{
if(Journeydate.getText().equals("1"))
{
System.out.println("your Journey date is 1");
Journeydate.click();
break;
}
}
Thread.sleep(2000);
Select selectchildnumber= new Select(driver.findElement(By.id("flight-children")));
selectchildnumber.selectByVisibleText("1");
Thread.sleep(2000);
System.out.println("the child specifics are displayed : "+ driver.findElement(By.id("flight-age-select-1")).isDisplayed());
Select selectAgeForChild = new Select(driver.findElement(By.id("flight-age-select-1")));
selectAgeForChild.selectByIndex(3);
//add a hotel
/*WebElement SelectHotel = driver.findElement(By.id("flight-add-hotel-checkbox"));
SelectHotel.click();
*/
//click search
WebElement Search = driver.findElement(By.id("search-button"));
Search.click();
Thread.sleep(2000);
System.out.println("your search results are ");
driver.quit();
} }