public class EdgeDriver
extends org.openqa.selenium.remote.RemoteWebDriver
implements org.openqa.selenium.html5.LocationContext, org.openqa.selenium.html5.WebStorage, org.openqa.selenium.interactions.HasTouchScreen, org.openqa.selenium.mobile.NetworkConnection
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 EdgeDriver 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 com.microsoft.edge.seleniumtools.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/msedgedriver.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 testBingSearch() {
driver.get("https://www.bing.com");
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("webdriver");
searchBox.quit();
assertEquals("webdriver - Bing", driver.getTitle());
}
}
Note that unlike EdgeDriver, RemoteWebDriver doesn't directly implement
role interfaces such as LocationContext and WebStorage.
Therefore, to access that functionality, it needs to be
augmented and then cast
to the appropriate interface.EdgeDriverService.createDefaultService()org.openqa.selenium.remote.RemoteWebDriver.RemoteTargetLocator, org.openqa.selenium.remote.RemoteWebDriver.RemoteWebDriverOptions, org.openqa.selenium.remote.RemoteWebDriver.Whenorg.openqa.selenium.mobile.NetworkConnection.ConnectionTypeorg.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)
Deprecated.
Use
EdgeDriver(EdgeOptions) instead. |
EdgeDriver(EdgeDriverService service)
Creates a new EdgeDriver instance.
|
EdgeDriver(EdgeDriverService service,
org.openqa.selenium.Capabilities capabilities)
Deprecated.
Use
EdgeDriver(EdgeDriverService, EdgeOptions) instead. |
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.
|
| Modifier and Type | Method and Description |
|---|---|
org.openqa.selenium.html5.LocalStorage |
getLocalStorage() |
org.openqa.selenium.mobile.NetworkConnection.ConnectionType |
getNetworkConnection() |
org.openqa.selenium.html5.SessionStorage |
getSessionStorage() |
org.openqa.selenium.interactions.TouchScreen |
getTouch() |
void |
launchApp(String id)
Launches Edge app specified by id.
|
org.openqa.selenium.html5.Location |
location() |
void |
setFileDetector(org.openqa.selenium.remote.FileDetector detector) |
void |
setLocation(org.openqa.selenium.html5.Location location) |
org.openqa.selenium.mobile.NetworkConnection.ConnectionType |
setNetworkConnection(org.openqa.selenium.mobile.NetworkConnection.ConnectionType type) |
builder, 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, getWindowHandle, getWindowHandles, log, manage, navigate, perform, quit, resetInputState, setCommandExecutor, setElementConverter, setErrorHandler, setFoundBy, setLogLevel, setSessionId, startSession, switchTo, toStringpublic 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.RemoteWebDriver(org.openqa.selenium.remote.CommandExecutor, Capabilities)@Deprecated public EdgeDriver(org.openqa.selenium.Capabilities capabilities)
EdgeDriver(EdgeOptions) instead.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.@Deprecated public EdgeDriver(EdgeDriverService service, org.openqa.selenium.Capabilities capabilities)
EdgeDriver(EdgeDriverService, EdgeOptions) instead.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.public void setFileDetector(org.openqa.selenium.remote.FileDetector detector)
setFileDetector in class org.openqa.selenium.remote.RemoteWebDriverpublic org.openqa.selenium.html5.LocalStorage getLocalStorage()
getLocalStorage in interface org.openqa.selenium.html5.WebStoragepublic org.openqa.selenium.html5.SessionStorage getSessionStorage()
getSessionStorage in interface org.openqa.selenium.html5.WebStoragepublic org.openqa.selenium.html5.Location location()
location in interface org.openqa.selenium.html5.LocationContextpublic void setLocation(org.openqa.selenium.html5.Location location)
setLocation in interface org.openqa.selenium.html5.LocationContextpublic org.openqa.selenium.interactions.TouchScreen getTouch()
getTouch in interface org.openqa.selenium.interactions.HasTouchScreenpublic org.openqa.selenium.mobile.NetworkConnection.ConnectionType getNetworkConnection()
getNetworkConnection in interface org.openqa.selenium.mobile.NetworkConnectionpublic org.openqa.selenium.mobile.NetworkConnection.ConnectionType setNetworkConnection(org.openqa.selenium.mobile.NetworkConnection.ConnectionType type)
setNetworkConnection in interface org.openqa.selenium.mobile.NetworkConnectionpublic void launchApp(String id)
id - Edge app id.Copyright © 2021. All rights reserved.