Пример #1
0
  @Test
  public void testZoomTo100() throws PageException {
    // find signin element
    ITafElement element = webpage.findObjectById(prop.getProperty("amazon_signin_link"));

    // get coordinates of signin element
    Point point1 = element.getCoordinates();
    CommonUtil.sop(point1.getX() + ", " + point1.getY());

    // Zoom out the web page
    webpage.zoomOut(2);

    // find the signin element
    element = webpage.findObjectById(prop.getProperty("amazon_signin_link"));

    // get its cordinates
    Point point2 = element.getCoordinates();
    CommonUtil.sop(point2.getX() + ", " + point2.getY());

    // zoom it to 100%
    webpage.zoomTo100();

    // find the signin element
    element = webpage.findObjectById(prop.getProperty("amazon_signin_link"));

    // get its cordinates
    Point point3 = element.getCoordinates();
    CommonUtil.sop(point3.getX() + ", " + point3.getY());

    // Assert on element location
    Assert.assertNotEquals(point1.getX(), point2.getX());
    Assert.assertEquals(point1.getX(), point3.getX());
  }
Пример #2
0
  @Test
  public void testDrapAndDrop() throws PageException {
    try {
      // open w3 schools tutorial
      driverObj.get(prop.getProperty("w3tutorials_url"));
      // driverObj.get("file:///C:/Users/P8-03GPQ0/Desktop/Drag_Drop.html");
      Thread.sleep(2000);

      // find draggable element
      // ITafElement draggable = webpage.findObjectByxPath(".//*[@id='drag1']");
      ITafElement draggable =
          webpage.findObjectById(prop.getProperty("w3tutorials_draggable_text"));

      Point point1 = draggable.getCoordinates();

      // find the drop area
      ITafElement dropArea = webpage.findObjectById(prop.getProperty("w3tutorials_drop_area"));

      // drag and drop the text
      draggable.dragAndDrop(dropArea);

      Point point2 = draggable.getCoordinates();

      Assert.assertNotEquals(point1.getY(), point2.getY());
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }