Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
.idea
.gradle
.gradle
/out
Binary file modified chromedriver.exe
Binary file not shown.
18 changes: 18 additions & 0 deletions src/main/java/Credentials.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class Credentials {

private String username;
private String password;

public Credentials() {
username = "[email protected]";
password = "password@123";
}

public String getUsername() {
return username;
}

public String getPassword() {
return password;
}
}
21 changes: 21 additions & 0 deletions src/main/java/FlightBookingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ public void testThatResultsAppearForAOneWayJourney() {

}

@Test
public void testThatResultsAppearForRecentSearches() {

setDriverPath();
driver.get("https://www.cleartrip.com/");
waitFor(2000);

//results for all recent searches
List<WebElement> recentSearches = driver.findElements(By.cssSelector("#RecentSearch li"));

//Click on the first recent search
recentSearches.get(0).click();

waitFor(5000);
//verify that result appears for the provided journey search
Assert.assertTrue(isElementPresent(By.className("searchSummary")));

//close the browser
driver.quit();
}


private void waitFor(int durationInMilliSeconds) {
try {
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/HotelBookingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.List;

public class HotelBookingTest {

WebDriver driver = new ChromeDriver();
Expand All @@ -22,6 +25,12 @@ public class HotelBookingTest {
@FindBy(id = "travellersOnhome")
private WebElement travellerSelection;

@FindBy(css = ".starFilter input[value='5']")
private WebElement fiveStarFilter;

@FindBy(css = ".hotelsList li .metaData.clearFix span[class*='starRating']")
private List<WebElement> filteredHotelsRating;

@Test
public void shouldBeAbleToSearchForHotels() {
setDriverPath();
Expand All @@ -38,6 +47,37 @@ public void shouldBeAbleToSearchForHotels() {

}

@Test
public void shouldBeAbleToFilterFiveStarHotels() {
setDriverPath();

driver.get("https://www.cleartrip.com/");
hotelLink.click();

localityTextBox.sendKeys("Indiranagar, Bangalore");

new Select(travellerSelection).selectByVisibleText("1 room, 2 adults");
searchButton.click();

waitFor(5000);

fiveStarFilter.click();

waitFor(2000);

Assert.assertTrue(filteredHotelsRating.get(0).getAttribute("Title").contains("5"));

driver.quit();
}

private void waitFor(int durationInMilliSeconds) {
try {
Thread.sleep(durationInMilliSeconds);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}

private void setDriverPath() {
if (PlatformUtil.isMac()) {
System.setProperty("webdriver.chrome.driver", "chromedriver");
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/SignInTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

public class SignInTest {

WebDriver driver = new ChromeDriver();
WebDriver driver;
Credentials creds;

@Test
public void shouldThrowAnErrorIfSignInDetailsAreMissing() {
Expand All @@ -27,6 +28,29 @@ public void shouldThrowAnErrorIfSignInDetailsAreMissing() {
driver.quit();
}

@Test
public void shouldThrowAnErrorIfSignInWithInvalidCredentials() {

setDriverPath();
driver.get("https://www.cleartrip.com/");
waitFor(2000);

driver.findElement(By.linkText("Your trips")).click();
waitFor(2000);
driver.findElement(By.id("SignIn")).click();

waitFor(3000);

driver.findElement(By.id("email")).sendKeys(creds.getUsername());
driver.findElement(By.id("password")).sendKeys(creds.getPassword());

driver.findElement(By.id("signInButton")).click();

String errors1 = driver.findElement(By.id("errors1")).getText();
Assert.assertTrue(errors1.contains("There were errors in your submission"));
driver.quit();
}

private void waitFor(int durationInMilliSeconds) {
try {
Thread.sleep(durationInMilliSeconds);
Expand Down