Repository navigation
Expand file tree
/
Copy pathHotelBookingTest.java
More file actions
80 lines (56 loc) · 2 KB
/
Copy pathHotelBookingTest.java
File metadata and controls
80 lines (56 loc) · 2 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
import com.sun.javafx.PlatformUtil;
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.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class HotelBookingTest {
WebDriver driver ;
@FindBy(linkText = "Hotels")
private WebElement hotelLink;
@FindBy(id = "Tags")
private WebElement localityTextBox;
@FindBy(id = "SearchHotelsButton")
private WebElement searchButton;
@FindBy(id = "travellersOnhome")
private WebElement travellerSelection;
@BeforeClass
public void setUp(){
System.setProperty("webdriver.chrome.driver", "E:\\testvigrant\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().window().maximize();
PageFactory.initElements(driver, HotelBookingTest.this);
}
@AfterClass
public void tearDown(){
driver.close();
driver.quit();
}
@Test
public void shouldBeAbleToSearchForHotels() {
setDriverPath();
driver.get("https://www.cleartrip.com/");
hotelLink.click();
localityTextBox.sendKeys("Indiranagar, Bangalore");
new Select(travellerSelection).selectByVisibleText("1 room, 2 adults");
searchButton.click();
}
private void setDriverPath() {
if (PlatformUtil.isMac()) {
System.setProperty("webdriver.chrome.driver", "chromedriver");
}
if (PlatformUtil.isWindows()) {
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
}
if (PlatformUtil.isLinux()) {
System.setProperty("webdriver.chrome.driver", "chromedriver_linux");
}
}
}