Exemplo n.º 1
0
  public static boolean widgetIsAdded(String widget) {

    List<WebElement> addedWidgets =
        Driver.Instance.findElements(By.id("com.itelematic.drive.dashboard:id/title"));

    List<String> appNames = new ArrayList<String>();
    for (WebElement wid : addedWidgets) appNames.add(wid.getText());

    for (String widz : appNames) System.out.println(widz);

    return true;
    // appNames.contains(widget);
  }
Exemplo n.º 2
0
  public static void addWidget(String widget) {

    // Add selected widget to the Dashboard
    List<WebElement> layouts =
        Driver.Instance.findElements(By.xpath("//android.widget.RelativeLayout[@NAF='true']"));
    System.out.println(layouts.size());

    layouts.get(0).click();

    // these are available apps
    WebElement appPage =
        Driver.Instance.findElementByAndroidUIAutomator(
            "new UiSelector().text(\"Select Application\")");
    // WebElement appPage =
    // Driver.Instance.findElementById("com.itelematic.drive.dashboard:id/gridViewCustom");
    System.out.println(appPage.getText());

    // Wait for the application page to load (takes some time, throws an
    // error if no wait).
    WebDriverWait wait = new WebDriverWait(Driver.Instance, 20);
    wait.until(ExpectedConditions.visibilityOf(appPage));

    Driver.Instance.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

    // Select wanted app from the grid
    List<WebElement> widgets =
        Driver.Instance.findElements(By.id("com.itelematic.drive.dashboard:id/textView"));
    System.out.println("Apps available= " + widgets.size());

    for (int n = 0; n <= widgets.size(); n++) {
      String app = widgets.get(n).getText();
      System.out.println(app);

      if (app.equals(widget)) {
        widgets.get(n).click();
        return;
      }
    }
  }
Exemplo n.º 3
0
  public static void removeWidget(String forms) {

    // TODO; some code to remove forms

    TouchAction action = new TouchAction(Driver.Instance);

    List<WebElement> addedWidgets =
        Driver.Instance.findElements(By.id("com.itelematic.drive.dashboard:id/title"));
    for (WebElement wid : addedWidgets) {
      if (wid.getText().equalsIgnoreCase(forms)) {
        System.out.println(wid);
        action.longPress(wid).release().perform();

        wid.click();
      }
    }
  }