public DesiredCapabilities createCapabilities(final DriverConfig webDriverConfig) {
    DesiredCapabilities capability = null;
    capability = DesiredCapabilities.htmlUnit();

    if (webDriverConfig.isEnableJavascript()) {
      capability.setJavascriptEnabled(true);
    } else {
      capability.setJavascriptEnabled(false);
    }

    capability.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
    capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    if (webDriverConfig.getBrowserVersion() != null) {
      capability.setVersion(webDriverConfig.getBrowserVersion());
    }

    if (webDriverConfig.getWebPlatform() != null) {
      capability.setPlatform(webDriverConfig.getWebPlatform());
    }

    if (webDriverConfig.getProxyHost() != null) {
      Proxy proxy = webDriverConfig.getProxy();
      capability.setCapability(CapabilityType.PROXY, proxy);
    }

    return capability;
  }
예제 #2
0
  private void setupForSauceLabsTesting() throws Exception {
    URL url =
        new URL(
            "http://"
                + authentication.getUsername()
                + ":"
                + authentication.getAccessKey()
                + "@ondemand.saucelabs.com:80/wd/hub");
    // DesiredCapabilities capabilities = new
    // DesiredCapabilities(BrowserType.SAFARI,"latest",Platform.MAC);
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
    if (version != null) {
      capabilities.setCapability(CapabilityType.VERSION, version);
    }
    capabilities.setCapability(CapabilityType.PLATFORM, os);

    String methodName = this.name.getMethodName();
    String className = this.getClass().getSimpleName();
    capabilities.setCapability("name", className + "_" + methodName);

    this.driver = new RemoteWebDriver(url, capabilities);
    this.sessionId = (((RemoteWebDriver) driver).getSessionId()).toString();
  }
예제 #3
0
  private ResultItems myDownload(Request request, Spider spider) throws IOException {
    ResultItems resultItems = new ResultItems(request, spider);

    DesiredCapabilities cap = DesiredCapabilities.chrome();
    ChromeOptions co = new ChromeOptions();
    String userAgent = request.getUserAgent();
    co.addArguments("--user-agent=" + userAgent);
    cap.setCapability(ChromeOptions.CAPABILITY, co);

    Proxy myProxy = spider.getProxy(request);
    if (myProxy != null) {
      String proxy = myProxy.getHost() + ":" + myProxy.getPort();
      org.openqa.selenium.Proxy p = new org.openqa.selenium.Proxy();
      p.setHttpProxy(proxy).setFtpProxy(proxy).setSslProxy(proxy);
      cap.setCapability(CapabilityType.PROXY, p);
    }

    WebDriver driver = new ChromeDriver(cap);
    driver.get(request.getUrl());
    // Get the html source of the page
    String pageSource = driver.getPageSource();
    // Close the browser
    driver.quit();
    return resultItems.setResource(Jsoup.parse(pageSource, request.getUrl()));
  }
예제 #4
0
  @Before
  public void setUp() throws Exception {

    String sysprop = System.getProperty("user.dir");

    File classpathRoot = new File(System.getProperty("user.dir"));

    System.out.println("created classpathRoot");

    //
    File appDir = new File(classpathRoot, "./apps/ContactManager");

    System.out.println("created appDir");

    File app = new File(appDir, "ContactManager.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    // capabilities.setCapability("deviceName","Android Emulator");
    capabilities.setCapability("deviceName", "Android");
    capabilities.setCapability("platformVersion", "4.4");
    capabilities.setCapability("app", app.getAbsolutePath());
    capabilities.setCapability("appPackage", "com.example.android.contactmanager");
    capabilities.setCapability("appActivity", ".ContactManager");
    driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

    System.out.println("created driver");
  }
 public DesiredCapabilities getIECapabilities() {
   DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
   capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
   capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, true);
   capabilities.setCapability("requireWindowFocus", true);
   return addProxySettings(capabilities, proxy());
 }
  protected WebDriver createInstanceOf(String className) {
    try {
      DesiredCapabilities capabilities = createCommonCapabilities();
      capabilities.setJavascriptEnabled(true);
      capabilities.setCapability(TAKES_SCREENSHOT, true);
      capabilities.setCapability(ACCEPT_SSL_CERTS, true);
      capabilities.setCapability(SUPPORTS_ALERTS, true);
      if (isPhantomjs()) {
        capabilities.setCapability(
            "phantomjs.cli.args", // PhantomJSDriverService.PHANTOMJS_CLI_ARGS ==
                                  // "phantomjs.cli.args"
            new String[] {"--web-security=no", "--ignore-ssl-errors=yes"});
      }

      Class<?> clazz = Class.forName(className);
      if (WebDriverProvider.class.isAssignableFrom(clazz)) {
        return ((WebDriverProvider) clazz.newInstance()).createDriver(capabilities);
      } else {
        Constructor<?> constructor = Class.forName(className).getConstructor(Capabilities.class);
        return (WebDriver) constructor.newInstance(capabilities);
      }
    } catch (InvocationTargetException e) {
      throw runtime(e.getTargetException());
    } catch (Exception invalidClassName) {
      throw new IllegalArgumentException(invalidClassName);
    }
  }
