Skip to content

Commit fc30d4f

Browse files
committed
Updated pom, home page object, and test for first test
1 parent ef8f452 commit fc30d4f

File tree

5 files changed

+89
-8
lines changed

5 files changed

+89
-8
lines changed

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
<artifactId>redx-demo</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

11-
<properties>
12-
<maven.compiler.source>1.12</maven.compiler.source>
13-
<maven.compiler.target>1.12</maven.compiler.target>
14-
</properties>
15-
1611
<dependencies>
1712
<dependency>
1813
<groupId>org.seleniumhq.selenium</groupId>
@@ -30,6 +25,11 @@
3025
<version>6.14.3</version>
3126
<scope>test</scope>
3227
</dependency>
28+
<dependency>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-compiler-plugin</artifactId>
31+
<version>3.8.1</version>
32+
</dependency>
3333
<dependency>
3434
<groupId>org.apache.maven.plugins</groupId>
3535
<artifactId>maven-surefire-plugin</artifactId>

src/main/java/pages/HomePage.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,66 @@
11
package pages;
22

3+
import org.openqa.selenium.By;
34
import org.openqa.selenium.WebDriver;
5+
import org.openqa.selenium.support.ui.ExpectedConditions;
6+
import org.openqa.selenium.support.ui.WebDriverWait;
47

58
public class HomePage {
69
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");
724

825
public HomePage(WebDriver driver) {
926
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();
1065
}
1166
}

src/test/java/base/BaseTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ public class BaseTests {
1111
protected HomePage homePage;
1212

1313
@BeforeMethod
14-
public void setUp(){
14+
public void setUp() {
1515
System.setProperty("webdriver.chrome.driver", "resources/chromedriver");
1616
driver = new ChromeDriver();
1717
driver.get("https://www.theredx.com/");
18-
driver.manage().window().maximize();
19-
2018
homePage = new HomePage(driver);
2119
}
2220

src/test/java/home/HomeTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package home;
2+
3+
import base.BaseTests;
4+
import org.testng.Assert;
5+
import org.testng.annotations.Test;
6+
7+
public class HomeTests extends BaseTests {
8+
9+
@Test
10+
public void testCanSubmitWatchDemoForm() {
11+
homePage.clickWatchDemo();
12+
homePage.submitWatchDemoForm("Joe","Fake","joe@fake.com", "5555555555");
13+
Assert.assertTrue(homePage.videoPlayerDisplayed(),"Video player was not displayed");
14+
}
15+
}

src/test/xml/redxDemoSuite.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
3+
<suite name="redxDemoSuite" verbose="1">
4+
<test name="TestSuite">
5+
<classes>
6+
<class name="home.HomeTests">
7+
<methods>
8+
<include name="testCanSubmitWatchDemoForm" />
9+
</methods>
10+
</class>
11+
</classes>
12+
</test>
13+
</suite>

0 commit comments

Comments
 (0)