Package org.uiautomation.ios.UIAModels.predicate

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


  @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


  @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

    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
  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

public class ServerSideCriteriaTest extends BaseIOSDriverTest {

  @BeforeClass
  public void startDriver() {
    driver = new RemoteIOSDriver(getRemoteURL(), SampleApps.intlMountainsCap("fr"));
    Criteria c1 = new TypeCriteria(UIATableCell.class);
    UIAElement element = driver.findElement(c1);
    element.tap();
  }
View Full Code Here

    try {
      while (!stopRequested) {
        try {
          log.fine("starting to look for an alert.");
          //driver.switchTo().window(WorkingMode.Native.toString());
          alert = driver.findElement(new TypeCriteria(UIAAlert.class));
          //driver.switchTo().window(WorkingMode.Web.toString());
          String alertDetails = alert.logElementTree(null, false).toString(2);
          log.fine("found an alert." + alertDetails);
          ex = new UnhandledAlertException("alert present", alertDetails);
          break;
View Full Code Here

TOP

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

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.