本文整理汇总了Java中org.openqa.selenium.edge.EdgeDriver类的典型用法代码示例。如果您正苦于以下问题:Java EdgeDriver类的具体用法?Java EdgeDriver怎么用?Java EdgeDriver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EdgeDriver类属于org.openqa.selenium.edge包,在下文中一共展示了EdgeDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldCreateLocalDriverInstance
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
@Test
public void shouldCreateLocalDriverInstance() {
Browser edge = StreamEx.of(browsers)
.findFirst(f -> f.name() == Browser.Name.Edge)
.orElseThrow(() -> new AssertionError(
"Unable to get Edge implementation"));
XmlConfig config = new XmlConfig(new HashMap<String, String>() {
{
put(BROWSER_NAME, "edge");
}
});
PowerMockito.mockStatic(WebDriverManager.class);
BrowserManager browserManager = mock(BrowserManager.class, RETURNS_DEEP_STUBS);
WebDriver driver = mock(EdgeDriver.class, RETURNS_DEEP_STUBS);
WebDriverProvider spyFactory = spy(defaultFactory);
Reflect spyReflectedDriver = spy(spyFactory.wrapDriver(edge));
PowerMockito.when(WebDriverManager.getInstance(spyReflectedDriver.type())).thenReturn(browserManager);
doNothing().when(browserManager).setup();
doReturn(spyReflectedDriver).when(spyFactory).wrapDriver(edge);
doReturn(on(driver)).when(spyReflectedDriver).create(edge.configuration(config));
assertThat(spyFactory.createDriver(edge, config)).isInstanceOf(EdgeDriver.class);
}
示例2: SeleniumExtension
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
public SeleniumExtension() {
handlerMap.put(ChromeDriver.class, ChromeDriverHandler.class);
handlerMap.put(FirefoxDriver.class, FirefoxDriverHandler.class);
handlerMap.put(EdgeDriver.class, EdgeDriverHandler.class);
handlerMap.put(OperaDriver.class, OperaDriverHandler.class);
handlerMap.put(SafariDriver.class, SafariDriverHandler.class);
handlerMap.put(RemoteWebDriver.class, RemoteDriverHandler.class);
handlerMap.put(AppiumDriver.class, AppiumDriverHandler.class);
handlerMap.put(List.class, ListDriverHandler.class);
handlerMap.put(PhantomJSDriver.class, OtherDriverHandler.class);
templateHandlerMap.put("chrome", ChromeDriver.class);
templateHandlerMap.put("firefox", FirefoxDriver.class);
templateHandlerMap.put("edge", EdgeDriver.class);
templateHandlerMap.put("opera", OperaDriver.class);
templateHandlerMap.put("safari", SafariDriver.class);
templateHandlerMap.put("appium", AppiumDriver.class);
templateHandlerMap.put("phantomjs", PhantomJSDriver.class);
templateHandlerMap.put("chrome-in-docker", RemoteWebDriver.class);
templateHandlerMap.put("firefox-in-docker", RemoteWebDriver.class);
templateHandlerMap.put("opera-in-docker", RemoteWebDriver.class);
}
示例3: resolve
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
@Override
public void resolve() {
try {
Optional<Object> testInstance = context.getTestInstance();
Optional<Capabilities> capabilities = annotationsReader
.getCapabilities(parameter, testInstance);
EdgeOptions edgeOptions = (EdgeOptions) getOptions(parameter,
testInstance);
if (capabilities.isPresent()) {
edgeOptions.merge(capabilities.get());
}
object = new EdgeDriver(edgeOptions);
} catch (Exception e) {
handleException(e);
}
}
示例4: start
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
WebDriver start(Capabilities capabilities) {
switch (this) {
case FIREFOX:
return new FirefoxDriver(capabilities);
case HTML_UNIT:
return new HtmlUnitDriver(capabilities);
case CHROME:
return new ChromeDriver(capabilities);
case EDGE:
return new EdgeDriver(capabilities);
case INTERNET_EXPLORER:
return new InternetExplorerDriver(capabilities);
case SAFARI:
return new SafariDriver(capabilities);
default:
throw new AssertionError();
}
}
示例5: initED
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
boolean initED(String url, String path) {
//Edge
try {
System.setProperty("webdriver.edge.driver", path);
driver = new EdgeDriver();
js = (JavascriptExecutor) driver;
writer.writeHeader(url, "ED");
driver.get(url);
} catch (IllegalStateException ise) {
ui.errorMessage("Path to Edge driver is invalid, check settings.");
return false;
} catch (InvalidArgumentException iae) {
ui.errorMessage("Invalid URL?");
return false;
} catch (Exception e) {
System.err.println(e);
return false;
}
return true;
}
示例6: getDriver
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
public static WebDriver getDriver(String browserType){
if ( StringUtils.isEmpty(browserType) || FIREFOX.equals(browserType)) {
return new FirefoxDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType));
}
else if (CHROME.equals(browserType)) {
return new ChromeDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType));
}
else if (IE.equals(browserType)) {
return new InternetExplorerDriver(SeleniumBrowserFactory.getBrowserCapabilities(browserType));
}
else if (PHANTOMJS.equals(browserType)) {
return new PhantomJSDriver();
}
else if (SAFARI.equals(browserType)) {
return new SafariDriver();
}
else if (EDGE.equals(browserType)) {
return new EdgeDriver();
}
else {
throw new RuntimeException(String.format("Unknown browser type: \"%s\"", browserType));
}
}
示例7: edge
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
private WebDriver edge(DesiredCapabilities customDesiredCapabilities) {
EdgeDriverManager.getInstance().setup();
DesiredCapabilities desiredCapabilities = getEdgeDesiredCapabilities();
if (!customDesiredCapabilities.asMap().isEmpty()) {
desiredCapabilities.merge(customDesiredCapabilities);
}
return new EdgeDriver(desiredCapabilities);
}
示例8: forcedTestProvider
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
static Stream<Arguments> forcedTestProvider() {
return Stream.of(
Arguments.of(AppiumDriverHandler.class,
ForcedAppiumJupiterTest.class, AppiumDriver.class,
"appiumNoCapabilitiesTest"),
Arguments.of(AppiumDriverHandler.class,
ForcedAppiumJupiterTest.class, AppiumDriver.class,
"appiumWithCapabilitiesTest"),
Arguments.of(ChromeDriverHandler.class,
ForcedBadChromeJupiterTest.class, ChromeDriver.class,
"chromeTest"),
Arguments.of(FirefoxDriverHandler.class,
ForcedBadFirefoxJupiterTest.class, FirefoxDriver.class,
"firefoxTest"),
Arguments.of(RemoteDriverHandler.class,
ForcedBadRemoteJupiterTest.class, RemoteWebDriver.class,
"remoteTest"),
Arguments.of(EdgeDriverHandler.class,
ForcedEdgeJupiterTest.class, EdgeDriver.class,
"edgeTest"),
Arguments.of(OperaDriverHandler.class,
ForcedOperaJupiterTest.class, OperaDriver.class,
"operaTest"),
Arguments.of(SafariDriverHandler.class,
ForcedSafariJupiterTest.class, SafariDriver.class,
"safariTest"));
}
示例9: testEdgeOptions
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("testClassProvider")
void testEdgeOptions(Class<?> testClass) throws Exception {
Parameter parameter = testClass.getMethod("edgeTest", EdgeDriver.class)
.getParameters()[0];
Optional<Object> testInstance = Optional.of(testClass.newInstance());
EdgeOptions edgeOptions = (EdgeOptions) annotationsReader
.getOptions(parameter, testInstance);
assertThat(edgeOptions.getCapability("pageLoadStrategy"),
equalTo("eager"));
}
示例10: start
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public EdgeDriver start(Capabilities other) {
Capabilities capabilities = this.mergeCapabilities(other);
if (capabilities == null) {
return new EdgeDriver();
}
return new EdgeDriver(capabilities);
}
示例11: loadDefaultConfiguration
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
/**
* Load the default configuration. It will not erase previous non-default configurations.
*
* @return Itself.
*/
public SeleniumConfiguration loadDefaultConfiguration() {
this.getConfiguration().put(ChromeDriver.class, new ChromeConfiguration());
this.getConfiguration().put(EdgeDriver.class, new EdgeConfiguration());
this.getConfiguration().put(FirefoxDriver.class, new FirefoxConfiguration());
this.getConfiguration().put(HtmlUnitConfiguration.class, new HtmlUnitConfiguration());
this.getConfiguration().put(InternetExplorerConfiguration.class, new InternetExplorerConfiguration());
this.getConfiguration().put(OperaConfiguration.class, new OperaConfiguration());
this.getConfiguration().put(PhantomJSConfiguration.class, new PhantomJSConfiguration());
this.getConfiguration().put(SafariDriver.class, new SafariConfiguration());
return this;
}
示例12: getDriver
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
@Override
protected WebDriver getDriver() throws Exception
{
System.setProperty(
"webdriver.edge.driver",
"C:/Program Files (x86)/Microsoft Web Driver/MicrosoftWebDriver.exe"
);
return new EdgeDriver();
}
示例13: EdgeFactory
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
public EdgeFactory() {
super(new Function<DesiredCapabilities, WebDriver>() {
@Override
public WebDriver apply(DesiredCapabilities capabilities) {
return new EdgeDriver(capabilities);
}
});
}
示例14: createWebDriver
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
@Override
public WebDriver createWebDriver(String sessionName)
{
return new EdgeDriver(createOptions());
}
示例15: createDriver
import org.openqa.selenium.edge.EdgeDriver; //导入依赖的package包/类
@Override
public WebDriver createDriver(Capabilities capabilities) {
String driverVersion = (String) capabilities.getCapability(CAPABILITY_DRIVER_VERSION);
EdgeDriverManager.getInstance().version(driverVersion).setup();
return new EdgeDriver((EdgeOptions) capabilities);
}