예제 #7
0
  /**
   * Creates a new {@link RemoteWebDriver} instance to be used to run WebDriver tests using Sauce.
   *
   * @param username the Sauce username
   * @param key the Sauce access key
   * @param os the operating system to be used
   * @param browser the name of the browser to be used
   * @param browserVersion the version of the browser to be used
   * @param method the test method being executed
   * @throws Exception thrown if any errors occur in the creation of the WebDriver instance
   */
  @Parameters({"username", "key", "os", "browser", "browserVersion"})
  @BeforeMethod
  public void setUp(
      @Optional("ivolf") String username,
      @Optional("90e3bb89-c21d-4885-85cf-f25494db06ff") String key,
      @Optional("Windows 8.1") String os,
      @Optional("internet explorer") String browser,
      @Optional("11") String browserVersion,
      Method method)
      throws Exception {

    if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(key)) {
      authentication = new SauceOnDemandAuthentication(username, key);
    } else {
      authentication =
          new SauceOnDemandAuthentication("ivolf", "90e3bb89-c21d-4885-85cf-f25494db06ff");
    }

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(browser);
    capabilities.setCapability("version", browserVersion);
    capabilities.setCapability("platform", os);
    capabilities.setCapability("name", method.getName());
    this.driver =
        new RemoteWebDriver(
            new URL(
                "http://"
                    + authentication.getUsername()
                    + ":"
                    + authentication.getAccessKey()
                    + "@ondemand.saucelabs.com:80/wd/hub"),
            capabilities);
  }
예제 #8
0
  @Ignore({ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, OPERA_MOBILE, PHANTOMJS, SAFARI})
  @NeedsLocalEnvironment
  @Test
  public void requiredProxyCapabilityShouldHavePriority() {
    ProxyServer desiredProxyServer = new ProxyServer();
    registerProxyTeardown(desiredProxyServer);

    Proxy desiredProxy = desiredProxyServer.asProxy();
    Proxy requiredProxy = proxyServer.asProxy();

    DesiredCapabilities desiredCaps = new DesiredCapabilities();
    desiredCaps.setCapability(PROXY, desiredProxy);
    DesiredCapabilities requiredCaps = new DesiredCapabilities();
    requiredCaps.setCapability(PROXY, requiredProxy);

    WebDriver driver =
        new WebDriverBuilder()
            .setDesiredCapabilities(desiredCaps)
            .setRequiredCapabilities(requiredCaps)
            .get();
    registerDriverTeardown(driver);

    driver.get(pages.simpleTestPage);

    assertFalse(
        "Desired proxy should not have been called.",
        desiredProxyServer.hasBeenCalled("simpleTest.html"));
    assertTrue(
        "Required proxy should have been called.", proxyServer.hasBeenCalled("simpleTest.html"));
  }
