当前位置: 首页>>代码示例>>Java>>正文


Java SafariDriver类代码示例

本文整理汇总了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");
	}
}
 
开发者ID:Spence1115,项目名称:selenium-cucumber-framework,代码行数:17,代码来源:BrowserFactory.java

示例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);
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:23,代码来源:SeleniumExtension.java

示例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);
    }
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:17,代码来源:SafariDriverHandler.java

示例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();

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:24,代码来源:WebDriverBrowseTest.java

示例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();

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:24,代码来源:WebDriverTest.java

示例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();
    }
}
 
开发者ID:chr-krenn,项目名称:chr-krenn-fhj-ws2016-sd14-pse,代码行数:19,代码来源:BaseUITest.java

示例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;
}
 
开发者ID:tarun3kumar,项目名称:seleniumtestsframework,代码行数:21,代码来源:SafariDriverFactory.java

示例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();
}
 
开发者ID:yujunliang,项目名称:seleniumcapsules,代码行数:18,代码来源:DragAndDropTest.java

示例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));
    }
}
 
开发者ID:galenframework,项目名称:galen,代码行数:25,代码来源:SeleniumBrowserFactory.java

示例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);
    }
}
 
开发者ID:testworx,项目名称:SeleniumFramework,代码行数:29,代码来源:Browser.java

示例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);
    }
}
 
开发者ID:testworx,项目名称:SeleniumFramework,代码行数:38,代码来源:BaseTest.java

示例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"));
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:28,代码来源:ForcedAnnotationReaderTest.java

示例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());
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:14,代码来源:SafariAnnotationReaderTest.java


注:本文中的org.openqa.selenium.safari.SafariDriver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。