當前位置: 首頁>>代碼示例>>Java>>正文


Java CapabilityType類代碼示例

本文整理匯總了Java中org.openqa.selenium.remote.CapabilityType的典型用法代碼示例。如果您正苦於以下問題:Java CapabilityType類的具體用法?Java CapabilityType怎麽用?Java CapabilityType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CapabilityType類屬於org.openqa.selenium.remote包,在下文中一共展示了CapabilityType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createPhantomJSDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
private static WebDriver createPhantomJSDriver(String driverPath) {

		DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();
		desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, driverPath);
		desiredCapabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, true);
		desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
		desiredCapabilities.setCapability(CapabilityType.ENABLE_PROFILING_CAPABILITY, true);
		desiredCapabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true);

		desiredCapabilities.setJavascriptEnabled(true);

		ArrayList<String> cliArgs = new ArrayList<String>();
		cliArgs.add("--web-security=true");
		cliArgs.add("--ignore-ssl-errors=true");
		desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);

		return new PhantomJSDriver(desiredCapabilities);
	}
 
開發者ID:entelgy-brasil,項目名稱:zucchini,代碼行數:19,代碼來源:SeleniumDriver.java

示例2: createSauce

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
    final DesiredCapabilities capabilities = new DesiredCapabilities ();
    capabilities.setBrowserName ( browser );
    if ( version != null )
    {
        capabilities.setVersion ( version );
    }
    capabilities.setCapability ( CapabilityType.PLATFORM, os );
    capabilities.setCapability ( CapabilityType.SUPPORTS_FINDING_BY_CSS, true );
    capabilities.setCapability ( "name", "Eclipse Package Drone Main Test" );

    if ( System.getenv ( "TRAVIS_JOB_NUMBER" ) != null )
    {
        capabilities.setCapability ( "tunnel-identifier", System.getenv ( "TRAVIS_JOB_NUMBER" ) );
        capabilities.setCapability ( "build", System.getenv ( "TRAVIS_BUILD_NUMBER" ) );
        capabilities.setCapability ( "tags", new String[] { "CI" } );
    }

    final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%[email protected]%s/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY, SAUCE_URL ) ), capabilities );

    driver.setFileDetector ( new LocalFileDetector () );

    return driver;
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:26,代碼來源:TestSuite.java

示例3: getPerformanceLoggingCapabilities

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
private static DesiredCapabilities getPerformanceLoggingCapabilities() {
    DesiredCapabilities caps = DesiredCapabilities.chrome();

    // Enable performance logging
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
    caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

    // Enable timeline tracing
    Map<String, Object> chromeOptions = new HashMap<String, Object>();
    Map<String, String> perfLoggingPrefs = new HashMap<String, String>();
    // Tracing categories, please note NO SPACE NEEDED after the commas
    perfLoggingPrefs.put("traceCategories", "blink.console,disabled-by-default-devtools.timeline");
    chromeOptions.put("perfLoggingPrefs", perfLoggingPrefs);
    //chromeOptions.put("debuggerAddress", "127.0.0.1:10134");
    caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    return caps;
}
 
開發者ID:hy9be,項目名稱:spa-perf,代碼行數:20,代碼來源:SPAPerfChromeDriver.java

示例4: generatePhantomJsDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
/**
 * Generates a phantomJs webdriver.
 *
 * @return
 *         A phantomJs webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generatePhantomJsDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.PHANTOMJS);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Phantomjs driver ({}) ...", pathWebdriver);

    final DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX + "Accept-Language", "fr-FR");
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, pathWebdriver);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setJavascriptEnabled(true);

    setLoggingLevel(capabilities);

    // Proxy configuration
    String proxy = "";
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        proxy = Context.getProxy().getHttpProxy();
    }
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
            new String[] { "--proxy=" + proxy, "--web-security=no", "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--webdriver-loglevel=NONE" });
    return new PhantomJSDriver(capabilities);
}
 
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:33,代碼來源:DriverFactory.java

示例5: generateHtmlUnitDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
/**
 * Generates a htmlunit webdriver.
 *
 * @return
 *         A htmlunit webdriver
 */
private WebDriver generateHtmlUnitDriver() {
    logger.info("Generating HtmlUnit driver...");
    final DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setJavascriptEnabled(true);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }
    return new HtmlUnitDriver(capabilities);
}
 
開發者ID:NoraUi,項目名稱:NoraUi,代碼行數:22,代碼來源:DriverFactory.java

