Example usage for org.openqa.selenium Platform MAC

List of usage examples for org.openqa.selenium Platform MAC

Introduction

In this page you can find the example usage for org.openqa.selenium Platform MAC.

Prototype

Platform MAC

To view the source code for org.openqa.selenium Platform MAC.

Click Source Link

Usage

From source file:RunIpadAcceptanceTests.java

License:Apache License

@BeforeClass
public static void setupSquashWebsiteUrl() {
    Platform current = Platform.getCurrent();
    Assert.assertTrue("Safari can be used only on MAC and Windows platforms",
            Platform.MAC.is(current) || Platform.WINDOWS.is(current));

    Properties p = new Properties(System.getProperties());
    p.setProperty("SquashWebsiteBaseUrl",
            "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-16.html");
    // This will be read before each scenario to set up the webdriver
    p.setProperty("WebDriverType", "Ipad");
    p.setProperty("WebDriverJavascriptEnabled", "true");
    System.setProperties(p);/*from   w  w w  .j  ava2 s.c o m*/
}

From source file:ExperimentRunner.java

License:Apache License

private static boolean isSupportedPlatform() {
    Platform current = Platform.getCurrent();
    return Platform.MAC.is(current) || Platform.WINDOWS.is(current);
}

From source file:RunFirefoxAcceptanceTests.java

License:Apache License

@BeforeClass
public static void setupSquashWebsiteUrl() {
    Platform current = Platform.getCurrent();
    Assert.assertTrue("Safari can be used only on MAC and Windows platforms",
            Platform.MAC.is(current) || Platform.WINDOWS.is(current));

    Properties p = new Properties(System.getProperties());
    p.setProperty("SquashWebsiteBaseUrl",
            "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-11.html");
    // This will be read before each scenario to set up the webdriver
    p.setProperty("WebDriverType", "Firefox");
    p.setProperty("webdriver.firefox.bin", "/Applications/Firefox.app/Contents/MacOS/firefox-bin");
    p.setProperty("WebDriverJavascriptEnabled", "true");
    System.setProperties(p);/*  w w w . ja  va  2s  .c  o  m*/
}

From source file:WebTestSelenium8.java

public void setUp() throws Exception {
    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("version", "11");
    capabilities.setCapability("platform", Platform.MAC);
    capabilities.setCapability("name", "Testing Selenium 2");
    try {//from   w w  w .  j a  v a  2s. com
        this.driver = new RemoteWebDriver(new URL(URL), capabilities);
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    } catch (Exception ex) {
        System.out.println("Driver problem");
    }
    this.driver.get("http://www.yale.edu");
}

From source file:RunSafariAcceptanceTests.java

License:Apache License

@BeforeClass
public static void setupSquashWebsiteUrl() {
    Platform current = Platform.getCurrent();
    Assert.assertTrue("Safari can be used only on MAC and Windows platforms",
            Platform.MAC.is(current) || Platform.WINDOWS.is(current));

    Properties p = new Properties(System.getProperties());
    p.setProperty("SquashWebsiteBaseUrl",
            "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-11.html");
    // This will be read before each scenario to set up the webdriver
    p.setProperty("WebDriverType", "Safari");
    p.setProperty("WebDriverJavascriptEnabled", "true");
    System.setProperties(p);// www  .j  a  v  a 2  s . c om
}

From source file:com.atlassian.selenium.browsers.firefox.DisplayAwareFirefoxChromeLauncher.java

License:Apache License

protected CommandLine prepareCommand(String... commands) {
    CommandLine command = new CommandLine(commands);
    command.setEnvironmentVariable("MOZ_NO_REMOTE", "1");

    // don't set the library path on Snow Leopard
    Platform platform = Platform.getCurrent();
    if (!platform.is(Platform.MAC) || ((platform.is(Platform.MAC)) && platform.getMajorVersion() <= 10
            && platform.getMinorVersion() <= 5)) {
        command.setDynamicLibraryPath(browserInstallation.libraryPath());
    }//from  www  .  j  a v a  2s.  c om

    if (System.getProperty("DISPLAY") != null) {
        command.setEnvironmentVariable("DISPLAY", System.getProperty("DISPLAY"));
    }

    return command;
}

From source file:com.htmlhifive.pitalium.core.selenium.PtlWebDriverFactory.java

