org.testng.asserts.SoftAssert Java Examples
The following examples show how to use
org.testng.asserts.SoftAssert.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElementTests.java From aquality-selenium-java with Apache License 2.0 | 6 votes |
@Test public void testTextBox() { navigate(TheInternetPage.LOGIN); FormAuthenticationForm authenticationForm = new FormAuthenticationForm(); SoftAssert softAssert = new SoftAssert(); ITextBox txbUsername = authenticationForm.getTxbUsername(); txbUsername.focus(); txbUsername.type("wrong"); softAssert.assertEquals(txbUsername.getValue(), "wrong"); ITextBox txbPass = authenticationForm.getTxbPassword(); txbPass.sendKeys(Keys.NUMPAD0); softAssert.assertEquals(txbPass.getValue(), "0"); txbPass.submit(); String expectedValue = ""; boolean result = AqualityServices.getConditionalWait().waitFor(() -> txbPass.getValue().equalsIgnoreCase(expectedValue), "Value of textbox should be equal " + expectedValue); softAssert.assertTrue(result); softAssert.assertAll(); }
Example #2
Source File: AbstractBackupE2ETest.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
/** * Will assert that @param count files starting with @param filePrefix are found * inside @param folder */ protected File[] assertFileExistInLocalBackupFolder(String folder, String filePrefix, int count) { File backupLocation = Paths.get("./qa/search/backup/host-bkp", folder).toFile(); Assert.assertTrue(backupLocation.exists(), "Backup location exists: " + backupLocation.getAbsolutePath()); if (count >= 1) { Assert.assertEquals(backupLocation.listFiles().length, count, "Expected Files in folder:" + backupLocation.getPath()); SoftAssert soft = new SoftAssert(); for (File file : backupLocation.listFiles()) { soft.assertTrue(file.getName().startsWith(filePrefix), String.format("File [%s] starts with prefix: %s", file.getPath(), filePrefix)); } soft.assertAll(); return backupLocation.listFiles(); } else { Assert.assertEquals(backupLocation.listFiles().length, 0, backupLocation.getPath() + "should be empty!"); } return null; }
Example #3
Source File: ArrayConcatTest.java From morpheus-core with Apache License 2.0 | 6 votes |
private void assertArrayElementEqualsTo( final Array<DataFrame<Integer, Month>> array, final DataFrame<Integer, Month> ...elements) { if(array.length() != elements.length){ throw new IllegalArgumentException("Parameters array and elements must have the same length"); } final SoftAssert softAssert = new SoftAssert(); for (int i = 0; i < array.length(); i++) { softAssert.assertEquals(array.getValue(i), elements[i],"Element "+i+" of the array: "); } softAssert.assertAll(); }
Example #4
Source File: ShoppingCartTest.java From aquality-selenium-java with Apache License 2.0 | 4 votes |
@Test public void testShoppingCart() { AqualityServices.getBrowser().getDriver().navigate().to(URL_AUTOMATIONPRACTICE); SoftAssert softAssert = new SoftAssert(); SliderForm sliderForm = new SliderForm(); Assert.assertTrue(sliderForm.isDisplayed()); sliderForm.clickBtnNext(); sliderForm.clickBtnNext(); ProductListForm productListForm = new ProductListForm(); List<ILabel> productList = productListForm.getProductContainerLabels(); softAssert.assertEquals(productList.size(), 7); productListForm.addToCardRandomProduct(); ProceedToCheckoutModal proceedToCheckoutModal = new ProceedToCheckoutModal(); proceedToCheckoutModal.getBtnProceedToCheckout().getJsActions().clickAndWait(); ShoppingCardSummaryForm shoppingCardSummaryForm = new ShoppingCardSummaryForm(); shoppingCardSummaryForm.getBtnPlus().getJsActions().click(); Integer expectedQuantity = 2; Integer actualQuantity = shoppingCardSummaryForm.waitForQuantityAndGetValue(expectedQuantity); softAssert.assertEquals(expectedQuantity, actualQuantity, "Quantity is not correct"); shoppingCardSummaryForm.clickProceedToCheckoutBtn(); softAssert.assertTrue(new AuthenticationForm().isDisplayed()); CartMenuForm cartMenuForm = new CartMenuForm(); cartMenuForm.openCartMenu(); cartMenuForm.clickCheckoutBtn(); shoppingCardSummaryForm.clickProceedToCheckoutBtn(); AuthenticationForm authenticationForm = new AuthenticationForm(); authenticationForm.setEmail(getUserEmail()); authenticationForm.clickCreateAccountBtn(); YourPersonalInfoForm yourPersonalInfoForm = new YourPersonalInfoForm(); yourPersonalInfoForm.selectGender(1); yourPersonalInfoForm.setFirstName(USER_FIRST_NAME); Integer expectedNumOfDays = 32; Integer actualNumOfDays = yourPersonalInfoForm.getNumOfDays(); softAssert.assertEquals(expectedNumOfDays, actualNumOfDays, "Num of days from combobox is not correct"); yourPersonalInfoForm.selectState(STATE); yourPersonalInfoForm.selectDay(29); boolean expectedStateOfNewsChb = false; boolean actualStateOfNewsChb = yourPersonalInfoForm.getNewsCheckBoxState(); String errorMessage = "News checkbox state is not correct"; softAssert.assertEquals(expectedStateOfNewsChb, actualStateOfNewsChb, errorMessage); yourPersonalInfoForm.setNewsChb(); softAssert.assertTrue(yourPersonalInfoForm.getNewsCheckBoxState(), errorMessage); softAssert.assertTrue(yourPersonalInfoForm.isNewsCheckboxChecked(), errorMessage); softAssert.assertAll(); }