-
Notifications
You must be signed in to change notification settings - Fork 572
Expand file tree
/
Copy pathHotelBookingTest.java
More file actions
78 lines (59 loc) · 2.08 KB
/
HotelBookingTest.java
File metadata and controls
78 lines (59 loc) · 2.08 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
import com.sun.javafx.PlatformUtil;
import java.util.concurrent.TimeUnit;
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.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
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;
@BeforeTest
public void beforeTest() {
setDriverPath();
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
driver = new ChromeDriver(options);
PageFactory.initElements(driver, this);
}
@Test
public void shouldBeAbleToSearchForHotels() {
// setDriverPath();
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
driver.get("https://www.cleartrip.com/");
driver.manage().window().fullscreen();
hotelLink.click();
localityTextBox.sendKeys("Indiranagar, Bangalore");
new Select(travellerSelection).selectByVisibleText("1 room, 2 adults");
searchButton.click();
}
@AfterTest
public void afterTest()
{
driver.close();
driver.quit();
}
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");
}
}
}