License:Apache License

/**
 * ??{@link PtlWebDriverFactory}?????/*from w w w  .  j ava  2  s . c  o m*/
 * 
 * @param capabilities Capability??
 * @return {@link PtlWebDriverFactory}?
 */
public static PtlWebDriverFactory getInstance(PtlCapabilities capabilities) {
    PtlTestConfig config = PtlTestConfig.getInstance();
    EnvironmentConfig environmentConfig = config.getEnvironment();
    TestAppConfig testAppConfig = config.getTestAppConfig();

    String browserName = Strings.nullToEmpty(capabilities.getBrowserName()).toLowerCase(Locale.ENGLISH);

    // IE
    if ("internet explorer".equals(browserName)) {
        String version = Strings.nullToEmpty(capabilities.getVersion());
        if (version.startsWith("7")) {
            return new PtlInternetExplorer7DriverFactory(environmentConfig, testAppConfig, capabilities);
        }
        if (version.startsWith("8")) {
            return new PtlInternetExplorer8DriverFactory(environmentConfig, testAppConfig, capabilities);
        }

        return new PtlInternetExplorerDriverFactory(environmentConfig, testAppConfig, capabilities);
    }

    // Edge
    if ("microsoftedge".equals(browserName)) {
        return new PtlEdgeDriverFactory(environmentConfig, testAppConfig, capabilities);
    }

    // Android
    if (capabilities.getPlatform() == Platform.ANDROID) {
        // Selendroid (Android 2.3+)
        String automationName = (String) capabilities.getCapability("automationName");
        if (automationName != null && "selendroid".equalsIgnoreCase(automationName)) {
            return new PtlSelendroidDriverFactory(environmentConfig, testAppConfig, capabilities);
        }

        // Default (Android 4.2+)
        return new PtlAndroidDriverFactory(environmentConfig, testAppConfig, capabilities);
    }

    // Chrome
    if ("chrome".equals(browserName)) {
        return new PtlChromeWebDriverFactory(environmentConfig, testAppConfig, capabilities);
    }

    // Safari
    if ("safari".equals(browserName)) {
        // MacOSX
        if (capabilities.getPlatform() == Platform.MAC) {
            return new PtlSafariDriverFactory(environmentConfig, testAppConfig, capabilities);
        }

        String deviceName = capabilities.getDeviceName();
        if (Strings.isNullOrEmpty(deviceName)) {
            throw new TestRuntimeException("\"deviceName\" is required for iOS devices");
        }
        if (deviceName.contains("iPad")) {
            return new PtlIPadDriverFactory(environmentConfig, testAppConfig, capabilities);
        }
        if (deviceName.contains("iPhone")) {
            return new PtlIPhoneDriverFactory(environmentConfig, testAppConfig, capabilities);
        }

        throw new TestRuntimeException("Unknown deviceName \"" + deviceName + "\"");
    }

    // Other
    return new PtlFirefoxWebDriverFactory(environmentConfig, testAppConfig, capabilities);
}

From source file:com.opera.core.systems.runner.AbstractOperaRunner.java

License:Apache License

public AbstractOperaRunner(OperaSettings s) {
    settings = s;//from  ww w .j  a va2  s  .  co  m

    // Find a suitable Opera executable based on requested product if no binary has already been
    // specified
    if (settings.getBinary() == null) {
        // Do check for null here since OperaBinary's sanitization throws a cryptic null pointer
        File binary = OperaBinary.find(settings.getProduct());
        if (binary == null) {
            throw new OperaRunnerException(
                    String.format("Unable to find executable for product %s", settings.getProduct()));
        }

        // Calls new OperaBinary(b) which will check that the binary is executable and that it's not a
        // directory
        settings.setBinary(binary);
    }

    // This can't be last, otherwise it might get interpreted as the page to open, and the file
    // listing page doesn't have a JS context to inject into.

    // Only append -pd if compatibility mode is enabled (for Opera < 11.60)
    if (settings.supportsPd()) {
        settings.arguments().add("-pd", settings.profile().getDirectory().getAbsolutePath());
    }

    // If port is set to -1 it means we're in compatibility mode as Opera < 11.60 does not support
    // the -debugproxy command-line argument.  It will instead use the default port 7001.
    if (settings.supportsDebugProxy()) {
        settings.arguments().add("debugproxy", settings.getHost() + ":" + settings.getPort());
    }

    settings.arguments().add("autotestmode");

    // Hack - if we are testing desktop mac the fullscreen argument must be after -pd
    // otherwise the pd setting does not have any effect. So putting it last.
    if (settings.getProduct().is(DESKTOP) && Platform.getCurrent().is(Platform.MAC)) {
        OperaArgument fullscreen = new OperaArgument("fullscreen");
        settings.arguments().remove(fullscreen);
        settings.arguments().add(fullscreen);
    }

    logger.config("Opera arguments: " + settings.arguments().getArgumentsAsStringList());
}

