public class EdgeDriver extends RemoteWebDriver
WebDriver
implementation that controls a Edge browser running on the local machine.
This class is provided as a convenience for easily testing the Edge browser. The control server
which each instance communicates with will live and die with the instance.
To avoid unnecessarily restarting the MicrosoftEdgeDriver server with each instance, use a
RemoteWebDriver
coupled with the desired EdgeDriverService
, which is managed
separately. For example:
import static org.junit.Assert.assertEquals;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
{@literal @RunWith(JUnit4.class)}
public class EdgeTest extends TestCase {
private static EdgeDriverService service;
private WebDriver driver;
{@literal @BeforeClass}
public static void createAndStartService() {
service = new EdgeDriverService.Builder()
.usingDriverExecutable(new File("path/to/my/MicrosoftWebDriver.exe"))
.usingAnyFreePort()
.build();
service.start();
}
{@literal @AfterClass}
public static void createAndStopService() {
service.stop();
}
{@literal @Before}
public void createDriver() {
driver = new RemoteWebDriver(service.getUrl(),
DesiredCapabilities.edge());
}
{@literal @After}
public void quitDriver() {
driver.quit();
}
{@literal @Test}
public void testGoogleSearch() {
driver.get("http://www.google.com");
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("webdriver");
searchBox.quit();
assertEquals("webdriver - Google Search", driver.getTitle());
}
}
EdgeDriverService.createDefaultService()
RemoteWebDriver.RemoteTargetLocator, RemoteWebDriver.RemoteWebDriverOptions, RemoteWebDriver.When
org.openqa.selenium.WebDriver.ImeHandler, org.openqa.selenium.WebDriver.Navigation, org.openqa.selenium.WebDriver.Options, org.openqa.selenium.WebDriver.TargetLocator, org.openqa.selenium.WebDriver.Timeouts, org.openqa.selenium.WebDriver.Window
Constructor and Description |
---|
EdgeDriver()
Creates a new EdgeDriver using the
default
server configuration. |
EdgeDriver(org.openqa.selenium.Capabilities capabilities)
Creates a new EdgeDriver instance.
|
EdgeDriver(EdgeDriverService service)
Creates a new EdgeDriver instance.
|
EdgeDriver(EdgeDriverService service,
org.openqa.selenium.Capabilities capabilities)
Creates a new EdgeDriver instance.
|
EdgeDriver(EdgeDriverService service,
EdgeOptions options)
Creates a new EdgeDriver instance with the specified options.
|
EdgeDriver(EdgeOptions options)
Creates a new EdgeDriver instance with the specified options.
|
close, execute, execute, executeAsyncScript, executeScript, findElement, findElement, findElementByClassName, findElementByCssSelector, findElementById, findElementByLinkText, findElementByName, findElementByPartialLinkText, findElementByTagName, findElementByXPath, findElements, findElements, findElementsByClassName, findElementsByCssSelector, findElementsById, findElementsByLinkText, findElementsByName, findElementsByPartialLinkText, findElementsByTagName, findElementsByXPath, get, getCapabilities, getCommandExecutor, getCurrentUrl, getElementConverter, getErrorHandler, getExecuteMethod, getFileDetector, getKeyboard, getMouse, getPageSource, getScreenshotAs, getSessionId, getTitle, getW3CStandardComplianceLevel, getWindowHandle, getWindowHandles, log, manage, navigate, quit, setCommandExecutor, setElementConverter, setErrorHandler, setFileDetector, setFoundBy, setLogLevel, setSessionId, startClient, startSession, startSession, stopClient, switchTo, toString
public EdgeDriver()
default
server configuration.public EdgeDriver(EdgeDriverService service)
service
will be started along with the driver,
and shutdown upon calling RemoteWebDriver.quit()
.service
- The service to use.EdgeDriver(EdgeDriverService, EdgeOptions)
public EdgeDriver(org.openqa.selenium.Capabilities capabilities)
capabilities
will be passed to the
edgedriver service.capabilities
- The capabilities required from the EdgeDriver.EdgeDriver(EdgeDriverService, Capabilities)
public EdgeDriver(EdgeOptions options)
options
- The options to use.EdgeDriver(EdgeDriverService, EdgeOptions)
public EdgeDriver(EdgeDriverService service, EdgeOptions options)
service
will be
started along with the driver, and shutdown upon calling RemoteWebDriver.quit()
.service
- The service to use.options
- The options to use.public EdgeDriver(EdgeDriverService service, org.openqa.selenium.Capabilities capabilities)
service
will be started along with the
driver, and shutdown upon calling RemoteWebDriver.quit()
.service
- The service to use.capabilities
- The capabilities required from the EdgeDriver.Copyright © 2015. All rights reserved.