Last active
December 10, 2016 22:32
-
-
Save banterCZ/acfa969df0bdda4e67c80446474b747c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import org.junit.jupiter.api.AfterEach; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.DisplayName; | |
import org.junit.jupiter.api.Test; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import org.openqa.selenium.By; | |
import java.net.URL; | |
import static org.junit.jupiter.api.Assertions.assertAll; | |
import static org.junit.jupiter.api.Assertions.assertEquals; | |
/** | |
* @author banterCZ | |
*/ | |
public class SampleIT { | |
private WebDriver webDriver; | |
@Test | |
@DisplayName("use case foo") | |
void groupedAssertions() { | |
webDriver.get("http://10.20.30.1/myapp/form-under-test"); | |
assertAll("mandatoryColor", | |
() -> checkMandatoryColor("firstname"), | |
() -> checkMandatoryColor("lastname") | |
); | |
//... | |
//may continue | |
} | |
private void checkMandatoryColor(String name) { | |
String expectedColor = "rgba(180, 49, 4, 1)"; | |
WebElement element = webDriver.findElement(By.name(name)); | |
String actualColor = element.getCssValue("border-bottom-color"); | |
assertEquals(expectedColor, actualColor, "Field: " + name); | |
} | |
@BeforeEach | |
void setup() throws Exception { | |
DesiredCapabilities abilities = DesiredCapabilities.firefox(); | |
webDriver = new RemoteWebDriver(new URL("http://10.20.30.40:4444/wd/hub"), abilities); | |
} | |
@AfterEach | |
void tearDown() { | |
webDriver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment