|
1 | 1 | package pages; |
2 | 2 |
|
| 3 | +import org.openqa.selenium.By; |
3 | 4 | import org.openqa.selenium.WebDriver; |
| 5 | +import org.openqa.selenium.support.ui.ExpectedConditions; |
| 6 | +import org.openqa.selenium.support.ui.WebDriverWait; |
4 | 7 |
|
5 | 8 | public class HomePage { |
6 | 9 | private WebDriver driver; |
| 10 | + private WebDriverWait wait; |
| 11 | + |
| 12 | + private By cookieWindow = By.cssSelector("#cookie-window"); |
| 13 | + private By logoSlidebar = By.cssSelector(".logos"); |
| 14 | + private By watchDemoBtn = By.cssSelector(".btn.btn-red-outline.gated"); |
| 15 | + |
| 16 | + //Demo Form |
| 17 | + private By watchDemoFormContainer = By.id("gform_fields_16"); |
| 18 | + private By firstNameField = By.cssSelector("[name=\"input_3\"]"); |
| 19 | + private By lastNameField = By.cssSelector("[name=\"input_9\"]"); |
| 20 | + private By emailField = By.cssSelector("[name=\"input_2\"]"); |
| 21 | + private By phoneField = By.cssSelector("[name=\"input_7\"]"); |
| 22 | + private By submitBtn = By.cssSelector(".gform_button"); |
| 23 | + private By videoPlayer = By.id("player"); |
7 | 24 |
|
8 | 25 | public HomePage(WebDriver driver) { |
9 | 26 | this.driver = driver; |
| 27 | + wait = new WebDriverWait(driver, 15); |
| 28 | + } |
| 29 | + |
| 30 | + public void clickWatchDemo() { |
| 31 | + wait.until(ExpectedConditions.invisibilityOfElementLocated(cookieWindow)); |
| 32 | + wait.until(ExpectedConditions.visibilityOfElementLocated(watchDemoBtn)); |
| 33 | + driver.findElement(watchDemoBtn).click(); |
| 34 | + } |
| 35 | + |
| 36 | + public void submitWatchDemoForm(String firstName, String lastName, String email, String phone) { |
| 37 | + inputFirstName(firstName); |
| 38 | + inputLastName(lastName); |
| 39 | + inputEmail(email); |
| 40 | + inputPhoneNumber(phone); |
| 41 | + } |
| 42 | + |
| 43 | + private void inputFirstName(String firstName){ |
| 44 | + wait.until(ExpectedConditions.visibilityOfElementLocated(watchDemoFormContainer)); |
| 45 | + driver.findElement(firstNameField).sendKeys(firstName); |
| 46 | + } |
| 47 | + |
| 48 | + private void inputLastName(String lastName){ |
| 49 | + wait.until(ExpectedConditions.visibilityOfElementLocated(watchDemoFormContainer)); |
| 50 | + driver.findElement(lastNameField).sendKeys(lastName); |
| 51 | + } |
| 52 | + |
| 53 | + private void inputEmail(String email){ |
| 54 | + wait.until(ExpectedConditions.visibilityOfElementLocated(watchDemoFormContainer)); |
| 55 | + driver.findElement(emailField).sendKeys(email); |
| 56 | + } |
| 57 | + |
| 58 | + private void inputPhoneNumber(String phone) { |
| 59 | + driver.findElement(phoneField).sendKeys(phone); |
| 60 | + } |
| 61 | + |
| 62 | + public boolean videoPlayerDisplayed(){ |
| 63 | + wait.until(ExpectedConditions.visibilityOfElementLocated(videoPlayer)); |
| 64 | + return driver.findElement(videoPlayer).isDisplayed(); |
10 | 65 | } |
11 | 66 | } |
0 commit comments