-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflyaway.java
More file actions
340 lines (207 loc) · 8.79 KB
/
flyaway.java
File metadata and controls
340 lines (207 loc) · 8.79 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
package com.test;
import java.util.Iterator;
import java.util.List;
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.support.ui.Select;
//import com.test.JDBC.JDBC;
public class flyaway{
public String[] exp_details() {
flyawayjdbc flyawayjdbc = new flyawayjdbc();
// TODO Auto-generated method stub
String str[]=new String[5];
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://localhost:8080/flyaway/");
driver.findElement(By.linkText("Login/Signup")).click();
driver.findElement(By.xpath("//input[@name=\"email_id\"]")).sendKeys("kp@pubg.com");
driver.findElement(By.xpath("//input[@name=\"pwd\"]")).sendKeys("kp");
driver.findElement(By.xpath("//button")).click();
driver.findElement(By.linkText("Logout")).click();
String exp_email="kp@pubg.com";
String exp_pwd ="pubg";
String exp_name = "kp";
String exp_adress ="kaverrapa layout";
String exp_city ="banglore";
str[0]=exp_name;
str[1]=exp_city;
str[2]=exp_email;
str[3]=exp_adress;
str[4]=exp_pwd;
driver.findElement(By.linkText("Login/Signup")).click();
driver.findElement(By.linkText("Not a member? Signup")).click();
driver.findElement(By.xpath("//input[@name=\"email_id\"]")).sendKeys(exp_email);
driver.findElement(By.xpath("//input[@name=\"pwd\"]")).sendKeys(exp_pwd);
driver.findElement(By.xpath("//input[@name=\"pwd2\"]")).sendKeys(exp_pwd);
driver.findElement(By.xpath("//input[@name=\"name\"]")).sendKeys(exp_name);
driver.findElement(By.xpath("//input[@name=\"address\"]")).sendKeys(exp_adress);
driver.findElement(By.xpath("//input[@name=\"city\"]")).sendKeys(exp_city);
driver.findElement(By.xpath("//button")).click();
// driver.close();
String[] jdbc = flyawayjdbc.Jdbc();
for (String string : jdbc) {
System.out.println(string);
}
return str;
}
public int Login_SearchFlight_Validate() {
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://localhost:8080/flyAway/");
driver.findElement(By.linkText("Login/Signup")).click();
driver.findElement(By.xpath("//input[@name=\"email_id\"]")).sendKeys("kp@pubg.com");
driver.findElement(By.xpath("//input[@name=\"pwd\"]")).sendKeys("kp");
driver.findElement(By.xpath("//button")).click();
driver.findElement(By.linkText("Home")).click();
String str[]=new String[18];
int i=0;
WebElement table = driver.findElement(By.xpath("//table[@border='1']"));
List<WebElement> list = table.findElements(By.tagName("tr"));
System.out.println("printing No of Rows"+list.size());
for (WebElement ls : list) {
List<WebElement> clist = ls.findElements(By.tagName("td"));
for (WebElement wl : clist) {
str[i]=wl.getText();
i++;
// System.out.println(wl.getText()+",");
}
}
System.out.println(" \n\n");
System.out.println("Printing the table from home page");
for (int j = 0; j < str.length; j++) {
System.out.println(str[j]);
}
System.out.println("\n\n");
driver.findElement(By.xpath("//select[@name='source']")).click();
driver.findElement(By.xpath("//select[@name='source']//option[@value='1']")).click();
String text = driver.findElement(By.xpath("//select[@name='source']//option[@value='1']")).getText();
System.out.println("Printing From location inside dropdown");
System.out.println(text);
System.out.println("\n\n");
driver.findElement(By.xpath("//select[@name='destination']")).click();
driver.findElement(By.xpath("//select[@name='destination']//option[@value='11']")).click();
String text2 = driver.findElement(By.xpath("//select[@name='destination']//option[@value='11']")).getText();
System.out.println("Printing TO location inside dropdown");
System.out.println(text2);
driver.findElement(By.xpath("//button")).click();
String str1[]=new String[12];
int k=0;
WebElement table1 = driver.findElement(By.xpath("//table[@border='1']"));
List<WebElement> list1 = table1.findElements(By.tagName("tr"));
System.out.println("printing No of Rows"+list1.size());
for (WebElement ls : list1) {
List<WebElement> clist = ls.findElements(By.tagName("td"));
for (WebElement wl : clist) {
str1[k]=wl.getText();
k++;
System.out.println(wl.getText()+",");
}
}
System.out.println("\n\n");
for (int j = 0; j < str1.length; j++) {
System.out.println(str1[j]);
}
String from_table=str1[6];
String to_table = str1[7];
System.out.println("printing from and to from table after submit to verify");
System.out.println(from_table+"\n"+to_table);
System.out.println("\n\n");
int ret =0;
if ((text.contains(from_table))){
ret++;
System.out.println("Source Location Validated");
} else {
System.out.println("Source Location did not validation");
}
if ((text2.contains(to_table))) {
ret++;
System.out.println("Destination Location Validated");
} else {
System.out.println("Destination Location not Validated");
}
// return ret;
// Not able to perform select element from dropdown menu
// WebElement WE_TO = driver.findElement(By.xpath("//select[@name='destination']"));
// Select select2 = new Select(WE_TO);
// select2.selectByVisibleText("Hyderabad");
// driver.findElement(By.xpath("//select[@name='source']")).click();
// WebElement WE_From = driver.findElement(By.xpath("//select[@name='source']"));
// System.out.println(WE_From.getAttribute("type"));
// Select select = new Select(WE_From);
// select.selectByValue("1");
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
driver.findElement(By.xpath("//button")).click();
// driver.close();
return ret;
}
public int Book_Show_and_Validate() {
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://localhost:8080/flyAway/");
driver.findElement(By.linkText("Login/Signup")).click();
driver.findElement(By.xpath("//input[@name=\"email_id\"]")).sendKeys("kp@pubg.com");
driver.findElement(By.xpath("//input[@name=\"pwd\"]")).sendKeys("kp");
driver.findElement(By.xpath("//button")).click();
driver.findElement(By.linkText("Home")).click();
driver.findElement(By.xpath("//select[@name='source']")).click();
driver.findElement(By.xpath("//select[@name='source']//option[@value='1']")).click();
String text = driver.findElement(By.xpath("//select[@name='source']//option[@value='1']")).getText();
System.out.println("Printing From location inside dropdown");
System.out.println(text);
System.out.println("\n\n");
driver.findElement(By.xpath("//select[@name='destination']")).click();
driver.findElement(By.xpath("//select[@name='destination']//option[@value='11']")).click();
String text2 = driver.findElement(By.xpath("//select[@name='destination']//option[@value='11']")).getText();
System.out.println("Printing TO location inside dropdown");
System.out.println(text2);
driver.findElement(By.xpath("//button")).click();
driver.findElement(By.linkText("Book Flight")).click();
driver.findElement(By.linkText("Click to complete booking")).click();
driver.findElement(By.linkText("See Your Bookings")).click();
WebElement table2 = driver.findElement(By.xpath("//table[@border='1']"));
List<WebElement> list2 = table2.findElements(By.tagName("tr"));
System.out.println("printing No of Rows"+list2.size());
// String str1[]=new String[12];
String str3[] = new String[list2.size()*5];
int l=0;
for (WebElement ls : list2) {
List<WebElement> clist = ls.findElements(By.tagName("td"));
for (WebElement wl : clist) {
System.out.println(wl.getText()+",");
str3[l]=wl.getText();
l++;
}
}
System.out.println("\n\n");
for (int j = 0; j < str3.length; j++) {
System.out.println(str3[j]);
}
System.out.println("\n\n");
String show_Source_AB=str3[6];
String show_Destination_AB = str3[7];
System.out.println("\n\n");
System.out.println(show_Source_AB+"\n"+show_Destination_AB+"\n\n");
int ret =0;
if (text.contains(show_Source_AB)) {
ret++;
System.out.println("Validation of Source after booking");
} else {
System.out.println("Validation failed Of source after booking");
}
if (text2.contains(show_Destination_AB)) {
ret++;
System.out.println("Validation of Destination after booking");
} else {
System.out.println("Validation Failed for destination after booking");
}
System.out.println("\n\n");
return ret;
}
}