本文整理汇总了Java中org.openqa.selenium.safari.SafariDriver类的典型用法代码示例。如果您正苦于以下问题:Java SafariDriver类的具体用法?Java SafariDriver怎么用?Java SafariDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SafariDriver类属于org.openqa.selenium.safari包,在下文中一共展示了SafariDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectLocalBrowser
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
public static WebDriver selectLocalBrowser() {
switch (browser) {
case Chrome:
return new ChromeDriver();
case Firefox:
return new FirefoxDriver();
case IE:
return new InternetExplorerDriver();
case Opera:
return new OperaDriver();
case Safari:
return new SafariDriver();
default:
throw new WebDriverException("No browser specified");
}
}
示例2: SeleniumExtension
import org.openqa.selenium.safari.SafariDriver; //导入依赖的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.safari.SafariDriver; //导入依赖的package包/类
@Override
public void resolve() {
try {
Optional<Object> testInstance = context.getTestInstance();
Optional<Capabilities> capabilities = annotationsReader
.getCapabilities(parameter, testInstance);
SafariOptions safariOptions = (SafariOptions) getOptions(parameter,
testInstance);
if (capabilities.isPresent()) {
safariOptions.merge(capabilities.get());
}
object = new SafariDriver(safariOptions);
} catch (Exception e) {
handleException(e);
}
}
示例4: getDefaultDriver
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@Override
public WebDriver getDefaultDriver()
{
String seleniumBrowser = System.getProperty( "selenium.browser" );
if ( StringUtils.contains( seleniumBrowser, "chrome" ) )
{
return new ChromeDriver();
}
if ( StringUtils.contains( seleniumBrowser, "safari" ) )
{
return new SafariDriver();
}
if ( StringUtils.contains( seleniumBrowser, "iexplore" ) )
{
return new InternetExplorerDriver();
}
return new FirefoxDriver();
}
示例5: getDefaultDriver
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@Override
public WebDriver getDefaultDriver()
{
String seleniumBrowser = System.getProperty( "selenium.browser" );
if ( StringUtils.contains( seleniumBrowser, "chrome" ) )
{
return new ChromeDriver();
}
if ( StringUtils.contains( seleniumBrowser, "safari" ) )
{
return new SafariDriver();
}
if ( StringUtils.contains( seleniumBrowser, "iexplore" ) )
{
return new InternetExplorerDriver();
}
return new FirefoxDriver();
}
示例6: start
import org.openqa.selenium.safari.SafariDriver; //导入依赖的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();
}
}
示例7: createWebDriver
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@Override
public WebDriver createWebDriver() {
DesiredCapabilities cap = new SafariCapabilitiesFactory().createCapabilities(webDriverConfig);
System.out.println("Begin Safari");
synchronized (this.getClass()) {
driver = new SafariDriver(cap);
}
System.out.println("safari started");
this.setWebDriver(driver);
// Implicit Waits handles dynamic element.
setImplicitWaitTimeout(webDriverConfig.getImplicitWaitTimeout());
if (webDriverConfig.getPageLoadTimeout() >= 0) {
TestLogging.log("Safari doesn't support pageLoadTimeout");
}
return driver;
}
示例8: dragAndDropSafari
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@Test
public void dragAndDropSafari() throws InterruptedException {
WebDriver driver = new SafariDriver();
driver.get("http://www.w3schools.com/html/html5_draganddrop.asp");
WebElement source = driver.findElement(id("drag1"));
System.out.println(source.getAttribute("src"));
WebElement target = driver.findElement(id("div2"));
System.out.println(target.getTagName() + "=" + target.toString());
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(source)
.moveToElement(target)
.release(source)
.build();
dragAndDrop.perform();
}
示例9: getDriver
import org.openqa.selenium.safari.SafariDriver; //导入依赖的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));
}
}
示例10: setLocalWebdriver
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
/**
* This method initialises the ThreadLocal WebDriver object according to the
* supplied parameters to enable tests to run on a users local machine.
*/
private void setLocalWebdriver() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("handlesAlerts", true);
switch (getBrowserId(browser)) {
case 0:
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
Boolean.valueOf(System.getProperty("IGNORE_SECURITY_DOMAINS", "false")));
driver.set(new InternetExplorerDriver(capabilities));
break;
case 1:
driver.set(new FirefoxDriver(capabilities));
break;
case 2:
driver.set(new SafariDriver(capabilities));
break;
case 3:
driver.set(new ChromeDriver(capabilities));
break;
default:
throw new WebDriverException("Browser not found: " + browser);
}
}
示例11: setLocalWebdriver
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
/**
* This method initialises the ThreadLocal WebDriver object according to the
* supplied parameters to enable tests to run on a users local machine.
*
* @param browser This can be set to "chrome", "internet explorer" or "firefox"
* @param version This should be set to reflect the browser required. It is only
* used when matching capabilities for a RemoteWebDriver object
* however.
* @param platform This should be set to whatever platform the test is required
* to run on e.g. "WINDOWS", "MAC", "LINUX". It is only used when
* matching capabilities for a RemoteWebDriver object however.
*/
public void setLocalWebdriver(String browser, String version,
String platform) {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability("handlesAlerts", true);
switch (getBrowserId(browser)) {
case 0:
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
Boolean.valueOf(System.getProperty("IGNORE_SECURITY_DOMAINS", "false")));
driver.set(new InternetExplorerDriver(capabilities));
break;
case 1:
driver.set(new FirefoxDriver(capabilities));
break;
case 2:
driver.set(new SafariDriver(capabilities));
break;
case 3:
driver.set(new ChromeDriver(capabilities));
break;
default:
throw new WebDriverException("Browser not found: " + browser);
}
}
示例12: getObject
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@Override
public SafariDriver getObject() throws BeansException {
if (properties.getSafari().isEnabled()) {
try {
return new SafariDriver();
} catch (WebDriverException e) {
e.printStackTrace();
// swallow the exception
}
}
return null;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:13,代码来源:SafariDriverFactory.java
示例13: testWithMockedSafari
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@Test
public void testWithMockedSafari() {
load(new Class[]{MockSafariConfiguration.class},
"com.greglturnquist.webdriver.firefox.enabled:false",
"com.greglturnquist.webdriver.chrome.enabled:false");
WebDriver driver = context.getBean(WebDriver.class);
assertThat(ClassUtils.isAssignable(TakesScreenshot.class,
driver.getClass())).isTrue();
assertThat(ClassUtils.isAssignable(SafariDriver.class,
driver.getClass())).isTrue();
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:12,代码来源:WebDriverAutoConfigurationTests.java
示例14: forcedTestProvider
import org.openqa.selenium.safari.SafariDriver; //导入依赖的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"));
}
示例15: testSafariOptions
import org.openqa.selenium.safari.SafariDriver; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("testClassProvider")
@SuppressWarnings("deprecation")
void testSafariOptions(Class<?> testClass) throws Exception {
Parameter parameter = testClass
.getMethod("safariTest", SafariDriver.class).getParameters()[0];
Optional<Object> testInstance = Optional.of(testClass.newInstance());
SafariOptions safariOptions = (SafariOptions) annotationsReader
.getOptions(parameter, testInstance);
assertTrue(safariOptions.getUseCleanSession());
assertFalse(safariOptions.getUseTechnologyPreview());
}