예제 #1
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();
    }
  }
예제 #2
0
  @Test
  public void testSendKeys() {
    try {

      // Find sign in button
      ITafElement signInElement = webpage.findObjectById(prop.getProperty("amazon_signin_link"));
      Assert.assertEquals("rgba(0, 102, 192, 1)", signInElement.getCssValue("color"));

      // hover on it
      signInElement.hover();

      // Click on it
      signInElement.click();

      // Find email field
      ITafElement element = webpage.findObjectById(prop.getProperty("amazon_email_field"));

      // enter text
      element.sendKeys("Text");

      Assert.assertEquals("Text", element.getAttribute("value"));
      CommonUtil.sop(element.getAttribute("style"));

      // clear email field
      element.clear();

      Assert.assertEquals("", element.getAttribute("value"));
    } catch (Exception ex) {
      log.error(ex.getMessage());
    }
  }
예제 #3
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());
  }
예제 #4
0
  @Test
  public void testFullScrollInSlowMotion() throws InterruptedException, PageException {
    // Scroll the web page in slow motion
    webpage.fullScrollInSlowMotion();

    // find the text "Amazon Payment Products"
    ITafElement element = webpage.findObjectByxPath(prop.getProperty("amazon_payment_products"));

    Assert.assertEquals("Amazon Payment Products", element.getText());
  }
예제 #5
0
  @Test
  public void testScrollToElement() throws PageException {
    // find the element "Amazon.com Rewards Visa Card"
    ITafElement element = webpage.findObjectByxPath(prop.getProperty("amazon_rewards_visa_card"));

    // Scroll to the element
    webpage.scrollToElement(element);

    // Assert and click on it
    Assert.assertEquals("Amazon.com Rewards Visa Card", element.getText());
    element.click();
  }
예제 #6
0
  @Test
  public void testSubmit() throws PageException {
    // Find sign in link
    ITafElement signInElement = webpage.findObjectById(prop.getProperty("amazon_signin_link"));

    // hover and click on it
    signInElement.hover();
    signInElement.click();

    // find email field
    ITafElement element = webpage.findObjectById(prop.getProperty("amazon_email_field"));

    // enter text
    element.sendKeys("Text");

    // find password
    element = webpage.findObjectById(prop.getProperty("amazon_password_field"));

    // enter text
    element.sendKeys("Text");

    // find the sign in button
    element = webpage.findObjectById(prop.getProperty("amazon_signin_submit_button"));

    // submit it
    element.submit();

    // find the warning message
    element = webpage.findObjectByxPath(prop.getProperty("amazon_signin_warning_msg"));
    Assert.assertEquals("Important Message!", element.getText());
  }
예제 #7
0
  @Test
  public void testScrollTopAndBottom() throws PageException {
    // scroll to bottom
    webpage.scrollBottom();

    // find "Amazon Payment Products" element and assert on it.
    ITafElement element = webpage.findObjectByxPath(prop.getProperty("amazon_payment_products"));
    Assert.assertEquals("Amazon Payment Products", element.getText());

    // Scroll to Top
    webpage.scrollTop();

    // find sign in text and assert
    element = webpage.findObjectByxPath(prop.getProperty("amazon_signin_text"));
    Assert.assertEquals("Hello. Sign in", element.getText());
    element.hover();
  }
예제 #8
0
  @Test
  public void testselectDropDownList() throws PageException, InterruptedException {
    // find the search drop down box
    ITafElement dorpdown = webpage.findObjectById(prop.getProperty("amazon_search_dropdown_box"));

    // select "Books" in dropdown
    dorpdown.selectDropDownList("Books");

    // find "Books" element
    ITafElement element =
        webpage.findObjectByxPath(prop.getProperty("amazon_search_dropdown_books"));

    // assert that it is selected
    Assert.assertTrue(element.isSelected());

    // Find the search text box
    element = webpage.findObjectById(prop.getProperty("amazon_search_text_box"));

    // enter "fiction novels"
    element.sendKeys("fiction novels");

    // find search button
    element = webpage.findObjectByxPath(prop.getProperty("amazon_search_submit_button"));

    // submit it
    element.submit();

    // find the text "fiction novels" in the search results
    element = webpage.findObjectByxPath(prop.getProperty("amazon_search_result_text"));

    // Assert on the text
    Assert.assertEquals("\"fiction novels\"", element.getText());
  }
예제 #9
0
  @Test
  public void testDoubleClick() {
    try {
      // find sign in link
      ITafElement element = webpage.findObjectById(prop.getProperty("amazon_signin_link"));

      // assert on css value
      Assert.assertEquals("rgba(0, 102, 192, 1)", element.getCssValue("color"));

      // double click on signin link
      element.doubleClick();
      ;

      // Assert on Sign in text
      String text = webpage.findObjectById(prop.getProperty("amazon_signin_title")).getText();
      Assert.assertEquals(text, "Sign In");
    } catch (Exception ex) {
      log.error(ex.getMessage());
    }
  }
예제 #10
0
  @Test
  public void testHover() {
    try {
      // find wishlist link
      ITafElement element = webpage.findObjectById(prop.getProperty("amazon_wishlist_link"));

      // hover on it
      element.hover();

      // find hovered box
      ITafElement hoveredItem =
          webpage.findObjectById(prop.getProperty("amazon_wishlist_hover_box"));

      // assert
      Assert.assertTrue(hoveredItem.isDisplayed());

    } catch (Exception ex) {
      log.error(ex.getMessage());
    }
  }
예제 #11
0
  @Test
  public void testClick() {
    try {
      // Find sign in button
      ITafElement element = webpage.findObjectById(prop.getProperty("amazon_signin_link"));
      Assert.assertEquals("rgba(0, 102, 192, 1)", element.getCssValue("color"));

      // hover on it
      element.hover();

      // Click on it
      element.click();

      // find the sign in element
      String text = webpage.findObjectById(prop.getProperty("amazon_signin_title")).getText();

      Assert.assertEquals(text, "Sign In");
    } catch (Exception ex) {
      log.error(ex.getMessage());
    }
  }