{
   put(DesiredCapabilities.chrome(), "org.openqa.selenium.chrome.ChromeDriver");
   put(DesiredCapabilities.firefox(), "org.openqa.selenium.firefox.FirefoxDriver");
   put(DesiredCapabilities.htmlUnit(), "org.openqa.selenium.htmlunit.HtmlUnitDriver");
   put(
       DesiredCapabilities.internetExplorer(),
       "org.openqa.selenium.ie.InternetExplorerDriver");
   put(DesiredCapabilities.opera(), "com.opera.core.systems.OperaDriver");
   put(DesiredCapabilities.safari(), "org.openqa.selenium.safari.SafariDriver");
   put(DesiredCapabilities.iphone(), "org.openqa.selenium.iphone.IPhoneDriver");
   put(DesiredCapabilities.ipad(), "org.openqa.selenium.iphone.IPhoneDriver");
   put(DesiredCapabilities.phantomjs(), "org.openqa.selenium.phantomjs.PhantomJSDriver");
 }
Пример #2
0
  @BeforeMethod
  public void browserOpen(Method method) throws IOException {
    Browser = "FF";
    if (Browser.equalsIgnoreCase("ff")) {
      driver = new FirefoxDriver();
    } else if (Browser.equalsIgnoreCase("IE")) {
      System.setProperty(
          "webdriver.ie.driver",
          (System.getProperty("user.dir") + "\\CrossBrowserDriver\\IEDriverServer.exe"));
      DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
      dc.setCapability(
          InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
      driver = new InternetExplorerDriver(dc);
      driver.manage().deleteAllCookies();
    } else if (Browser.equalsIgnoreCase("ch")) {
      System.setProperty(
          "webdriver.chrome.driver",
          (System.getProperty("user.dir") + "\\CrossBrowserDriver\\chromedriver.exe"));
      driver = new ChromeDriver();
      System.err.println("Google Chrome is selected");
    } else if (Browser.equalsIgnoreCase("Safari")) {
      driver = new SafariDriver();
      System.err.println("Safari has been selected");
    } else if (Browser.equalsIgnoreCase("iOS")) {
      new RemoteWebDriver(new URL("http://localhost:3001/driver/hub"), DesiredCapabilities.ipad());
      System.err.println("iOS is selected To do the Cross Browser Test");
    } else {
      throw new IllegalArgumentException("The Browser Type is Undefined");
    }

    // mailBaseURL = "https://debugmail.io";
    // baseURL = "http://qa.corporaterewards.us";
    // baseURL = "http://devakrongeneralcelebrations.workstride.com";
    // //AKRON
    baseURL = "http://www.spafinder.com"; // SpaFinder
    driver.get(baseURL);

    iWait(10);
    maxPage();
    String testName = method.getName();
    String pageTitle = driver.getTitle();
    APPLICATION_LOG.debug(
        "==========================================================================================================");
    APPLICATION_LOG.debug("Test Page is: ==> " + pageTitle + " Just S-T-A-R-T-E-D");
    APPLICATION_LOG.debug("Test Method is: ==> " + testName + " Just S-T-A-R-T-E-D");
    APPLICATION_LOG.debug(
        "==========================================================================================================");
  }
  public static DesiredCapabilities of(Browser browser) {
    if (browser == null) {
      return null;
    }

    DesiredCapabilities caps;

    switch (browser) {
      case android:
      case android_real_phone:
        caps = DesiredCapabilities.android();
        break;

      case chrome:
        caps = DesiredCapabilities.chrome();
        break;

      case ff:
        caps = DesiredCapabilities.firefox();
        break;

      case htmlunit:
        caps = DesiredCapabilities.htmlUnit();
        caps.setJavascriptEnabled(false);
        break;

      case htmlunit_js:
        caps = DesiredCapabilities.htmlUnit();
        caps.setJavascriptEnabled(true);
        break;

      case ie:
        caps = DesiredCapabilities.internetExplorer();
        break;

      case opera:
        OperaProfile profile = new OperaProfile();
        profile.preferences().set("Geolocation", "Enable geolocation", true);
        // This pref allows all sites to access geolocation without prompting.
        // A 0 value would deny all sites and -1 would prompt for all sites.
        profile.preferences().set("User Prefs", "Geolocation site state", 1);

        caps = DesiredCapabilities.opera();
        caps.setCapability("opera.profile", profile);
        break;

      case opera_mobile:
        caps = DesiredCapabilities.opera();
        caps.setCapability(OperaSettings.Capability.PRODUCT.getCapability(), OperaProduct.MOBILE);
        break;

      case phantomjs:
        caps = DesiredCapabilities.phantomjs();
        break;

      case safari:
        caps = DesiredCapabilities.safari();
        break;

      case ipad:
        caps = DesiredCapabilities.ipad();
        break;

      case iphone:
        caps = DesiredCapabilities.iphone();
        break;

      default:
        throw new RuntimeException("Cannot determine browser config to use");
    }

    String version = System.getProperty("selenium.browser.version");
    if (version != null) {
      caps.setVersion(version);
    }

    caps.setCapability(HAS_NATIVE_EVENTS, Boolean.getBoolean("selenium.browser.native_events"));

    return caps;
  }