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


Java Platform类代码示例

本文整理汇总了Java中org.openqa.selenium.Platform的典型用法代码示例。如果您正苦于以下问题:Java Platform类的具体用法?Java Platform怎么用?Java Platform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Platform类属于org.openqa.selenium包,在下文中一共展示了Platform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSauce

import org.openqa.selenium.Platform; //导入依赖的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

示例2: onPosix

import org.openqa.selenium.Platform; //导入依赖的package包/类
private boolean onPosix() {
	Platform current = Platform.getCurrent();
	switch (current) {
		case LINUX:
		case UNIX:
			return true;
		case MAC:
		case ANY:
		case VISTA:
		case WINDOWS:
		case XP:
		case ANDROID:
		default:
			return false;
	}
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:17,代码来源:FirefoxLinuxCrash.java

示例3: findCommand

import org.openqa.selenium.Platform; //导入依赖的package包/类
public String findCommand(String command) {
    if (vmCommand != null) {
        return vmCommand;
    }
    if (javaHome != null) {
        File homeFolder = new File(javaHome);
        if (!homeFolder.exists() || !homeFolder.isDirectory()) {
            throw new WebDriverException(String.format("%s: No such directory", homeFolder));
        }
        File binFolder = new File(javaHome, "bin");
        if (!binFolder.exists() || !binFolder.isDirectory()) {
            throw new WebDriverException(String.format("%s: No bin directory found in home directory", binFolder));
        }
        File java = new File(binFolder, Platform.getCurrent().is(Platform.WINDOWS) ? command + ".exe" : command);
        if (!java.exists() || !java.isFile()) {
            throw new WebDriverException(String.format("%s: No such file", java));
        }
        return java.getAbsolutePath();
    }
    return command;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:JavaProfile.java

示例4: failsWhenRequestingNonCurrentPlatform

import org.openqa.selenium.Platform; //导入依赖的package包/类
public void failsWhenRequestingNonCurrentPlatform() throws Throwable {
    Platform[] values = Platform.values();
    Platform otherPlatform = null;
    for (Platform platform : values) {
        if (Platform.getCurrent().is(platform)) {
            continue;
        }
        otherPlatform = platform;
        break;
    }
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", otherPlatform);
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:JavaDriverTest.java

示例5: shouldRetrieveBrowserDefaults

import org.openqa.selenium.Platform; //导入依赖的package包/类
@Test
public void shouldRetrieveBrowserDefaults() {
    final Map<String, String> chromeParameters = new HashMap<>();
    chromeParameters.put(BROWSER_NAME, "chrome");

    final XmlConfig config = new XmlConfig(chromeParameters);
    final Browser chrome = StreamEx.of(browsers)
                                   .findFirst(b -> b.name() == Browser.Name.Chrome)
                                   .orElseThrow(() -> new AssertionError("Unable to retrieve Chrome"));

    assertThat(chrome.isRemote()).isFalse();
    assertThat(chrome.url()).isEqualTo("http://localhost:4444/wd/hub");
    assertThat(chrome.defaultConfiguration(config))
            .extracting(Capabilities::getBrowserName)
            .containsExactly("chrome");
    assertThat(chrome.defaultConfiguration(config))
            .extracting(Capabilities::getVersion)
            .containsExactly("");
    assertThat(chrome.defaultConfiguration(config))
            .extracting(Capabilities::getPlatform)
            .containsExactly(Platform.getCurrent());
    assertThat(chrome.configuration(config)).isEqualTo(chrome.defaultConfiguration(config));
}
 
开发者ID:sskorol,项目名称:webdriver-supplier,代码行数:24,代码来源:CoreTests.java

示例6: createNullFile

import org.openqa.selenium.Platform; //导入依赖的package包/类
public static int createNullFile( Path file, long size ) throws IOException, InterruptedException
{
    if( Platform.getCurrent().equals( Platform.LINUX ) || Platform.getCurrent().equals( Platform.MAC ) )
    {
        final String CMD = String.format( "dd if=/dev/zero of=%s count=1024 bs=%d", file, size / 1024 );
        Process process = Runtime.getRuntime().exec( CMD );
        BufferedReader input = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
        String processBuffer;
        while ( ( processBuffer = input.readLine() ) != null )
        {
            logger.debug( "create null file: {}", processBuffer );
        }
        input.close();
        return process.waitFor();
    }

    throw new NotImplementedException();
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:19,代码来源:FileUtils.java

示例7: createTextFile

import org.openqa.selenium.Platform; //导入依赖的package包/类
public static int createTextFile( Path file, long size ) throws IOException, InterruptedException
{
    if( Platform.getCurrent().equals( Platform.LINUX ) || Platform.getCurrent().equals( Platform.MAC ) )
    {
        final String CMD = String.format( "dd if=/dev/urandom of=%s count=1024 bs=%d", file, size / 1024 );
        Process process = Runtime.getRuntime().exec( CMD );
        BufferedReader input = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
        String processBuffer;
        while ( ( processBuffer = input.readLine() ) != null )
        {
            logger.debug( "create text file: {}", processBuffer );
        }
        input.close();
        return process.waitFor();

    }

    throw new NotImplementedException();
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:20,代码来源:FileUtils.java

示例8: setCapabilities

import org.openqa.selenium.Platform; //导入依赖的package包/类
/**
 * This method sets the browser capability to the Desired Capabilities
 * @param Object - current device Object value
 * @param DesiredCapabilities
 * @param String - name of the option
 * @return DesiredCapabilities
 */
@SuppressWarnings("unchecked")
protected DesiredCapabilities setCapabilities(Object value, DesiredCapabilities dc, String name) {
	if (value instanceof Boolean)
	{
		dc.setCapability( name, value );
	}
	
	else if (value instanceof String) 
	{
		dc.setCapability( name, value );
	}
	
	else if (value instanceof Platform) 
	{
		dc.setCapability( name, value );
	}
	
	else if (value instanceof Map) 
	{
		dc = BrowserCapabilityManager.instance().getBrowsercapabilityFactory(name)
				.createBrowserOptions(dc, (Map<String,Object>)value);
	}
	return dc;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:32,代码来源:AbstractDriverFactory.java

示例9: getValue

import org.openqa.selenium.Platform; //导入依赖的package包/类
private Object getValue( String clazz, String value )
{
    Object rtn = null;

    switch ( clazz )
    {
        case "BOOLEAN":
            rtn = Boolean.parseBoolean( value );
            break;
            
        case "OBJECT":
            rtn = value;
            break;
            
        case "STRING":
            rtn = value;
            break;
            
        case "PLATFORM":
            rtn = ((value != null) ? Platform.valueOf( value.toUpperCase() ) : null );
            break;
    }

    return rtn;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:26,代码来源:SQLApplicationProvider.java

示例10: capabilitiesAreSetWhenCreatingBrowser

import org.openqa.selenium.Platform; //导入依赖的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: setVersionAndPlatform

import org.openqa.selenium.Platform; //导入依赖的package包/类
private static DesiredCapabilities setVersionAndPlatform(
		DesiredCapabilities capability, String version, String platform) {
	if (MAC.equalsIgnoreCase(platform)) {
		capability.setPlatform(Platform.MAC);
	} else if (LINUX.equalsIgnoreCase(platform)) {
		capability.setPlatform(Platform.LINUX);
	} else if (XP.equalsIgnoreCase(platform)) {
		capability.setPlatform(Platform.XP);
	} else if (VISTA.equalsIgnoreCase(platform)) {
		capability.setPlatform(Platform.VISTA);
	} else if (WINDOWS.equalsIgnoreCase(platform)) {
		capability.setPlatform(Platform.WINDOWS);
	} else if (ANDROID.equalsIgnoreCase(platform)) {
		capability.setPlatform(Platform.ANDROID);
	} else {
		capability.setPlatform(Platform.ANY);
	}

	if (version != null) {
		capability.setVersion(version);
	}
	return capability;
}
 
开发者ID:ViliamS,项目名称:XPathBuilder,代码行数:24,代码来源:WebDriverFactory.java

示例12: getDriver

import org.openqa.selenium.Platform; //导入依赖的package包/类
/**
 * Creates a new webdriver instance for your test.
 * @return WebDriver that has been configured to execute the specified platform and browser.
 * @throws MalformedURLException
 */
private WebDriver getDriver() throws MalformedURLException{
	URL server 							= new URL("http://localhost:4444/wd/hub");
	DesiredCapabilities capababilities 	= new DesiredCapabilities();
	
	// Set your OS (platform) here.
	capababilities.setPlatform(Platform.MAC);
	// Set your Browser here.
	capababilities.setBrowserName("chrome");
	// Set your Browser version here. This should be a number.
	capababilities.setVersion("58");
	capababilities.setJavascriptEnabled(true);
	
	RemoteWebDriver ret = new RemoteWebDriver(server, capababilities);
	ret.navigate().to("https://www.amazon.com/");
	return ret;
}
 
开发者ID:jmastri,项目名称:automata,代码行数:22,代码来源:SampleTest.java

示例13: onException

import org.openqa.selenium.Platform; //导入依赖的package包/类
@Override
public void onException(Throwable throwable, WebDriver driver) {
  if (Platform.getCurrent().is(Platform.ANDROID)) {
    // Android Java APIs do not support java.awt
    return;
  }
  String encoded;
  try {
    workAroundD3dBugInVista();

    Rectangle size = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    BufferedImage image = new Robot().createScreenCapture(size);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ImageIO.write(image, "png", outputStream);

    encoded = new Base64Encoder().encode(outputStream.toByteArray());

    session.attachScreenshot(encoded);
  } catch (Throwable e) {
    // Alright. No screen shot. Propogate the original exception
  }
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:24,代码来源:SnapshotScreenListener.java

示例14: testInitializeCapabilitiesFromProperties

import org.openqa.selenium.Platform; //导入依赖的package包/类
@Test
public void testInitializeCapabilitiesFromProperties() throws IOException {
    ClassLoader classLoader = getClass().getClassLoader();
    File origin = new File(classLoader.getResource("converttest.yaml").getFile());
    File dest = folder.newFile();
    FileUtils.copyFile(origin, dest);

    Properties example = new Properties();
    example.setProperty("CAPABILITIES", dest.getCanonicalPath());
    TestRunnerConfig config = TestRunnerConfig.initialize(example);
    Assert.assertEquals("chrome", config.capabilities().getBrowserName());
    Assert.assertEquals("1280x1024", config.capabilities().getCapability("screenResolution"));
    Assert.assertEquals("47.0", config.capabilities().getVersion());
    Assert.assertEquals(Platform.fromString("OS X 10.10"), config.capabilities().getPlatform());

}
 
开发者ID:relateiq,项目名称:AugmentedDriver,代码行数:17,代码来源:TestRunnerConfigTest.java

示例15: testFormat_selector

import org.openqa.selenium.Platform; //导入依赖的package包/类
/**
 * 通常のフォーマットテスト(セレクタ)
 */
@Test
public void testFormat_selector() throws Exception {
	PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
	capabilities.setPlatform(Platform.WINDOWS);
	capabilities.setBrowserName("firefox");
	capabilities.setVersion("38");

	PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId",
			new IndexDomSelector(SelectorType.TAG_NAME, "body", 1), null, capabilities);

	FileNameFormatter formatter = new FileNameFormatter(
			"{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
	String result = formatter.format(metadata);
	assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_TAG_NAME_body_[1].png"));
}
 
开发者ID:hifive,项目名称:hifive-pitalium,代码行数:19,代码来源:FileNameFormatterTest.java


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