|
39 | 39 | * import org.junit.*;
|
40 | 40 | * import org.junit.runner.RunWith;
|
41 | 41 | * import org.junit.runners.JUnit4;
|
| 42 | + * import org.openqa.selenium.By; |
| 43 | + * import org.openqa.selenium.WebDriver; |
| 44 | + * import org.openqa.selenium.WebElement; |
42 | 45 | * import org.openqa.selenium.chrome.ChromeDriverService;
|
43 |
| - * import org.openqa.selenium.remote.DesiredCapabilities; |
| 46 | + * import org.openqa.selenium.chrome.ChromeOptions; |
44 | 47 | * import org.openqa.selenium.remote.RemoteWebDriver;
|
45 | 48 | *
|
| 49 | + * import java.io.File; |
| 50 | + * import java.io.IOException; |
| 51 | + * |
46 | 52 | * {@literal @RunWith(JUnit4.class)}
|
47 |
| - * public class ChromeTest extends TestCase { |
| 53 | + * public class ChromeTest { |
48 | 54 | *
|
49 | 55 | * private static ChromeDriverService service;
|
50 | 56 | * private WebDriver driver;
|
51 | 57 | *
|
52 | 58 | * {@literal @BeforeClass}
|
53 |
| - * public static void createAndStartService() { |
| 59 | + * public static void createAndStartService() throws IOException { |
54 | 60 | * service = new ChromeDriverService.Builder()
|
55 | 61 | * .usingDriverExecutable(new File("path/to/my/chromedriver.exe"))
|
56 | 62 | * .usingAnyFreePort()
|
|
65 | 71 | *
|
66 | 72 | * {@literal @Before}
|
67 | 73 | * public void createDriver() {
|
68 |
| - * driver = new RemoteWebDriver(service.getUrl(), |
69 |
| - * DesiredCapabilities.chrome()); |
| 74 | + * driver = new RemoteWebDriver(service.getUrl(), new ChromeOptions()); |
70 | 75 | * }
|
71 | 76 | *
|
72 | 77 | * {@literal @After}
|
|
79 | 84 | * driver.get("http://www.google.com");
|
80 | 85 | * WebElement searchBox = driver.findElement(By.name("q"));
|
81 | 86 | * searchBox.sendKeys("webdriver");
|
82 |
| - * searchBox.quit(); |
| 87 | + * searchBox.sendKeys(Keys.ENTER); |
83 | 88 | * assertEquals("webdriver - Google Search", driver.getTitle());
|
84 | 89 | * }
|
85 | 90 | * }
|
|
0 commit comments