Java 类org.openqa.selenium.safari.SafariDriver 实例源码

项目:selenium-cucumber-framework    文件:BrowserFactory.java   
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");
    }
}
项目:selenium-jupiter    文件:SeleniumExtension.java   
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);
}
项目:selenium-jupiter    文件:SafariDriverHandler.java   
@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);
    }
}
项目:apache-archiva    文件:WebDriverBrowseTest.java   
@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();

}
项目:apache-archiva    文件:WebDriverTest.java   
@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();

}
项目:chr-krenn-fhj-ws2016-sd14-pse    文件:BaseUITest.java   
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();
    }
}
项目:seleniumtestsframework    文件:SafariDriverFactory.java   
@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;
}
项目:seleniumcapsules    文件:DragAndDropTest.java   
@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();
}
项目:galen    文件:SeleniumBrowserFactory.java   
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));
    }
}
项目:SeleniumFramework    文件:Browser.java   
/**
 * 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);
    }
}
项目:SeleniumFramework    文件:BaseTest.java   
/**
 * 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);
    }
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:SafariDriverFactory.java   
@Override
public SafariDriver getObject() throws BeansException {
    if (properties.getSafari().isEnabled()) {
        try {
            return new SafariDriver();
        } catch (WebDriverException e) {
            e.printStackTrace();
            // swallow the exception
        }
    }
    return null;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:WebDriverAutoConfigurationTests.java   
@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();
}
项目:selenium-jupiter    文件:ForcedAnnotationReaderTest.java   
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"));
}
项目:selenium-jupiter    文件:SafariAnnotationReaderTest.java   
@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());
}
项目:Java-Testing-Toolbox    文件:SafariConfiguration.java   
/**
 * {@inheritDoc}
 */
@Override
public SafariDriver start(Capabilities other) {
    Capabilities capabilities = this.mergeCapabilities(other);

    if (capabilities == null) {
        return new SafariDriver();
    }

    return new SafariDriver(capabilities);
}
项目:Java-Testing-Toolbox    文件:SeleniumConfiguration.java   
/**
 * 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;
}
项目:AutomationFrameworkTPG    文件:DriverProperties.java   
private WebDriver initSafariDriver(String appURL) {
    System.out.println("Launching Safari browser..");
    WebDriver driver = new SafariDriver();
    driver.manage().window().maximize();
    driver.navigate().to(appURL);
    return new WebDriverProxy().protect(driver);
}
项目:selenium-example    文件:SafariTest.java   
@Before
public void prepare() {

    testUrl = "https://leftstick.github.io/";

    driver = new SafariDriver();
    driver.manage().window().maximize();
    driver.get(testUrl);
}
项目:webdrivermanager    文件:OtherWebDriverTest.java   
@Parameters(name = "{index}: {0} {1}")
public static Collection<Object[]> data() {
    return asList(new Object[][] {
            { SafariDriver.class, WebDriverException.class },
            { EventFiringWebDriver.class, InstantiationException.class },
            { HtmlUnitDriver.class, null },
            { RemoteWebDriver.class, IllegalAccessException.class } });
}
项目:kc-rice    文件:WebDriverUtils.java   
/**
 * <p>
 * remote.public.driver set to chrome or firefox (null assumes firefox).
 * </p><p>
 * if remote.public.hub is set a RemoteWebDriver is created (Selenium Grid)
 * if proxy.host is set, the web driver is setup to use a proxy
 * </p>
 *
 * @return WebDriver or null if unable to create
 */
