@Test
 public void testSoftAssert() {
   SoftAssert s = new SoftAssert();
   s.assertEquals(2 * 2, 3, "Three");
   s.assertEquals(2 * 2, 5, "Five");
   s.assertAll();
 }
Beispiel #2
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();
  }
Beispiel #3
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();
  }
 @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();
 }
  @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("******************************************");
  }
  @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("******************************************");
  }
  @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("******************************************");
    }
  }
  @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("******************************************");
  }
  // 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();
    }
  }
Beispiel #10
0
  public void assertText() {
    System.out.println("Assert that the text is present " + actual);

    softAssert.assertEquals(actualText, actual, "Failed to assert an element");
  }