From source file:com.opera.core.systems.runner.launcher.OperaLauncherRunnerSettings.java

License:Apache License

/**
 * Makes the launcher executable by chmod'ing the file at given path (GNU/Linux and Mac only).
 *
 * @param launcher the file to make executable
 *//*  w  ww  .j  a v a  2s.  c  o  m*/
private static void makeLauncherExecutable(File launcher) {
    Platform current = Platform.getCurrent();

    if (current.is(Platform.UNIX) || current.is(Platform.MAC)) {
        CommandLine line = new CommandLine("chmod", "u+x", launcher.getAbsolutePath());
        line.execute();
    }
}

From source file:com.photon.phresco.Screens.BaseScreen.java

License:Apache License

public void instantiateBrowser(String selectedBrowser, String selectedPlatform, String applicationURL,
        String applicationContext) throws ScreenException, MalformedURLException {

    URL server = new URL("http://localhost:4444/wd/hub/");
    if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_CHROME)) {
        log.info("-------------***LAUNCHING GOOGLECHROME***--------------");
        try {/*w w w . j  ava2s. co m*/

            capabilities = new DesiredCapabilities();
            capabilities.setBrowserName("chrome");

        } catch (Exception e) {
            e.printStackTrace();
        }

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_IE)) {
        log.info("---------------***LAUNCHING INTERNET EXPLORE***-----------");
        try {
            capabilities = new DesiredCapabilities();
            capabilities.setJavascriptEnabled(true);
            capabilities.setBrowserName("iexplorer");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_OPERA)) {
        log.info("-------------***LAUNCHING OPERA***--------------");
        try {

            capabilities = new DesiredCapabilities();
            capabilities.setBrowserName("opera");
            capabilities.setCapability("opera.autostart ", true);

            System.out.println("-----------checking the OPERA-------");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_SAFARI)) {
        log.info("-------------***LAUNCHING SAFARI***--------------");
        try {
            capabilities = new DesiredCapabilities();
            capabilities.setBrowserName("safari");
            /*   capabilities.setCapability("safari.autostart ", true);*/
            System.out.println("-----------checking the SAFARI-------");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_FIREFOX)) {
        log.info("-------------***LAUNCHING FIREFOX***--------------");
        capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("firefox");
    } else if (selectedBrowser.equalsIgnoreCase(Constants.HTML_UNIT_DRIVER)) {
        log.info("-------------***HTML_UNIT_DRIVER***--------------");
        capabilities = new DesiredCapabilities();
        capabilities.setBrowserName("htmlunit");
        /*URL server = new URL("http://testVM:4444/wd/hub");
        new RemoteWebDriver(new Url("http://testVM:4444/wd/hub");*/

        System.out.println("-----------checking the HTML_UNIT_DRIVER-------");
        // break;
        // driver = new RemoteWebDriver(server, capabilities);

    } else {
        throw new ScreenException("------Only FireFox,InternetExplore and Chrome works-----------");
    }
    if (selectedPlatform.equalsIgnoreCase("WINDOWS")) {
        capabilities.setCapability(CapabilityType.PLATFORM, Platform.WINDOWS);

    } else if (selectedPlatform.equalsIgnoreCase("LINUX")) {
        capabilities.setCapability(CapabilityType.PLATFORM, Platform.LINUX);

    } else if (selectedPlatform.equalsIgnoreCase("MAC")) {
        capabilities.setCapability(CapabilityType.PLATFORM, Platform.MAC);

    }
    driver = new RemoteWebDriver(server, capabilities);
    driver.get(applicationURL + applicationContext);

}