public static WebDriver getWebDriver() {
    String driverParam = System.getProperty(HUB_DRIVER_PROPERTY);
    String hubParam = System.getProperty(HUB_PROPERTY);
    String proxyParam = System.getProperty(PROXY_HOST_PROPERTY);

    // setup proxy if specified as VM Arg
    DesiredCapabilities capabilities = new DesiredCapabilities();
    WebDriver webDriver = null;
    if (StringUtils.isNotEmpty(proxyParam)) {
        capabilities.setCapability(CapabilityType.PROXY, new Proxy().setHttpProxy(proxyParam));
    }

    if (hubParam == null) {
        if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
            FirefoxProfile profile = new FirefoxProfile();
            profile.setEnableNativeEvents(false);
            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
            return new FirefoxDriver(capabilities);
        } else if ("chrome".equalsIgnoreCase(driverParam)) {
            return new ChromeDriver(capabilities);
        } else if ("safari".equals(driverParam)) {
            System.out.println("SafariDriver probably won't work, if it does please contact Erik M.");
            return new SafariDriver(capabilities);
        }
    } else {
        try {
            if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(getHubUrlString()), DesiredCapabilities.firefox());
            } else if ("chrome".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(getHubUrlString()), DesiredCapabilities.chrome());
            }
        } catch (MalformedURLException mue) {
            System.out.println(getHubUrlString() + " " + mue.getMessage());
            mue.printStackTrace();
        }
    }
    return null;
}
项目:frameworkium-core    文件:SafariImpl.java   
@Override
public WebDriver getWebDriver(Capabilities capabilities) {
    if (Driver.isMobile()) {
        throw new IllegalArgumentException(
                "seleniumGridURL or sauceUser and sauceKey must be specified when running on iOS");
    } else {
        return new SafariDriver(new SafariOptions(capabilities));
    }
}
项目:hsac-fitnesse-fixtures    文件:SeleniumHelper.java   
/**
 * @return true when current driver is connected to either a local or remote Safari.
 */
public boolean connectedToSafari() {
    boolean result = false;
    WebDriver driver = driver();
    if (driver instanceof SafariDriver) {
        result = true;
    } else if (driver instanceof RemoteWebDriver) {
        result = checkRemoteBrowserName(driver, "safari");
    }
    return result;
}
项目:desert    文件:WebDriverFactory.java   
private static WebDriver createLocalDriver(Capabilities capabilities) {
    String browserType = capabilities.getBrowserName();
    if (browserType.equals(BrowserType.FIREFOX))
        return new FirefoxDriver(capabilities);
    if (browserType.equals(BrowserType.IE))
        return new InternetExplorerDriver(capabilities);
    if (browserType.equals(BrowserType.CHROME))
        return new ChromeDriver(capabilities);
    if (browserType.equals(BrowserType.SAFARI))
        return new SafariDriver(capabilities);

    throw new Error("Unsupported browser type: " + browserType);
}
项目:rice    文件:WebDriverUtils.java   
/**
 * <p>
 * remote.public.driver set to chrome or firefox (null assumes firefox).
 * </p><p>
 * if remote.public.hub is set a RemoteWebDriver is created (Selenium Grid)
 * if proxy.host is set, the web driver is setup to use a proxy
 * </p>
 *
 * @return WebDriver or null if unable to create
 */