예제 #9
0
 private WebDriver startIEBrowser() {
   setIEDriverPath();
   DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
   ieCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
   ieCapabilities.setCapability(
       InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
   return new InternetExplorerDriver(ieCapabilities);
 }
예제 #10
0
 @Before
 public void setUp() throws Exception {
   DesiredCapabilities caps = DesiredCapabilities.chrome();
   caps.setCapability("platform", "Windows XP");
   caps.setCapability("version", "43.0");
   driver = new RemoteWebDriver(new URL(URL), caps);
   driver.get("https://www.op.fi/op?sym=" + stock + ".HSE&id=32455&srcpl=3");
 }
 /** Add the common capability to custom capabilities */
 protected DesiredCapabilities addDefaultCapabilities(DesiredCapabilities desiredCapabilities) {
   desiredCapabilities.setCapability("takeScreenshot", true);
   desiredCapabilities.setCapability("hostName", hostName);
   // get the Jenkins build tag
   if (asJenkinsRun) {
     desiredCapabilities.setCapability("jenkinsBuildTag", jenkinsBuildTag);
   }
   return desiredCapabilities;
 }
 public DesiredCapabilities getChromeCapabilities() {
   DesiredCapabilities capabilities = DesiredCapabilities.chrome();
   capabilities.setCapability(
       "chrome.switches", Collections.singletonList("--no-default-browser-check"));
   HashMap<String, String> chromePreferences = new HashMap<>();
   chromePreferences.put("profile.password_manager_enabled", "false");
   capabilities.setCapability("chrome.prefs", chromePreferences);
   System.out.println(proxy());
   return addProxySettings(capabilities, proxy());
 }
예제 #13
0
 @BeforeMethod(alwaysRun = true)
 public void setUp() throws Exception {
   DesiredCapabilities capabilities = new DesiredCapabilities();
   capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.APPIUM);
   capabilities.setCapability(CapabilityType.BROWSER_NAME, "chrome");
   capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
   capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "015d4bdf31202013");
   capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.1");
   driver = new AndroidDriver<WebElement>(url, capabilities);
 }
예제 #14
0
 private static DesiredCapabilities getAndroidCapabilities(DesiredCapabilities userPrefs) {
   DesiredCapabilities caps = DesiredCapabilities.android();
   caps.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
   caps.setCapability(CapabilityType.ROTATABLE, true);
   caps.setCapability(CapabilityType.SUPPORTS_BROWSER_CONNECTION, true);
   if (userPrefs != null) {
     caps.merge(userPrefs);
   }
   return caps;
 }
예제 #15
0
  public static void main(String[] args) throws MalformedURLException {
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability("platformName", "android");
    cap.setCapability("app", "e:/example.apk");
    cap.setCapability("unicodeKeyboard", "true");
    cap.setCapability("resetKeyboard", "true");
    //        cap.setCapability("deviceName", "huawei-plk_ul00-W8R0215813002079");
    cap.setCapability("deviceName", "192.168.120.91:5555");

    AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    driver.findElementByAndroidUIAutomator("new UiSelector().text(\"排行榜\")").click();

    //        根据父元素获取同级元素
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().text(\"排行榜\")." + "fromParent(new UiSelector().text(\"应用\"))")
        .click();

    //        获取子元素
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/tab_host\")"
                + ".childSelector(new UiSelector().className(\"android.widget.TextView\").text(\"游戏\"))")
        .click();

    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_image\")")
        .click();

    driver.navigate().back();

    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_box_close\")")
        .click();
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_box_edit\")")
        .sendKeys("腾讯新闻");
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_button\")")
        .click();
    WebElement ele =
        (WebElement)
            driver
                .findElementsByAndroidUIAutomator(
                    "new UiSelector()" + ".className(\"android.widget.TextView\").text(\"安装\")")
                .get(0);
    ele.click();
    driver.openNotifications();
    driver.quit();
  }
 @Before
 public void setup() throws Exception {
   File appDir = new File("src/test/java/io/appium/java_client");
   File app = new File(appDir, "UICatalog.app.zip");
   DesiredCapabilities capabilities = new DesiredCapabilities();
   capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
   capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
   capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
   capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
   driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
 }
예제 #17
0
  @Test
  public void callIng() throws MalformedURLException {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "Micromax Q380");
    capabilities.setCapability("platformVersion", "5.0.0");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("appPackage", "com.android.vending");
    capabilities.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");

    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  }
 protected WebDriver createHtmlUnitDriver() {
   DesiredCapabilities capabilities = DesiredCapabilities.htmlUnitWithJs();
   capabilities.merge(createCommonCapabilities());
   capabilities.setCapability(HtmlUnitDriver.INVALIDSELECTIONERROR, true);
   capabilities.setCapability(HtmlUnitDriver.INVALIDXPATHERROR, false);
   if (browser.indexOf(':') > -1) {
     // Use constants BrowserType.IE, BrowserType.FIREFOX, BrowserType.CHROME etc.
     String emulatedBrowser = browser.replaceFirst("htmlunit:(.*)", "$1");
     capabilities.setVersion(emulatedBrowser);
   }
   return new HtmlUnitDriver(capabilities);
 }
