本文整理匯總了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());
}