public static WebDriver getWebDriver() {
    String driverParam = System.getProperty(HUB_DRIVER_PROPERTY);
    String hubParam = System.getProperty(HUB_PROPERTY);
    String proxyParam = System.getProperty(PROXY_HOST_PROPERTY);

    // setup proxy if specified as VM Arg
    DesiredCapabilities capabilities = new DesiredCapabilities();
    WebDriver webDriver = null;
    if (StringUtils.isNotEmpty(proxyParam)) {
        capabilities.setCapability(CapabilityType.PROXY, new Proxy().setHttpProxy(proxyParam));
    }

    if (hubParam == null) {
        if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
            FirefoxProfile profile = new FirefoxProfile();
            profile.setEnableNativeEvents(false);
            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
            return new FirefoxDriver(capabilities);
        } else if ("chrome".equalsIgnoreCase(driverParam)) {
            return new ChromeDriver(capabilities);
        } else if ("safari".equals(driverParam)) {
            System.out.println("SafariDriver probably won't work, if it does please contact Erik M.");
            return new SafariDriver(capabilities);
        }
    } else {
        try {
            if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(getHubUrlString()), DesiredCapabilities.firefox());
            } else if ("chrome".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(getHubUrlString()), DesiredCapabilities.chrome());
            }
        } catch (MalformedURLException mue) {
            System.out.println(getHubUrlString() + " " + mue.getMessage());
            mue.printStackTrace();
        }
    }
    return null;
}
项目:selenium-java-robot    文件:LocalRobotizedBrowserFactory.java   
@Override
public RemoteWebDriver createWebDriver() {
    SafariDriver safari = new SafariDriver();
    if (OS.isFamilyMac()) {
        try {
            // put the browser in the foreground:
            String cmdline = "open -a safari";
            SeleniumJavaRobot.log("Executing: " + cmdline);
            Runtime.getRuntime().exec(cmdline);
        } catch (Exception e) {
        }
    }
    return safari;
}
项目:darcy-webdriver    文件:SafariBrowserFactoryTest.java   
@Test
public void shouldBeInstanceOfUntargetedSafariDriver() {
    WebDriverBrowserFactory browserFactory = new SafariBrowserFactory();

    browser = (WebDriverBrowser) browserFactory.newBrowser();
    ForwardingTargetedWebDriver webDriver = (ForwardingTargetedWebDriver) browser.getWrappedDriver();
    CachingTargetLocator targetLocator = (CachingTargetLocator) webDriver.getTargetLocator();

    assertThat(targetLocator.getUntargetedDriver(), instanceOf(SafariDriver.class));
}
项目:seleniumcapsules    文件:BrowserTest.java   
@Test
public void findHowItWorksLinkUsingPartialLinkText() {
    WebDriver driver = new SafariDriver();
    driver.get("http://ticketfly.com/careers");
    WebElement element = driver.findElement(By.linkText("How It Works"));
    System.out.println("element=" + element);
    System.out.println("element.getTagName()=" + element.getTagName());
    System.out.println("element.getText()=" + element.getText());
}
项目:gga-selenium-framework    文件:WebDriverWrapper.java   
/**
 * initialization SafariDriver
 *
 * @param capabilities - desired capabilities
 */
public static void initSafariDriver(Capabilities capabilities) {
    ReporterNGExt.logTechnical("Initialization Safari Driver");
    setWebDriver(new SafariDriver(capabilities));
    setTimeout(TIMEOUT);
    getDriver().manage().window().maximize();
}
项目:gga-selenium-framework    文件:WebDriverWrapper.java   
/**
 * initialization SafariDriver
 */
public static void initSafariDriver() {
    ReporterNGExt.logTechnical("Initialization Safari Driver");
    setWebDriver(new SafariDriver());
    setTimeout(TIMEOUT);
    getDriver().manage().window().maximize();
}
项目:wisdom    文件:WisdomFluentLeniumTest.java   
@Override
public WebDriver getDefaultDriver() {
    String browser = System.getProperty("fluentlenium.browser");
    LOGGER.debug("Selecting Selenium Browser using " + browser);
    if (browser == null) {
        LOGGER.debug("Using default HTML Unit Driver");
        return new HtmlUnitDriver();
    }

    if ("chrome".equalsIgnoreCase(browser)) {
        LOGGER.debug("Using Chrome");
        return new ChromeDriver();
    }

    if ("firefox".equalsIgnoreCase(browser)) {
        LOGGER.debug("Using Firefox");
        return new FirefoxDriver();
    }

    if ("ie".equalsIgnoreCase(browser) || "internetexplorer".equalsIgnoreCase(browser)) {
        LOGGER.debug("Using Internet Explorer");
        return new InternetExplorerDriver();
    }

    if ("safari".equalsIgnoreCase(browser)) {
        LOGGER.debug("Using Safari");
        return new SafariDriver();
    }

    throw new IllegalArgumentException("Unknown browser : " + browser);
}
项目:Testy    文件:WebDriverConfig.java   
public static void init(WebDriver driver) {
    if (driver != null) {
        LOGGER.info("===============================================================");
        LOGGER.info("|          Open Selenium Web Driver ");
        LOGGER.info("===============================================================\n");
        WebDriverConfig.driver = driver;
        WebLocator.setDriverExecutor(driver);
        if (driver instanceof InternetExplorerDriver) {
            isIE = true;
        } else if (driver instanceof ChromeDriver) {
            isChrome = true;
        } else if (driver instanceof FirefoxDriver) {
            isFireFox = true;
        } else if (driver instanceof SafariDriver) {
            isSafari = true;
        } else if (driver instanceof OperaDesktopDriver) {
            isOpera = true;
        }

        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(WebLocatorConfig.getInt("driver.implicitlyWait"), TimeUnit.MILLISECONDS);

        Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
                if (WebLocatorConfig.getBoolean("driver.autoClose")) {
                    initSeleniumEnd();
                }
            }
        });
    }
}
项目:kuali_rice    文件:WebDriverUtil.java   
/**
 * remote.public.driver set to chrome or firefox (null assumes firefox)
 * if remote.public.hub is set a RemoteWebDriver is created (Selenium Grid)
 * if proxy.host is set, the web driver is setup to use a proxy
 * @return WebDriver or null if unable to create
 */
