当前位置: 首页>>代码示例>>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;未经允许,请勿转载。