@Test(groups = {"taobao"})
  public void webDriver() {
    driver.get("http://m.taobao.com/");
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
    MobileElement tmall = (MobileElement) driver.findElementByXPath("//div[@id='a6636-1']");
    tmall.swipe(SwipeElementDirection.DOWN, 1000);
    tmall.tap(1, 1000);
    HashMap<String, Integer> tapObject = new HashMap<String, Integer>();
    tapObject.put("x", 120);
    tapObject.put("y", 120);
    tapObject.put("touchCount", 1);
    tapObject.put("duration", 1200);
    driver.executeScript("mobile: tap", tapObject);
    JavascriptExecutor js = (JavascriptExecutor) driver;
    HashMap<String, Double> flickObject = new HashMap<String, Double>();
    flickObject.put("startX", 200.0);
    flickObject.put("startY", 700.5);
    flickObject.put("endX", 200.2);
    flickObject.put("endY", 100.5);
    js.executeScript("mobile: flick", flickObject);

    TouchAction action = new TouchAction(driver);

    action.press(tmall).waitAction(400).perform();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
    List<WebElement> elements =
        driver.findElementsByXPath("//ul/li/a[@class='card-item card-style-chn']");
    for (WebElement e : elements) {
      System.out.println(e.getAttribute("href"));
    }
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    System.out.println(driver.getPageSource());
  }
Beispiel #2
0
 public ContactsPage deleteContact(String name) {
   TouchAction action = new TouchAction(wd);
   WebElement contact = getContactFieldByName(name);
   action.longPress(contact).release().perform();
   modalOptionDeleteContact.click();
   btnDeleteDeletePrompt.click();
   return this;
 }
  @Test
  public void F_more() {

    // List<WebElement> editBox=driver.findElements(By.className("android.widget.TextView"));
    // editBox.get(3).click();

    // driver.findElement(By.name("Collections")).click();

    // driver.findElement(By.name("COOL!")).click();

    List<WebElement> collection1 =
        driver.findElements(By.className("android.view.View")); // Taping on Collection folder
    collection1.get(5).click();

    TouchAction tActionn = new TouchAction(driver); // Tap function
    tActionn.tap(150, 301).release().perform();

    // driver.findElement(By.xpath("//*[@class='android.view.View' and @index='5']")).click();

    driver.findElementByAccessibilityId("More").click();
    driver.findElementByName("Info").click();
    driver.findElement(By.id("com.mimedia.gallery:id/gallery_action_bar_nav_icon")).click();

    driver.findElementByAccessibilityId("More").click();
    driver.findElementByName("Add to Collection").click();
    driver.findElement(By.id("com.mimedia.gallery:id/merged_collection_cover")).click();
    driver.findElementByName("Add to Collection").click();

    driver.findElementByAccessibilityId("More").click();

    driver.findElementByName("Add to MiDrive").click();
    List<WebElement> midrive = driver.findElements(By.className("android.widget.FrameLayout"));
    midrive.get(0).click();
    // driver.findElement(By.xpath("//*[@class='android.widget.FrameLayout' and
    // @index='0']")).click();
    driver.findElementByName("Add to MiDrive").click();

    driver.findElementByAccessibilityId("More").click();
    driver.findElementByName("Delete").click();
    driver.findElementByName("Cancel").click();

    driver.findElementByAccessibilityId("More").click();
    driver.findElementByName("Delete").click();
    driver.findElementByName("Delete").click();
    driver.findElement(By.id("com.mimedia.gallery:id/gallery_action_bar_nav_icon")).click();

    TouchAction tActionn1 = new TouchAction(driver); // Tap function
    tActionn1.tap(150, 301).release().perform();
    WebDriver augmentedDriver = new Augmenter().augment(driver); // Landscape orientation
    ((Rotatable) augmentedDriver).rotate(ScreenOrientation.LANDSCAPE); // Landscape orientation
    WebDriver augmentedDriver1 = new Augmenter().augment(driver); // Landscape orientation
    ((Rotatable) augmentedDriver1).rotate(ScreenOrientation.PORTRAIT);
    for (int i = 0; i <= 0; i++) {
      driver
          .findElement(By.id("com.mimedia.gallery:id/gallery_action_bar_nav_icon"))
          .click(); // Back key twice
    }
  }
  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();
      }
    }
  }
  public void iOSSwipe(int startX, int startY, int endX, int endY) throws Exception {
    TouchAction action = new TouchAction(driver);

    action.press(startX, startY);
    action.waitAction(1000); // has to be >= 500 otherwise it will fail
    action.moveTo(endX, endY);
    action.release();
    action.perform();
  }