示例6: createDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    Map<String, Object> preferences = new Hashtable<>();
    preferences.put("profile.default_content_settings.popups", 0);
    preferences.put("download.prompt_for_download", "false");
    String downloadsPath = System.getProperty("user.home") + "/Downloads";
    preferences.put("download.default_directory", loadSystemPropertyOrDefault("fileDownloadPath", downloadsPath));
    preferences.put("plugins.plugins_disabled", new String[]{
            "Adobe Flash Player", "Chrome PDF Viewer"});
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", preferences);

    capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    return new ChromeDriver(capabilities);
}
 
開發者ID:alfa-laboratory,項目名稱:akita-testing-template,代碼行數:18,代碼來源:AkitaChromeDriverProvider.java

示例7: newDriverForTest

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
private WebDriver newDriverForTest() {
    ChromeOptions theOptions = new ChromeOptions();
    theOptions.addArguments("headless");
    theOptions.addArguments("disable-gpu");

    LoggingPreferences theLoggingPreferences = new LoggingPreferences();
    theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
    theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);

    DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
    theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);

    return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
 
開發者ID:mirkosertic,項目名稱:Bytecoder,代碼行數:15,代碼來源:BytecoderUnitTestRunner.java

示例8: initIEDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
private WebDriver initIEDriver(String appURL) {
	System.out.println("Launching IE browser..");
	DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
	ieCapabilities.setJavascriptEnabled(true); 
	ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,   
			true); 
	ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); 
	ieCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true);         
	ieCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.DISMISS); //Accept unexpected alerts 
	ieCapabilities.setCapability("requireWindowFocus", true); 
	ieCapabilities.setCapability("enablePersistentHover", false); 
	ieCapabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
	
	WebDriver driver=new InternetExplorerDriver(ieCapabilities);
	driver.manage().deleteAllCookies();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    for(String winHandle : driver.getWindowHandles()){
       driver =  driver.switchTo().window(winHandle);
    }
    driver.get(appURL);
	return new WebDriverProxy().protect(driver);
}
 
開發者ID:3pillarlabs,項目名稱:AutomationFrameworkTPG,代碼行數:23,代碼來源:DriverProperties.java

示例9: get64IEDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
public static WebDriver get64IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer64.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(CapabilityType.BROWSER_NAME, "IE");
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);

	return new InternetExplorerDriver(caps);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:11,代碼來源:SeleniumTestUtilities.java

示例10: capabilitiesAreSetWhenCreatingBrowser

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
@Test
public void capabilitiesAreSetWhenCreatingBrowser() throws MalformedURLException {

    given(configuration.getRemoteBrowserName()).willReturn("firefox");
    given(configuration.getRemoteBrowserVersion()).willReturn("46.0.1");
    given(configuration.getRemoteFirefoxMarionette()).willReturn(true);
    given(configuration.getRemoteHost()).willReturn("localhost");
    given(configuration.getRemotePort()).willReturn(4444);

    cut.createBrowser();

    then(webDriverProducer).should().apply(urlCaptor.capture(), capabilitiesCaptor.capture());

    URL url = urlCaptor.getValue();
    assertThat(url).hasProtocol("http").hasHost("localhost").hasPort(4444).hasPath("/wd/hub");

    DesiredCapabilities capabilities = capabilitiesCaptor.getValue();
    assertThat(capabilities.getCapability(CapabilityType.BROWSER_NAME)).isEqualTo("firefox");
    assertThat(capabilities.getCapability(CapabilityType.VERSION)).isEqualTo("46.0.1");
    assertThat(capabilities.getCapability(CapabilityType.PLATFORM)).isEqualTo(Platform.ANY);
    assertThat(capabilities.getCapability(CapabilityType.HAS_NATIVE_EVENTS)).isEqualTo(false);
    assertThat(capabilities.getCapability(CapabilityType.ACCEPT_SSL_CERTS)).isEqualTo(true);
    assertThat(capabilities.getCapability("marionette")).isEqualTo(true);

}
 
開發者ID:testIT-WebTester,項目名稱:webtester2-core,代碼行數:26,代碼來源:RemoteFactoryTest.java

