forked from machen2/ApprenticeLearningApp
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCreatePostTest.java
More file actions
54 lines (42 loc) · 1.49 KB
/
CreatePostTest.java
File metadata and controls
54 lines (42 loc) · 1.49 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
package com.pillar.pillarLearningCenter.endToEndTests;
import io.github.bonigarcia.wdm.WebDriverManager;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
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.chrome.ChromeOptions;
import java.util.List;
public class CreatePostTest {
private WebDriver driver;
private ChromeOptions options = new ChromeOptions().addArguments("--headless");
@BeforeClass
public static void setupClass() {
WebDriverManager.chromedriver().setup();
}
@Before
public void setupTest() {
driver = new ChromeDriver(options);
}
@After
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void ThisThingCreatesAPost() {
driver.navigate().to("http://localhost:8080/posts/new");
driver.findElement(By.name("title")).sendKeys("New Title - in memory");
driver.findElement(By.name("content")).sendKeys("Content here");
driver.findElement(By.name("username")).sendKeys("Max");
driver.findElement(By.name("submit")).click();
List<WebElement> results = driver.findElements(By.xpath("//h1"));
String result = results.get(1).getText();
assertEquals("New Title - in memory", result);
}
}