Package org.uiautomation.ios.UIAModels.predicate

Examples of org.uiautomation.ios.UIAModels.predicate.Criteria


  // TODO freynaud find a test for stale.
  @Test(expectedExceptions = StaleElementReferenceException.class, enabled = false)
  public void staleElement() {
    try {
      String name = "Buttons, Various uses of UIButton";
      Criteria c1 = new TypeCriteria(UIATableCell.class);
      Criteria c2 = new NameCriteria(name);
      Criteria c = new AndCriteria(c1, c2);
      UIAElement element = driver.findElement(c);
      // should work.
      // new screen. The element doesn't exist anymore
      element.tap();
View Full Code Here


    textview = getTextView();
  }

  private UIATextView getTextView() {
    String name = "TextView, Use of UITextField";
    Criteria c1 = new TypeCriteria(UIATableCell.class);
    Criteria c2 = new NameCriteria(name);
    Criteria c = new AndCriteria(c1, c2);
    UIAElement element = driver.findElement(c);
    element.tap();
    Criteria fieldC = new TypeCriteria(UIATextView.class);
    UIATextView res = (UIATextView) driver.findElement(fieldC);
    return res;
  }
View Full Code Here

    try {
      json = getCriteria(getRequest().getPayload());
    } catch (JSONException e) {
      throw new WebDriverException(e);
    }
    Criteria decorated = AbstractCriteria.parse(json, decorator);
    return decorated;
  }
