コード例 #1
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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());
  }
コード例 #4
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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();
    }
  }
コード例 #5
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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());
  }
コード例 #6
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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());
  }
コード例 #7
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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();
  }
コード例 #8
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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();
  }
コード例 #9
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @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());
    }
  }
コード例 #12
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  @Before
  public void before() throws DriverException {
    prop = TafTestUtil.loadProps(TafTestUtil.propFilePath);

    TafTestUtil.initialize();

    String[] currentTestbeds =
        TestBedManagerConfiguration.INSTANCE.getWebConfig().getCurrentTestBeds();
    // TestBed currentTestbed = TafTestUtil.loadTestBedDetails(currentTestbeds[0]);
    String currentTestbedName = currentTestbeds[0];
    // TestBedManager.INSTANCE.setCurrentTestBed(currentTestbed);
    TestBedManager.INSTANCE.getCurrentTestBeds().get(currentTestbedName);

    driverObj = TestUtil.createDriver(true);
    Mockito.when(mockContext.getCurrentXmlTest().getAllParameters().get("testBedName"))
        .thenReturn("Chrome");

    webpage = new WebPage(mockContext);
    webpage.loadPage("http://www.amazon.com");
  }
コード例 #13
0
ファイル: WebElementTest.java プロジェクト: sonamM/july_NS
  // This method is giving error as uncheck is not working as expected
  @Test
  public void testScrollcheck() {
    try {
      // hover on shop by department in amazon.com
      // webpage.findObjectById("nav-shop").hover();
      webpage.findObjectByxPath(prop.getProperty("amazon_shop_by_department")).hover();

      // Thread.sleep(1000);

      // click on clothing, shoes & jewellery
      webpage.findObjectByxPath(prop.getProperty("amazon_clothing_shoes_jewellery")).hover();

      // Thread.sleep(1000);

      // click on Men
      webpage.findObjectByxPath(prop.getProperty("amazon_men")).click();

      // click on watches
      webpage.findObjectByxPath(prop.getProperty("amazon_watches")).click();

      // check casual
      webpage.scrollDown(3);
      webpage.findObjectByxPath(prop.getProperty("amazon_watches_casual")).check();
      Thread.sleep(2000);

      // check Luxury
      webpage.scrollDown(3);
      Assert.assertTrue(
          webpage.findObjectByxPath(prop.getProperty("amazon_watches_casual")).isEnabled());
      webpage.findObjectByxPath(prop.getProperty("amazon_watches_fashion")).check();
      Thread.sleep(2000);

      // uncheck Luxury
      webpage.scrollDown(3);
      webpage.findObjectByxPath(prop.getProperty("amazon_watches_fashion")).uncheck();

      webpage.scrollDown(1);
      Assert.assertFalse(
          webpage.findObjectByxPath(prop.getProperty("amazon_watches_fashion")).isEnabled());
      Thread.sleep(2000);

    } catch (Exception ex) {
      log.error(ex.getMessage());
    }
  }