Skip to content

Instantly share code, notes, and snippets.

@banterCZ
Last active February 15, 2016 10:40
Show Gist options
  • Save banterCZ/9189930 to your computer and use it in GitHub Desktop.
Save banterCZ/9189930 to your computer and use it in GitHub Desktop.
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ErrorCollector
import org.openqa.selenium.By
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver
import static org.hamcrest.core.Is.*
/**
* @author banterCZ
*/
class SampleIT {
def webDriver
@Rule
@Delegate
public ErrorCollector errorCollector = new ErrorCollector()
@Test
void "use case foo"() {
webDriver.get("http://10.20.30.1/myapp/form-under-test")
checkMandatoryColor("firsname")
checkMandatoryColor("lastname")
//...
//may continue
}
private def checkMandatoryColor(def name) {
def expectedColor = "rgba(180, 49, 4, 1)"
def element = webDriver.findElement(By.name(name))
def actualColor = element.getCssValue("border-bottom-color")
checkThat("Field: $name", actualColor, is(expectedColor))
}
@Before
void setup() {
DesiredCapabilities abilities = DesiredCapabilities.firefox()
webDriver = new RemoteWebDriver(new URL("http://10.20.30.40:4444/wd/hub"), abilities)
}
@After
void tearDown() {
webDriver.quit()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment