-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRedbus.java
More file actions
72 lines (67 loc) · 2.94 KB
/
Redbus.java
File metadata and controls
72 lines (67 loc) · 2.94 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
/**
* @author Deepika Arora
*
* This sample program automated booking tickets on Redbus
*/
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class Redbus {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.redbus.in");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[1]/div[1]/input"))
.sendKeys("Bangalore");
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[1]/div[2]/div[1]/input"))
.sendKeys("Chennai");
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div[1]/img"))
.click();
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div[1]/div/div/div[1]/table/tbody/tr[5]/td[6]/a"))
.click();
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div[2]/img"))
.click();
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[2]/div[2]/div[2]/div/div/table[1]/tbody/tr[5]/td[7]/a"))
.click();
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[3]/div[1]/div[2]/div[3]/a"))
.click();
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[1]/div[2]/div[1]/div[1]/div[2]/div[3]/table/tbody[1]/tr[3]/td[7]/div/div[1]"))
.click();
driver.findElement(
By.xpath("//html/body/center/div[3]/div[4]/div[1]/div[2]/div[1]/div[1]/div[2]/div[3]/table/tbody[2]/tr/td/div/div[1]/div/div[3]/div[2]/div[2]/div[8]/a"))
.click();
Select make = new Select(
driver.findElement(By
.xpath("html/body/center/div[3]/div[4]/div[1]/div[2]/div[1]/div[1]/div[2]/div[3]/table/tbody[2]/tr/td/div/div[1]/div/div[3]/div[4]/select")));
make.selectByIndex(1);
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/div[1]/div[2]/div[1]/div[1]/div[2]/div[3]/table/tbody[2]/tr/td/div/div[1]/div/div[3]/div[3]/a"))
.click();
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/div[1]/div[1]/div[3]/div[3]"))
.click();
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/form[1]/div[3]/div[1]/div[1]/div[1]/div[3]/div/ul/li[1]/input"))
.sendKeys("Test user");
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/form[1]/div[3]/div[1]/div[1]/div[1]/div[3]/div/ul/li[2]/input[2]"))
.click();
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/form[1]/div[3]/div[1]/div[1]/div[1]/div[12]/div[1]/div[1]/input"))
.click();
driver.findElement(
By.xpath("html/body/center/div[3]/div[4]/form[1]/div[3]/div[1]/div[4]/div[2]/div/ul/li[4]/a"))
.click();
}
}