當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。