Created
July 25, 2012 14:33
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
package com.sawoy.grid; | |
import com.google.common.base.Throwables; | |
import org.junit.*; | |
import org.openqa.selenium.Cookie; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.ie.InternetExplorerDriver; | |
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel; | |
import org.openqa.selenium.ie.InternetExplorerDriverService; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import java.io.File; | |
import java.io.IOException; | |
import java.util.concurrent.TimeUnit; | |
import java.util.logging.Level; | |
public class Google { | |
protected static WebDriver webDriver; | |
protected static InternetExplorerDriverService service; | |
@BeforeClass | |
public static void setUpClass() { | |
System.setProperty("webdriver.ie.driver", "D:\\IEDriverServer.exe"); | |
service = new InternetExplorerDriverService.Builder().usingAnyFreePort() | |
.withLogFile(new File("D:\\iedriver1.log")).withLogLevel(InternetExplorerDriverLogLevel.TRACE).build(); | |
try { | |
service.start(); | |
} catch (IOException e) { | |
throw Throwables.propagate(e); | |
} | |
Runtime.getRuntime().addShutdownHook(new Thread() { | |
@Override | |
public void run() { | |
service.stop(); | |
} | |
}); | |
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); | |
webDriver = new InternetExplorerDriver(service, capabilities); | |
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); | |
} | |
@AfterClass | |
public static void tearDownClass() { | |
webDriver.quit(); | |
} | |
@Before | |
public void setUp() { | |
webDriver.get("http://google.com"); | |
} | |
@Test | |
public void tryAddCookie() { | |
webDriver.manage().addCookie(new Cookie("testCookie", "tC", "/")); | |
} | |
@Test | |
public void tryGetCookie() { | |
String result = webDriver.manage().getCookieNamed("testCookie").getValue(); | |
Assert.assertEquals("tC", result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment