-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomePage.java
More file actions
59 lines (49 loc) · 1.92 KB
/
Copy pathHomePage.java
File metadata and controls
59 lines (49 loc) · 1.92 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
package pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.Select;
import java.time.Duration;
public class HomePage {
WebDriver driver;
WebDriverWait wait;
By signInLink = By.xpath("//a[contains(text(),'Sign in')]");
By registerLink = By.xpath("//a[@aria-label='Register your account']");
By menu = By.id("menu");
By languageButton = By.id("language");
By contactLink = By.xpath("//a[text()='Contact']");
By homeNav = By.xpath("//a[@data-test='nav-home']");
public HomePage(WebDriver driver){
this.driver = driver;
wait = new WebDriverWait(driver, Duration.ofSeconds(20));
}
// Go to Sign In page
public void goToSignIn() {
wait.until(ExpectedConditions.elementToBeClickable(signInLink)).click();
}
// Go to Register page
public void goToRegister() {
wait.until(ExpectedConditions.elementToBeClickable(registerLink)).click();
}
// Go to Home page
public void goToHome() {
wait.until(ExpectedConditions.elementToBeClickable(homeNav)).click();
}
// Go to Contact page
public void goToContact() {
wait.until(ExpectedConditions.elementToBeClickable(contactLink)).click();
}
// Change language by index
public void changeLanguage(int index) {
wait.until(ExpectedConditions.elementToBeClickable(languageButton)).click();
WebElement option = wait.until(ExpectedConditions.elementToBeClickable(
By.xpath("(//ul[@role='menu']//li)[" + index + "]")));
option.click();
}
// Check if menu is displayed (used after login)
public boolean isMenuDisplayed() {
return wait.until(ExpectedConditions.visibilityOfElementLocated(menu)).isDisplayed();
}
}