Ejemplo n.º 1
0
 @Test(
     dataProvider = "DP_valid_login",
     dataProviderClass = DataProviderObjects.DP_LoginScenario.class,
     groups = {"SmokeTest"})
 public void avalid_login(String TC_ID, String Order, String Uname, String Pwd, String expected)
     throws Exception {
   SoftAssert assert1 = new SoftAssert();
   Initialize_browser();
   POM_LoginScenario pom_valid = new POM_LoginScenario(driver);
   pom_valid.execute_common_methods_log(Uname, Pwd);
   if (!driver
       .getTitle()
       .equalsIgnoreCase(
           "Buy Books Online | Online Bookstore India | Online Book Shopping | Free Shipping Across India")) {
     log.error(
         "The user has failed to login, the page the user currently is " + driver.getTitle());
     Assert.fail();
     tear_down();
   }
   String actual = pom_valid.get_valid_log_msg();
   assert1.assertEquals(
       actual, expected, "The actual found is" + actual + " The expected is " + expected);
   if (actual.equalsIgnoreCase(expected)) {
     log.info("The validation has passed");
   } else {
     log.error("THe validation has failed");
   }
   pom_valid.click_signout();
   tear_down();
   assert1.assertAll();
 }
Ejemplo n.º 2
0
  @Test(
      dataProvider = "Valid_edit",
      dataProviderClass = Dataprovider_invoice.DataProvider_edit.class,
      groups = {"invoice"})
  public void Valid_edit(
      String TC_ID, String Order, String invoice_name, String desp, String Exp_Res)
      throws IOException {
    String uname = c1.Reading_Properties("uname");
    String pwd = c1.Reading_Properties("pwd");
    log.info("Executing the testcase " + TC_ID + "  Order of  " + Order);
    // System.out.println("hi");
    initBrowsersession1();
    Pageobject_edit lpob = new Pageobject_edit(browser);
    lpob.Commonprocessinvoice(uname, pwd, TC_ID, invoice_name, desp); // , Pwd);
    String Actual_Res = lpob.Valid_edit();
    sAssert.assertEquals(Exp_Res, Actual_Res);

    if (Actual_Res.equals(Exp_Res)) {
      log.info("Passed as Expected msg was Valid");
    } else {
      log.info("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
      sAssert.fail("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
    }
    tearDown();
    sAssert.assertAll();
    log.info("******************************************");
  }
Ejemplo n.º 3
0
 @Test
 public void testSoftAssert() {
   SoftAssert s = new SoftAssert();
   s.assertEquals(2 * 2, 3, "Three");
   s.assertEquals(2 * 2, 5, "Five");
   s.assertAll();
 }
Ejemplo n.º 4
0
  @Test(
      dataProvider = "Invalid_delete_blnk",
      dataProviderClass = Dataprovider_item_cat.DataProvider_del.class,
      groups = {"branch"})
  public void Invalid_delete_blnk(String TC_ID, String Order, String Exp_Res) throws IOException {
    String uname = c1.Reading_Properties("uname");
    String pwd = c1.Reading_Properties("pwd");
    int j = (int) Double.parseDouble(Order);
    for (int i = 0; i < j; i++) {
      // System.out.println(j);
      log.info("Executing the testcase " + TC_ID + "  Order of  " + Order);

      initBrowsersession1();

      Pageobject_del lpob = new Pageobject_del(browser);
      lpob.Commonprocess_item_cat_del(uname, pwd); // ,curr_name);//, Pwd);
      String Actual_Res = lpob.Invalid_delete_blnk();

      sAssert.assertEquals(Exp_Res, Actual_Res);

      if (Actual_Res.equals(Exp_Res)) {

        log.info("Passed as Expected msg was Valid");

      } else {
        log.info("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
        sAssert.fail("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
      }

      tearDown();
      sAssert.assertAll();
      log.info("******************************************");
    }
  }
Ejemplo n.º 5
0
  @Test(
      dataProvider = "Valid_mul_item_cat_del",
      dataProviderClass = Dataprovider_item_cat.DataProvider_del.class,
      groups = {"branch"})
  public void Valid_mul_item_cat_del(String TC_ID, String Order, String Exp_Res)
      throws IOException, InterruptedException {
    String uname = c1.Reading_Properties("uname");
    String pwd = c1.Reading_Properties("pwd");
    log.info("Executing the testcase " + TC_ID + "  Order of  " + Order);
    // System.out.println("hi");
    initBrowsersession1();

    Pageobject_del lpob = new Pageobject_del(browser);
    lpob.Commonprocess_item_cat_del(uname, pwd);
    String Actual_Res = lpob.Valid_mul_item_cat_del();
    sAssert.assertEquals(Exp_Res, Actual_Res);

    if (Actual_Res.equals(Exp_Res)) {
      log.info("Passed as Expected msg was Valid");
    } else {
      log.info("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
      sAssert.fail("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
    }
    tearDown();
    sAssert.assertAll();
    log.info("******************************************");
  }
Ejemplo n.º 6
0
  @Test(
      dataProvider = "dp_Invalidskill",
      dataProviderClass = Dataprovider_Employ_skill.DataProvider_create.class,
      groups = {"employ_SkillSet"})
  public void test_Invalidskill(
      String TC_ID, String Order, String skill_name, String desp, String Exp_Res)
      throws IOException {
    String uname = c1.Reading_Properties("uname");
    String pwd = c1.Reading_Properties("pwd");
    log.info("Executing the testcase " + TC_ID + "  Order of  " + Order);
    // System.out.println("hi");
    initBrowsersession1();
    Pageobject_create lpob = new Pageobject_create(browser);
    lpob.Commonprocessskill(uname, pwd, TC_ID, skill_name, desp); // , Pwd);
    String Actual_Res = lpob.getInvalidskillResult();
    sAssert.assertEquals(Exp_Res, Actual_Res);

    if (Actual_Res.equals(Exp_Res)) {
      log.info("Passed as Expected msg was Valid");
    } else {
      log.info("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
      sAssert.fail("Failed as Expected msg was " + Exp_Res + "Actual msg was   " + Actual_Res);
    }
    tearDown();
    sAssert.assertAll();
    log.info("******************************************");
  }
 /** Test the list feed instances api using an orderBy parameter. Check the order. */
 @Test
 public void testFeedOrderBy()
     throws URISyntaxException, OozieClientException, JAXBException, AuthenticationException,
         IOException, InterruptedException {
   SoftAssert softAssert = new SoftAssert();
   // orderBy start time
   InstancesResult r =
       prism.getFeedHelper().listInstances(feedName, "orderBy=startTime&sortOrder=desc", null);
   InstancesResult.Instance[] instances = r.getInstances();
   Date previousDate = new Date();
   for (InstancesResult.Instance instance : instances) {
     Date current = instance.getStartTime();
     if (current != null) { // e.g if instance is WAITING it doesn't have start time
       softAssert.assertTrue(
           current.before(previousDate) || current.equals(previousDate),
           "Wrong order. Current startTime :" + current + " Previous: " + previousDate);
       previousDate = (Date) current.clone();
     }
   }
   // orderBy status
   r =
       prism
           .getFeedHelper()
           .listInstances(
               feedName,
               "start=" + startTime + "&numResults=12&orderBy=status&sortOrder=desc",
               null);
   InstanceUtil.validateResponse(r, 12, 1, 1, 4, 6);
   instances = r.getInstances();
   InstancesResult.WorkflowStatus previousStatus = InstancesResult.WorkflowStatus.WAITING;
   for (InstancesResult.Instance instance : instances) {
     InstancesResult.WorkflowStatus current = instance.getStatus();
     softAssert.assertTrue(
         current.toString().compareTo(previousStatus.toString()) <= 0,
         "Wrong order. Compared " + current + " and " + previousStatus + " statuses.");
     previousStatus = current;
   }
   // sort by endTime
   r =
       prism
           .getFeedHelper()
           .listInstances(
               feedName,
               "start=" + startTime + "&numResults=12&orderBy=endTime&sortOrder=desc",
               null);
   instances = r.getInstances();
   previousDate = new Date();
   for (InstancesResult.Instance instance : instances) {
     Date current = instance.getEndTime();
     if (current != null) { // e.g if instance is WAITING it doesn't have end time
       softAssert.assertTrue(
           current.before(previousDate) || current.equals(previousDate),
           "Wrong order. Current startTime :" + current + " Previous: " + previousDate);
       previousDate = (Date) current.clone();
     }
   }
   softAssert.assertAll();
 }
  // Accepts 3 column's String data In every Iteration.
  @Test(dataProvider = "SuiteTwoCaseOneData")
  public void SuiteTwoCaseOneTest(String DataCol1, String DataCol2, String ExpectedResult) {

    DataSet++;

    // Created object of testng SoftAssert class.
    s_assert = new SoftAssert();

    // If found DataToRun = "N" for data set then execution will be skipped for that data set.
    if (!TestDataToRun[DataSet].equalsIgnoreCase("Y")) {
      // If DataToRun = "N", Set Testskip=true.
      Testskip = true;
      throw new SkipException(
          "DataToRun for row number " + DataSet + " Is No Or Blank. So Skipping Its Execution.");
    }

    // If found DataToRun = "Y" for data set then bellow given lines will be executed.
    // To Convert data from String to Integer
    int ValueOne = Integer.parseInt(DataCol1);
    int ValueTwo = Integer.parseInt(DataCol2);
    int ExpectedResultInt = Integer.parseInt(ExpectedResult);

    // To Initialize Firefox browser.
    loadWebBrowser();

    driver.get(Param.getProperty("siteURL") + "/2014/04/calc.html");
    getElementByName("txt_Result").clear();
    getElementByXPath("btn_Calc_PrePart", ValueOne, "btn_Calc_PostPart").click();
    getElementByID("btn_multiply").click();
    getElementByXPath("btn_Calc_PrePart", ValueTwo, "btn_Calc_PostPart").click();
    getElementByCSS("btn_Equals").click();
    String Result = getElementByName("txt_Result").getAttribute("value");
    int ActualResultInt = Integer.parseInt(Result);
    if (!(ActualResultInt == ExpectedResultInt)) {
      Testfail = true;
      s_assert.assertEquals(
          ActualResultInt,
          ExpectedResultInt,
          "ActualResult Value "
              + ActualResultInt
              + " And ExpectedResult Value "
              + ExpectedResultInt
              + " Not Match");
    }

    if (Testfail) {
      // At last, test data assertion failure will be reported In testNG reports and It will mark
      // your test data, test case and test suite as fail.
      s_assert.assertAll();
    }
  }
Ejemplo n.º 9
0
  public void Prod_verifyAA(WebDriver dr, Date idString, SimpleDateFormat ft) {
    WebDriverWait wait = new WebDriverWait(dr, 10);
    SoftAssert softassert = new SoftAssert();
    WebElement ele;
    String eletext;

    dr.get(ProdUrl.INBOX + "140539755/"); // MID for [email protected] || asdf1231
    ele = dr.findElement(By.cssSelector(Inbox.RecievedUsername_Text_ELE));
    eletext = ele.getText();
    softassert.assertEquals(eletext, "ProdimusPrime7");
    ele = dr.findElement(By.cssSelector(Inbox.RecentRecieved_Text_ELE));
    eletext = ele.getText();
    softassert.assertEquals(eletext, inputtext + ft.format(idString));
    softassert.assertAll();
  }
Ejemplo n.º 10
0
  public void STG_verifyAA(WebDriver dr, Date idString, SimpleDateFormat ft) {
    WebDriverWait wait = new WebDriverWait(dr, 10);
    SoftAssert softassert = new SoftAssert();
    WebElement ele;
    String eletext;

    dr.get(stageUrl.INBOX + "1127786087/");
    ele = dr.findElement(By.cssSelector(Inbox.RecievedUsername_Text_ELE));
    eletext = ele.getText();
    softassert.assertEquals(eletext, "Tortuga");
    ele = dr.findElement(By.cssSelector(Inbox.RecentRecieved_Text_ELE));
    eletext = ele.getText();
    softassert.assertEquals(eletext, inputtext + ft.format(idString));
    softassert.assertAll();
  }
Ejemplo n.º 11
0
 @Test(enabled = false)
 public void assertionTest() throws Exception {
   setUp(RecipeExecLocation.SourceCluster);
   final SoftAssert anAssert = new SoftAssert();
   HiveAssert.assertTableEqual(
       cluster,
       clusterHC.getTable("default", "hcatsmoke10546"),
       cluster2,
       clusterHC2.getTable("default", "hcatsmoke10548"),
       anAssert);
   HiveAssert.assertDbEqual(
       cluster,
       clusterHC.getDatabase("default"),
       cluster2,
       clusterHC2.getDatabase("default"),
       anAssert);
   anAssert.assertAll();
 }
  public void PerformanceTabTest() {
    Reporter.log("In to PerformanceTabTest");
    logger.info("Switching to Performance Tab");
    PerformanceTab.click();
    logger.info("Fetching Performance Cycle duration");
    logger.info(PerformanceCycle.getText());
    logger.info("Fetching Performance Details");
    List<WebElement> EmployeePerformanceDetails =
        driver.findElements(By.xpath(Constants.Employeedetaillistxpath));
    for (int i = 0; i < EmployeePerformanceDetails.size(); i++) {
      logger.info(EmployeePerformanceDetails.get(i).getText());
      System.out.println(
          "Employee Performance Details " + EmployeePerformanceDetails.get(i).getText());
    }
    logger.info("Navigating user to Performance Review section");
    s_assert.assertNotNull(
        EmployeePerformanceDetails.get(0).findElement(By.tagName("a")), "First employee not found");
    EmployeePerformanceDetails.get(0).findElement(By.tagName("a")).click();
    logger.info("Displaying Review Information");
    logger.info(Section1.getText());
    logger.info(Userinfo.getText());
    logger.info(Section2.getText());
    logger.info("Switching to Self Review Tab");
    Selfreviewsection.click();
    List<WebElement> THeader = driver.findElements(By.xpath(Constants.TableHeaderxpath));
    for (int j = 0; j < THeader.size(); j++) {
      logger.info(THeader.get(j).getText());
      System.out.println("Printing table header " + THeader.get(j).getText());
    }

    List<WebElement> Ratings = driver.findElements(By.xpath(Constants.ActualTablexpath));
    int count = Ratings.size();
    for (int k = 0; k < Ratings.size(); k++) {
      logger.info(Ratings.get(k).getText());
      System.out.println("Printing real ratings " + Ratings.get(k).getText());
    }
    if (count == 0) {
      s_assert.fail("User does not have any ratings");
    }
    s_assert.assertAll();
  }
Ejemplo n.º 13
0
  public void assertText() {
    System.out.println("Assert that the text is present " + actual);

    softAssert.assertEquals(actualText, actual, "Failed to assert an element");
  }
 public static SoftAssert softAssertion(Boolean condition) {
   SoftAssert softAssert = new SoftAssert();
   softAssert.assertTrue(condition);
   return softAssert;
   // softAssert.assertAll();
 }
  /**
   * Test list feed instances using custom filter. Expecting list of feed instances which satisfy
   * custom filters.
   */
  @Test
  public void testFeedCustomFilter()
      throws URISyntaxException, IOException, AuthenticationException, InterruptedException {
    String params = "start=" + startTime + "&filterBy=status:RUNNING";
    InstancesResult r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 1, 1, 0, 0, 0);

    params = "start=" + startTime + "&end=" + endTime + "&filterBy=status:RUNNING&offset=2";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateSuccessWOInstances(r);

    params = "start=" + startTime + "&end=" + endTime + "&filterBy=status:WAITING";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 4, 0, 0, 4, 0);

    params =
        "start="
            + startTime
            + "&end="
            + TimeUtil.addMinsToTime(startTime, 41)
            + "&filterBy=status:WAITING";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 3, 0, 0, 3, 0);

    params = "start=" + startTime + "&offset=1&numResults=1&filterBy=status:WAITING";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 1, 0, 0, 1, 0);

    params = "start=" + TimeUtil.addMinsToTime(startTime, 16) + "&offset=2&numResults=12";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 6, 0, 1, 3, 2);

    String sourceCluster = bundles[0].getClusterNames().get(0);
    String clusterName = bundles[1].getClusterNames().get(0);
    params =
        "start="
            + startTime
            + "&filterBy=STATUS:KILLED,CLUSTER:"
            + clusterName
            + "&numResults=5&orderBy=startTime&sortOrder=desc";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 5, 0, 0, 0, 5);

    // should be ordered by a start time
    SoftAssert softAssert = new SoftAssert();
    InstancesResult.Instance[] instances = r.getInstances();
    Date previousDate = new Date();
    for (InstancesResult.Instance instance : instances) {
      Date current = instance.getStartTime();
      softAssert.assertNotNull(current, "Start time shouldn't be null for KILLED instance.");
      softAssert.assertTrue(
          current.before(previousDate) || current.equals(previousDate),
          "Wrong order. Current startTime :" + current + " Previous: " + previousDate);
      previousDate = (Date) current.clone();
    }
    softAssert.assertAll();

    // missing 1st, 11th, 12th instances, all other instances should be retrieved.
    params = "start=" + TimeUtil.addMinsToTime(startTime, 2) + "&offset=2";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 9, 0, 1, 3, 5);

    // missing the 1st, 11th, 12th instance, all instances which have progressed should be present:
    // 5 killed + 1 suspended, but numResults=5, so expecting 1 suspended and 4 killed instances.
    params =
        "start="
            + TimeUtil.addMinsToTime(startTime, 2)
            + "&filterBy=SOURCECLUSTER:"
            + sourceCluster
            + "&offset=1&numResults=5";
    r = prism.getFeedHelper().listInstances(feedName, params, null);
    InstanceUtil.validateResponse(r, 5, 0, 1, 0, 4);
  }