View Full Code Here

    String using = payload.getString("using");
    String value = payload.getString("value");
    if ("tag name".equals(using) || "class name".equals(using)) {
      try {
        Package p = UIAElement.class.getPackage();
        Criteria c = new TypeCriteria(Class.forName(p.getName() + "." + value));
        return c.stringify();
      } catch (ClassNotFoundException e) {
        throw new InvalidSelectorException(value + " is not a recognized type.");
      }
      //  http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAccessibilityIdentification_Protocol/Introduction/Introduction.html
    } else if ("name".equals(using) || "id".equals(using)) {
      Criteria c = new NameCriteria(getAUT().applyL10N(value));
      return c.stringify();
    } else if ("link text".equals(using) || "partial link text".equals(using)) {
      return createGenericCriteria(using, value);
    } else {
      throw new InvalidSelectorException(
          using + "is not a valid selector for the native part of ios-driver.");
View Full Code Here

  @Test
  public void logElement() throws Exception {
    driver =
        new RemoteIOSDriver(getRemoteURL(),
            SampleApps.intlMountainsCap(Locale.FRENCH.toString()));
    Criteria c1 = new TypeCriteria(UIATableCell.class);
    UIAElement element = driver.findElement(c1);
    element.tap();

    NameCriteria criteria =
        new NameCriteria("sentenceFormat", L10NStrategy.serverL10N, MatchingStrategy.regex);
View Full Code Here

    driver = new RemoteIOSDriver(getRemoteURL(), SampleApps.intlMountainsCap("en"));
  }

  @Test
  public void orCriteriaReturnsFirstMatch() {
    Criteria mountain1 = new NameCriteria("Mountain 1");
    Criteria mountain2 = new NameCriteria("Mountain 2");

    UIAElement result1 = driver.findElement(new OrCriteria(mountain1, mountain2));
    UIAElement result2 = driver.findElement(new OrCriteria(mountain2, mountain1));

    Assert.assertEquals(result1.getName(), "Mountain 1");
View Full Code Here

    Assert.assertEquals(result2.getName(), "Mountain 2");
  }

  @Test
  public void complexOrCriteriaReturnsFirstMatch() {
    Criteria mountain1 = new NameCriteria("Mountain 1");
    Criteria mountain2 = new NameCriteria("Mountain 2");
    Criteria mountain3 = new NameCriteria("Mountain 3");

    UIAElement result1 = driver.findElement(new OrCriteria(mountain1, mountain2, mountain3));
    UIAElement
        result3 =
        driver.findElement(new OrCriteria(new OrCriteria(mountain3, mountain2), mountain1));
View Full Code Here

    int webPageWidth = getInspector().getInnerWidth();
    if (dim.getWidth() != webPageWidth) {
      log.fine("BUG : dim.getWidth()!=webPageWidth");
    }

    Criteria c = new TypeCriteria(UIAWebView.class);
    String json = c.stringify().toString();
    StringBuilder script = new StringBuilder();
    script.append("var root = UIAutomation.cache.get('1');");
    script.append("var webview = root.element(-1," + json + ");");
    script.append("var webviewSize = webview.rect();");
    script.append("var ratioX = 1.0 * webviewSize.size.width / " + dim.getWidth() + ";");
    script.append("var ratioY = 1.0 * webviewSize.size.height / " + dim.getHeight() + ";");
    int top = po.getY();
    int left = po.getX();
    // switch +1 to +2 in next, with +1 some clicks in text fields didn't bring up the
    // keyboard, the text field would get focus, but the keyboard would not launch
    // also with this change 17 miscellaneous selenium tests got fixed
    switch (position) {
      case TOP_LEFT: {
        script.append("var top = (" + top + "*ratioX);");
        script.append("var left = (" + left + "*ratioY);");
        break;
      }
      case CENTER: {
        Dimension size = getSize();
        script.append("var top = (" + top + " + " + size.getHeight() + " / 2) * ratioX;");
        script.append("var left = (" + left + " + " + size.getWidth() + " / 2) * ratioY;");
        break;
      }
    }

    script.append("var x = left;");
    boolean ipad = session.getCapabilities().getDevice() == DeviceType.ipad;
    boolean ios7 = new IOSVersion(session.getCapabilities().getSDKVersion()).isGreaterOrEqualTo("7.0");
    boolean ios8 = new IOSVersion(session.getCapabilities().getSDKVersion()).isGreaterOrEqualTo("8.0");

    if (ios8) {
      if (isSafari()) {
        // the first button in the second view for iOS8 safari is the height of the address bar
        script.append("top += root.elements()[1].elements()[0].rect().size.height;");
      }
      script.append("var y = top;");
    } else if (ios7) {
      script.append("var y = webviewSize.origin.y + top;");
      if (isSafari()) {
        script.append("var orientation = UIATarget.localTarget().deviceOrientation();");
        script.append("var plus = orientation == UIA_DEVICE_ORIENTATION_LANDSCAPELEFT || orientation == UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN;");
        // TODO: why is the webView shifted by 20
        script.append("y += plus? 20 : -20;");
      }
    } else {
      if (isSafari()) {
        if (ipad) {
          // for ipad, the adress bar h is fixed @ 96px.
          script.append("var y = top+96;");
        } else {
          ImmutableList<ContentResult> results =
              session.getApplication().getCurrentDictionary().getPotentialMatches("Address");
          if (results.size() != 1) {
            log.warning("translation returned " + results.size());
          }
          ContentResult result = results.get(0);
          String addressL10ned = result.getL10nFormatted();
          Criteria
              c2 =
              new AndCriteria(new TypeCriteria(UIAElement.class), new NameCriteria(addressL10ned),
                  new LabelCriteria(addressL10ned));
          script.append("var addressBar = root.element(-1," + c2.stringify().toString() + ");");
          script.append("var addressBarSize = addressBar.rect();");
          script.append("var delta = addressBarSize.origin.y +39;");
          script.append("if (delta<20){delta=20;};");
          script.append("var y = top+delta;");
        }
      } else {
        Criteria wv = new TypeCriteria(UIAScrollView.class);
        script.append("var webview = root.element(-1," + wv.stringify().toString() + ");");
        script.append("var size = webview.rect();");
        script.append("var offsetY = size.origin.y;");
        // UIAWebView.y
        script.append("var y = top+offsetY;");
        //script.append("var y = top+64;");
View Full Code Here

  @Test(dataProvider = "intlMountain")
  public void selectAndValidateServerSideL10NedContent(String lang, String expectedContent) {
    driver = new RemoteIOSDriver(getRemoteURL(), SampleApps.intlMountainsCap(lang));

    Criteria c1 = new TypeCriteria(UIATableCell.class);
    UIAElement element = driver.findElement(c1);
    element.tap();

    NameCriteria
      criteria =
View Full Code Here

  @Test
  public void apostrophe() {
    driver = new RemoteIOSDriver(getRemoteURL(), SampleApps.intlMountainsCap("fr"));

    Criteria c1 = new TypeCriteria(UIATableCell.class);
    UIAElement element = driver.findElement(c1);
    element.tap();

    // and using Xpath
    WebElement
View Full Code Here

TOP

Related Classes of org.uiautomation.ios.UIAModels.predicate.Criteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.