Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created November 15, 2011 05:35
Show Gist options
  • Select an option

  • Save chanwit/1366256 to your computer and use it in GitHub Desktop.

Select an option

Save chanwit/1366256 to your computer and use it in GitHub Desktop.
package zk
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.ChromeDriverService
import org.openqa.selenium.remote.RemoteWebDriver
import org.openqa.selenium.remote.DesiredCapabilities
import org.junit.runners.BlockJUnit4ClassRunner
import org.junit.runner.RunWith
import org.junit.*
@RunWith(BlockJUnit4ClassRunner.class)
class WebDriverTests extends GroovyTestCase {
private static ChromeDriverService service
private WebDriver driver
@BeforeClass
public static void createAndStartService() {
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File('E:/ChromeDriver/chromedriver.exe'))
.usingPort(4444)
.build()
service.start()
}
@AfterClass
public static void createAndStopService() {
service.stop()
}
@Before
public void createDriver() {
driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome())
}
@After
public void quitDriver() {
driver.quit()
}
@Test void testSomething() {
driver.get("http://localhost:8080/zk/hello#world")
WebElement label = driver.findElement(By.name("zk_comp_2"))
assertEquals "Hello World via Tag", label.text
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment