-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomesTestEnv.java
More file actions
136 lines (120 loc) · 4.95 KB
/
Copy pathhomesTestEnv.java
File metadata and controls
136 lines (120 loc) · 4.95 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
package intro;
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.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class homesTestEnv {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "D:\\Learning\\selenium\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
// Test Environment test cases
// Test case 1B Search - Auckland - Test Environment
driver.get("https://ketu.homes-test.com/");
driver.manage().window().maximize();
driver.findElement(By.id("autocomplete-search")).sendKeys("Auckland");
WebDriverWait wait4 = new WebDriverWait(driver, 5);
wait4.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(@class,'ng-tns-c165-8 addressResult ng-star-inserted')]")));
List<WebElement> options4 = driver.findElements(By.xpath("//div[contains(@class,'ng-tns-c165-8 addressResult ng-star-inserted')]"));
for (WebElement option : options4)
{
if (option.getText().equalsIgnoreCase("Auckland"))
{
option.click();
break;
}
}
Thread.sleep(5000);
String Expected_page4 = "https://ketu.homes-test.com/map/auckland/auckland?searchLoc";
String Actual_page4 = driver.getCurrentUrl();
if (Actual_page4.contains(Expected_page4))
{
System.out.println("The Correct page is opened for search result - Auckland Test Environment");
}
else
{
System.out.println("The page opened is Incorrect");
}
String SearchResult4 = driver.findElement(By.xpath("/html[1]/body[1]/homes-root[1]/homes-map-page[1]/div[1]/homes-drawer[1]/div[1]/div[2]/h2[1]")).getText();
if (SearchResult4.contains("Auckland"))
{
System.out.println("Correct search results displayed - Auckland Test Environment");
}
else
{
System.out.println("InCorrect search results displayed");
}
// Test Case 2 B - Petone Test Environment
driver.get("https://ketu.homes-test.com/");
driver.findElement(By.id("autocomplete-search")).sendKeys("Petone");
WebDriverWait wait5 = new WebDriverWait(driver, 5);
wait5.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(@class,'ng-tns-c165-8 addressResult ng-star-inserted')]")));
List<WebElement> options5 = driver.findElements(By.xpath("//div[contains(@class,'addressResult')]"));
for (WebElement option : options5)
{
if ((option.getText().contains("Petone")))
{
option.click();
break;
}
}
Thread.sleep(5000);
String Expected_page5 = "https://ketu.homes-test.com/map/lower-hutt/petone?searchLoc";
String Actual_page5 = driver.getCurrentUrl();
if (Actual_page5.contains(Expected_page5))
{
System.out.println("The Correct page is opened for search result - Petone Test Environment");
}
else
{
System.out.println("The page opened is Incorrect");
}
String SearchResult5 = driver.findElement(By.xpath("/html[1]/body[1]/homes-root[1]/homes-map-page[1]/div[1]/homes-drawer[1]/div[1]/div[2]/h2[1]")).getText();
if (SearchResult5.contains("Petone"))
{
System.out.println("Correct search results displayed - Petone Test Environment");
}
else
{
System.out.println("InCorrect search results displayed");
}
// Test Case 3 B - 45, Puru Cresent Test Environment
driver.get("https://ketu.homes-test.com/");
driver.findElement(By.id("autocomplete-search")).sendKeys("45 Puru Crescent");
WebDriverWait wait6 = new WebDriverWait(driver, 5);
wait6.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(@class,'ng-tns-c165-8 addressResult ng-star-inserted')]")));
List<WebElement> options6 = driver.findElements(By.xpath("//div[contains(@class,'addressResult')]"));
for (WebElement option : options6)
{
if ((option.getText().contains("45 Puru Crescent")))
{
option.click();
break;
}
}
Thread.sleep(5000);
String Expected_page6 = "https://ketu.homes-test.com/map/wellington/lyall-bay/puru-crescent/45?searchLoc=rhf%7BFyb%7Bi%60@";
String Actual_page6 = driver.getCurrentUrl();
if (Actual_page6.equalsIgnoreCase(Expected_page6))
{
System.out.println("The Correct page is opened for search results - Puru, Cresent Test Environment");
}
else
{
System.out.println("The page opened is Incorrect");
}
String SearchResult6 = driver.findElement(By.xpath("/html[1]/body[1]/homes-root[1]/homes-map-page[1]/div[1]/homes-drawer[1]/div[1]/div[2]/h2[1]")).getText();
if (SearchResult6.contains("45 Puru Crescent, Lyall Bay"))
{
System.out.println("Correct search results displayed - Puru, Cresent Test Environment");
}
else
{
System.out.println("InCorrect search results displayed");
}
driver.close();
}
}