-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from arnlaugsson/selenium
Add Selenium support
- Loading branch information
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/selenium/java/is/ru/arnlaugsson/chuck_joke/SeleniumTestWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package is.ru.arnlaugsson.chuck_joke; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
|
||
|
||
public abstract class SeleniumTestWrapper { | ||
static ChromeDriver driver; | ||
static String baseUrl; | ||
static String port; | ||
|
||
@BeforeClass | ||
public static void openBrowser(){ | ||
driver = new ChromeDriver(); | ||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); | ||
|
||
port = System.getenv("PORT"); | ||
if (port == null) { | ||
port = "4567"; | ||
} | ||
baseUrl = "http://localhost:" + port; | ||
} | ||
|
||
@AfterClass | ||
public static void closeBrowser(){ | ||
driver.quit(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/selenium/java/is/ru/arnlaugsson/chuck_joke/TestChuckWeb.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package is.ru.arnlaugsson.chuck_joke; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import org.junit.Test; | ||
|
||
public class TestChuckWeb extends SeleniumTestWrapper { | ||
@Test | ||
public void titleMatches() { | ||
driver.get(baseUrl); | ||
assertEquals("Chuck Norris Jokes", driver.getTitle()); | ||
} | ||
|
||
@Test | ||
public void assertUpdatingNameChangesSpecificJoke() { | ||
driver.get(baseUrl + "/config.html"); | ||
/* | ||
1. Fill in some name (first name, last name) | ||
2. Submit form. | ||
3. Assert that form notifies of success ("Name set as: ...") | ||
4. Navigate to page to get specific Joke | ||
5. Enter a specific joke number | ||
6. Assert the name is used in the joke. | ||
*/ | ||
} | ||
} |