public static WebDriver getWebDriver() {
    String driverParam = System.getProperty(ITUtil.HUB_DRIVER_PROPERTY);
    String hubParam = System.getProperty(ITUtil.HUB_PROPERTY);
    String proxyParam = System.getProperty(PROXY_HOST_PROPERTY);

    // setup proxy if specified as VM Arg
    DesiredCapabilities capabilities = new DesiredCapabilities();
    WebDriver webDriver = null;
    if (StringUtils.isNotEmpty(proxyParam)) {
        capabilities.setCapability(CapabilityType.PROXY, new Proxy().setHttpProxy(proxyParam));
    }

    if (hubParam == null) {
        if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
            FirefoxProfile profile = new FirefoxProfile();
            profile.setEnableNativeEvents(false);
            capabilities.setCapability(FirefoxDriver.PROFILE, profile);
            return new FirefoxDriver(capabilities);
        } else if ("chrome".equalsIgnoreCase(driverParam)) {
            return new ChromeDriver(capabilities);
        } else if ("safari".equals(driverParam)) {
            System.out.println("SafariDriver probably won't work, if it does please contact Erik M.");
            return new SafariDriver(capabilities);
        }
    } else {
        try {
            if (driverParam == null || "firefox".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(ITUtil.getHubUrlString()), DesiredCapabilities.firefox());
            } else if ("chrome".equalsIgnoreCase(driverParam)) {
                return new RemoteWebDriver(new URL(ITUtil.getHubUrlString()), DesiredCapabilities.chrome());
            }
        } catch (MalformedURLException mue) {
            System.out.println(ITUtil.getHubUrlString() + " " + mue.getMessage());
            mue.printStackTrace();
        }
    }
    return null;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:WebDriverAutoConfigurationTests.java   
@Bean
SafariDriverFactory safariDriverFactory() {
    SafariDriverFactory factory = mock(SafariDriverFactory.class);
    given(factory.getObject()).willReturn(mock(SafariDriver.class));
    return factory;
}
项目:functional-programming-selenium-examples    文件:Safari.java   
@Override
public WebDriver getWebDriver()
{
    WebDriver driver = new SafariDriver();
       return driver;
}
项目:givemeadriver    文件:SafariDriverFactory.java   
@Override
public WebDriver createDriver(Capabilities capabilities) {
    return new SafariDriver((SafariOptions) capabilities);
}
项目:selenium-jupiter    文件:ForcedSafariJupiterTest.java   
@Test
public void safariTest(SafariDriver driver) {
    assumeFalse(IS_OS_MAC);
    assertThat(driver, nullValue());
}
项目:selenium-jupiter    文件:SafariWithGlobalOptionsJupiterTest.java   
@Test
public void safariTest(SafariDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("A JUnit 5 extension for Selenium WebDriver"));
}
项目:selenium-jupiter    文件:SafariJupiterTest.java   
@Test
public void test(SafariDriver driver) {
    driver.get("http://www.seleniumhq.org/");
    assertThat(driver.getTitle(),
            containsString("A JUnit 5 extension for Selenium WebDriver"));
}
项目:pageobjects    文件:DriversTest.java   
@Test
@Ignore
public void testSafariDriver() throws Exception {
    assumeTrue(System.getenv("Path").contains("Safari"));
    assertTrue(Drivers.SAFARI.get() instanceof SafariDriver);
}