示例11: setUp

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    Configuration.load();
    Configuration.print();
    
    System.setProperty("webdriver.gecko.driver", new File("drivers/geckodriver").getAbsolutePath());
    System.setProperty("webdriver.chrome.driver", new File("drivers/chromedriver").getAbsolutePath());
    
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability(CapabilityType.BROWSER_NAME, "");
    cap.setCapability("platformVersion", Configuration.get("app_platformVersion"));
    cap.setCapability("platformName", "Android");
    cap.setCapability("app", new File(Configuration.get("app_path")).getAbsolutePath());
    cap.setCapability("deviceName", "Any");
    cap.setCapability("commandTimeout", "60");
    if (Configuration.platform().isWeb()) {
        Driver.add(Configuration.get("browser"), cap);
    } else {
        Driver.add(Configuration.get("driver_url"), Configuration.get("browser"), cap);
    }
    searchPage = PageFactory.init(SearchPage.class);
    searchPage.navigate();
}
 
開發者ID:mkolisnyk,項目名稱:0686OS,代碼行數:24,代碼來源:TestCommon.java

示例12: getWebClient

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
private WebDriver getWebClient(int portForJSCoverProxy) {
    Proxy proxy = new Proxy().setHttpProxy("localhost:" + portForJSCoverProxy);
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(CapabilityType.PROXY, proxy);
    caps.setJavascriptEnabled(true);
    caps.setBrowserName(BrowserType.HTMLUNIT);
    return new HtmlUnitDriver(caps) {
        @Override
        protected WebClient modifyWebClient(WebClient client) {
            client.setScriptPreProcessor((htmlPage, sourceCode, sourceName, lineNumber, htmlElement) -> {
                if(removeJsSnippets != null && !removeJsSnippets.isEmpty()) {
                    for(String toReplace : removeJsSnippets) {
                        sourceCode = sourceCode.replace(toReplace, "");
                    }
                    return sourceCode;
                } else {
                    return sourceCode;
                }

            });
            return client;
        }
    };
}
 
開發者ID:digitalfondue,項目名稱:jscoverproxy-maven-plugin,代碼行數:25,代碼來源:JSCoverProxyMavenMojo.java

示例13: createWebDriver

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
@Override
public WebCommunicationWrapper createWebDriver(ProxyServerWrapper proxyServer)
    throws WorkerException {
  try {
    Proxy proxy = proxyServer.seleniumProxy();
    proxyServer.setCaptureContent(true);
    proxyServer.setCaptureHeaders(true);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    FirefoxProfile fp = getFirefoxProfile();
    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);
    capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

    return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), proxyServer,
        requestExecutorFactory
            .createInstance());
  } catch (Exception e) {
    throw new WorkerException(e.getMessage(), e);
  }
}
 
開發者ID:Cognifide,項目名稱:aet,代碼行數:25,代碼來源:FirefoxWebDriverFactory.java

示例14: createCapabilities

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {
    final DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("automationName", cfg.getAutomationName());
    capabilities.setCapability("platformName", cfg.getMobilePlatformName());

    // Set up version and device name else appium server would pick the only available emulator/device
    // Both of these are ignored for android for now
    capabilities.setCapability("platformVersion", cfg.getMobilePlatformVersion());
    capabilities.setCapability("deviceName", cfg.getDeviceName());

    capabilities.setCapability("app", cfg.getApp());
    capabilities.setCapability("appPackage", cfg.getAppPackage());
    capabilities.setCapability("appActivity", cfg.getAppActivity());

    capabilities.setCapability(CapabilityType.BROWSER_NAME, cfg.getBrowserName());
    capabilities.setCapability("newCommandTimeout", cfg.getNewCommandTimeout());

    return capabilities;
}
 
開發者ID:tarun3kumar,項目名稱:seleniumtestsframework,代碼行數:21,代碼來源:IOsCapabilitiesFactory.java

示例15: createCapabilities

import org.openqa.selenium.remote.CapabilityType; //導入依賴的package包/類
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("automationName", cfg.getAutomationName());
    capabilities.setCapability("platformName", cfg.getMobilePlatformName());

    // Set up version and device name else appium server would pick the only available emulator/device
    // Both of these are ignored for android for now
    capabilities.setCapability("platformVersion", cfg.getMobilePlatformVersion());
    capabilities.setCapability("deviceName", cfg.getDeviceName());

    capabilities.setCapability("app", cfg.getApp());
    capabilities.setCapability("appPackage", cfg.getAppPackage());
    capabilities.setCapability("appActivity", cfg.getAppActivity());

    capabilities.setCapability(CapabilityType.BROWSER_NAME, cfg.getBrowserName());
    capabilities.setCapability("newCommandTimeout", cfg.getNewCommandTimeout());

    return capabilities;
}
 
開發者ID:tarun3kumar,項目名稱:seleniumtestsframework,代碼行數:21,代碼來源:IPhoneCapabilitiesFactory.java


注:本文中的org.openqa.selenium.remote.CapabilityType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。