예제 #19
0
  @BeforeClass
  public static void configure() throws IOException {
    // Read config file
    sConfig = new Properties();
    sConfig.load(new FileReader(CONFIG_FILE));

    // Prepare capabilities
    sCaps = new DesiredCapabilities();
    sCaps.setJavascriptEnabled(true);
    sCaps.setCapability("takesScreenshot", false);

    String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);

    // Fetch PhantomJS-specific configuration parameters
    if (driver.equals(DRIVER_PHANTOMJS)) {
      // "phantomjs_exec_path"
      if (sConfig.getProperty("phantomjs_exec_path") != null) {
        sCaps.setCapability(
            PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
            sConfig.getProperty("phantomjs_exec_path"));
      } else {
        throw new IOException(
            String.format(
                "Property '%s' not set!",
                PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
      }
      // "phantomjs_driver_path"
      if (sConfig.getProperty("phantomjs_driver_path") != null) {
        System.out.println("Test will use an external GhostDriver");
        sCaps.setCapability(
            PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY,
            sConfig.getProperty("phantomjs_driver_path"));
      } else {
        System.out.println("Test will use PhantomJS internal GhostDriver");
      }
    }

    // Disable "web-security", enable all possible "ssl-protocols" and "ignore-ssl-errors" for
    // PhantomJSDriver
    sCaps.setCapability(
        PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
        new String[] {"--web-security=false", "--ssl-protocol=any", "--ignore-ssl-errors=true"});

    // Control LogLevel for GhostDriver, via CLI arguments
    sCaps.setCapability(
        PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS,
        new String[] {
          "--logLevel="
              + (sConfig.getProperty("phantomjs_driver_loglevel") != null
                  ? sConfig.getProperty("phantomjs_driver_loglevel")
                  : "INFO")
        });
  }
예제 #20
0
 // get cloud Driver
 public WebDriver getSauceLabDriver(
     String userName, String key, String os, String browserName, String browserVersion)
     throws IOException {
   DesiredCapabilities cap = new DesiredCapabilities();
   cap.setCapability("platform", os);
   cap.setBrowserName(browserName);
   cap.setCapability("version", browserVersion);
   driver =
       new RemoteWebDriver(
           new URL("http://" + userName + ":" + key + "@ondemand.saucelabs.com:80/wd/hub"), cap);
   return driver;
 }
 @Before
 public void setUp() throws Exception {
   DesiredCapabilities capabilities = new DesiredCapabilities();
   capabilities.setCapability("deviceName", "10.4.21.140:5555");
   capabilities.setCapability("platformVersion", "5.0.1");
   // If you want the tests on real device, make sure chrome browser is installed and change the
   // line to
   // capabilities.setCapability("browserName", "chrome");
   capabilities.setCapability("browserName", "browser");
   capabilities.setCapability("setJavaScriptEnabled", true);
   driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
   wait = new WebDriverWait(driver, 30);
 }
예제 #22
0
  public void setUp() {

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("takesScreenshot", true);
    caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, phantomjsPath);
    String[] phantomArgs = new String[] {"--webdriver-loglevel=NONE", "--ssl-protocol=any"};
    caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
    driver = new PhantomJSDriver();
    // driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(LOAD_WAIT_TIME, TimeUnit.SECONDS);
    driver.manage().window().setSize(new Dimension(1024, 768));
    loginOrGoToBaseURL();
  }
예제 #23
0
  @BeforeClass
  public static void beforeClass() throws Exception {
    service = AppiumDriverLocalService.buildDefaultService();
    service.start();

    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "ApiDemos-debug.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.SELENDROID);
    capabilities.setCapability(MobileCapabilityType.SELENDROID_PORT, SELENDROID_PORT);
    driver = new AndroidDriver<WebElement>(service.getUrl(), capabilities);
  }
  public static void main(String[] args) throws Exception {

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("browserName", "iPhone");
    caps.setCapability("platform", "MAC");
    caps.setCapability("device", "iPhone 5S");
    caps.setCapability("browserstack.debug", "true");
    caps.setCapability("browserstack.local", "true");

    WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
    driver.get("http://www.google.com/ncr");

    driver.quit();
  }
예제 #25
0
 @BeforeMethod(alwaysRun = true)
 public void reportHeader(Method method) throws Throwable {
   // itc = ctx;
   Date date = new Date();
   SimpleDateFormat sdf = new SimpleDateFormat("dd_MMM_yyyy hh mm ss SSS");
   String formattedDate = sdf.format(date);
   ReportStampSupport.calculateTestCaseStartTime();
   if (browser.equalsIgnoreCase("firefox")) {
     ProfilesIni profile = new ProfilesIni();
     FirefoxProfile ffprofile = new FirefoxProfile();
     ffprofile.setEnableNativeEvents(true);
     webDriver = new FirefoxDriver(ffprofile);
   } else if (browser.equalsIgnoreCase("ie")) {
     File file = new File("Drivers\\IEDriverServer.exe");
     System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
     DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
     caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
     webDriver = new InternetExplorerDriver(caps);
     i = i + 1;
   } else if (browser.equalsIgnoreCase("chrome")) {
     System.setProperty("webdriver.chrome.driver", "Drivers\\chromedriver.exe");
     DesiredCapabilities capabilities = new DesiredCapabilities();
     ChromeOptions options = new ChromeOptions();
     options.addArguments("test-type");
     capabilities.setCapability(ChromeOptions.CAPABILITY, options);
     webDriver = new ChromeDriver(capabilities);
   } else if (browser.equalsIgnoreCase("iphone")) {
     Iosdriver.resetApp();
   } else if (browser.equalsIgnoreCase("android")) {
     AndroidDriver2.resetApp();
   }
   flag = false;
   if ((!(browser.equalsIgnoreCase("Android"))) & (!(browser.equalsIgnoreCase("iPhone")))) {
     driver = /*new EventFiringWebDriver*/ (webDriver);
     /*ActionEngineSupport myListener = new ActionEngineSupport();
     driver.register(myListener);*/
     driver.manage().window().maximize();
     driver.manage().timeouts().implicitlyWait(3, TimeUnit.MINUTES);
     driver.get(url);
   }
   HtmlReportSupport.tc_name = method.getName().toString() + "-" + formattedDate;
   String[] ts_Name = this.getClass().getName().toString().split("\\.");
   HtmlReportSupport.packageName = ts_Name[0] + "." + ts_Name[1] + "." + ts_Name[2];
   HtmlReportSupport.testHeader(HtmlReportSupport.tc_name, browser);
   stepNum = 0;
   PassNum = 0;
   FailNum = 0;
   testName = method.getName();
   logger.info("Current Test : " + testName);
 }
  @Override
  public void initialize() {
    String browser = System.getProperty("browser", "").toLowerCase();

    DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
    dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    dc.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
    dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

    // dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    // It's possible to avoid the post-processing cost of uploading videos for passing tests
    //        dc.setCapability("video-upload-on-pass", false);

    if ("ie8".equals(browser)) {
      dc.setVersion("8");
      dc.setCapability("platform", "Windows 2008");
    } else if ("ie9".equals(browser)) {
      dc.setVersion("9");
      dc.setCapability("platform", "Windows 2008");
    } else if ("ie10".equals(browser)) {
      dc.setVersion("10");
      dc.setCapability("platform", "Windows 2012");
    }

    // Set a 10 minute limit per test
    dc.setCapability("max-duration", 10 * 60);
    // Set a 30 second command timeout
    dc.setCapability("command-timeout", 30);
    // Set a 15 second idle timeout
    dc.setCapability("idle-timeout", 15);
  }
예제 #27
0
  @Before
  public void setUp() throws Exception {
    if (service == null || !service.isRunning())
      throw new RuntimeException("An appium server node is not started!");

    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "WebViewApp.app.zip");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "8.4");
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    driver = new IOSDriver<WebElement>(service.getUrl(), capabilities);
  }
  @Test
  public void canSpecifyUnhandledAlertBehaviourUsingCapabilities() {
    desiredCaps.setCapability(UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    driver2 = new WebDriverBuilder().setDesiredCapabilities(desiredCaps).get();

    runScenarioWithUnhandledAlert("This is a default value");
  }
 protected DesiredCapabilities createCommonCapabilities() {
   DesiredCapabilities browserCapabilities = new DesiredCapabilities();
   if (webProxySettings != null) {
     browserCapabilities.setCapability(PROXY, webProxySettings);
   }
   return browserCapabilities;
 }
 protected WebDriver createChromeDriver() {
   DesiredCapabilities capabilities = createCommonCapabilities();
   ChromeOptions options = new ChromeOptions();
   options.addArguments("test-type");
   capabilities.setCapability(ChromeOptions.CAPABILITY, options);
   return new ChromeDriver(capabilities);
 }