8
votes
Exception in thread "main" java.lang.AssertionError: expected [3] but found [3]
Hi size() returns integer and you are comparing with string
You can use the size() method of java. util. ArrayList to find the
length or size of ArrayList in Java. The size() method returns an
...
7
votes
How to verify data is saved or not using selenium?
How do users verify the data is saved? I would make the test take the same path.
In your case placing an order might result into an item in the checkout shopping-basket. Find elements in the ...
5
votes
How to print a message after checking through TestNG's Assert.assertEquals method?
The easiest way is to wrap the assertion within a try-catch block, something like:
try {
Assert.assertEquals(actualString, expectedString);
} catch (AssertionError e) {
System.out.println(&...
4
votes
How to print a message after checking through TestNG's Assert.assertEquals method?
The best practice of TestNg behavior overriding is using so called listeners. For example you can override the dafault behavior of what is happenning when your assert fails. To do that you need to ...
4
votes
JUnit Assert's message equivalent implementation using Selenium Webdriver's wait method
As it seems to me, the most close equivalent to JUnit assertion messages is withMessage() method introduced in FluentWait class. Below is the example of how I use it:
public class Test {
public ...
3
votes
Accepted
Assertion message with TestNG
I don't know that there's necessarily a better or cleaner way than your example, but I can offer at least one alternative:
Boolean saved = webDriver.findElement(By.name("CreatePostbox")).isDisplayed()...
3
votes
How to verify a success message using selenium webdriver?
First two points: I cannot see any "Dear admin" in the message and instead of "assertEquals" try "assertTrue" and "contains". Then try:
String expectedMessage = "The Institution is deleted ...
3
votes
Accepted
[Selenium]getAttribute using "textContent" - assertion fails when 'equals' is used but works when 'contains' is used
Obviously, label contains some extra characters beyond "Login ID". Could be spaces. Print it out to find out what it is.
Your problem is (IMHO) not being new to Selenium but being new to programming ...
3
votes
How to test forgot password link?
If you want to test it end-2-end you can use a service like https://mailtrap.io/
Here you can use an API to retrieve the email and extract the link and open the link with Selenium.
Still I am ...
3
votes
Assert in TestNG (Actual int value, Expected int value)
public static void assertEquals(int actual,
int expected,
java.lang.String message)
Asserts that two ints are equal. If they are not, ...
3
votes
How do I verify a Link URL using Selenium Webdriver / TestNG?
I can see multiple solutions:
Parse HTML page you test, e.g., with some XML+XPath+JSoup libraries, and check whether element you selected has a right link. This will not work with XHR/AJAX requests, ...
3
votes
How to use assertion to compare both different size of the rows?
There are a few different ways to achieve that depending on how you prefer to do things:
As another person has commented you don't appear to need those int declarations, so can just use the .size() ...
3
votes
Assertion on static value or calculated one
I would consider the whole idea of verifying such logic from the UI perspective as a bad practice. See info on test pyramid.
If you need to test the calculation logic of your service - you can do ...
2
votes
Accepted
Assertion about size of an XML tag
Regexp is your friend
matches(//ns:XPathToIt/ns:password,'\w{7,}')
The \w{7,} will match a string with 7 characters. In the Expected Result put "true".
SoapUI Assertions
2
votes
Assert in TestNG (Actual int value, Expected int value)
The TestNG Assert documentation describes a function assertNotEquals
Assert.assertNotEquals(length, 0);
This does what you want I guess, if not you can also check with assertEquals with some extra ...
2
votes
Efficient way to test data quality of database through java?
You might want to take look at the DataTable of cucumber-jvm since you've been using it anyway. The idea is to use one of its diff methods to compare the expected to the actual state of the database.
...
2
votes
Accepted
How to write Assertion in Selenium Cucumber BDD?
You need to import Junit.Assert in your Step Definition file and then you can use them as normal assert statements inside the Step Implementation.
For example,
@Then("^the total price should be (\...
2
votes
Accepted
What elements should I assert for automation of my eCommerce application?
It depends on your testing objectives, the number of verifications you can do to a website is infinite.
We have no background knowledge about your project so it is hard for us to understand what "...
2
votes
How to verify data is saved or not using selenium?
I agree with Niels` suggestion of checking the database. An alternative could be refreshing the page, or navigating back and forth and asserting that you still see the value. That would imply that the ...
2
votes
Accepted
Is it necessary to Assert web page title in every case?
NO, don't litter tests with loads of asserts.
Have one test that you have reached the correct page.
Other tests should navigate to the page and then perform additional actions which are tested. If ...
1
vote
How to assert checkbox is marked using JavaScript
I can't add this as a comment, because I don't have enough reputation. So, try this:
async t => { await t .click(checkbox) .expect(checkbox.checked).ok(); })
The Xpath which you are using is too ...
1
vote
How to assert checkbox is marked using JavaScript
Without more information I can't be certain, but the HTML you've given suggests that instead of an actual HTML field, there's fancy javascript and CSS being used to give the appearance of a checkbox.
...
1
vote
how to enable assertions through the Gradle Kotlin DSL?
You must enable assertions via the -ea flag.
application {
// Define the main class for the application
mainClassName = "App"
// enable assertions
applicationDefaultJvmArgs = ['-ea']
}...
1
vote
Unresolved reference: enableAssertions
You would need to specify the flag for the JUnit platform. Reference on the following answer: https://stackoverflow.com/a/48178018
1
vote
How to convert a String to int on assert
To get the string value of an int, you can use: String.valueOf(int)
1
vote
Unable to open an .xlsx file with script in Selenium WebDriver - getting InvalidFormatException
Use file extension to handle WorkSheet Type
String inputFilename = new File(path).getName();
switch (inputFilename.substring(inputFilename.lastIndexOf(".") + 1,
inputFilename.length())) {
...
1
vote
How to verify the body context using Assert command
Assert :
Reminder : If Assert get failed the execution or program get terminated there itself.
It can be used as follows:
Assert.assertEquals(driver.findElement(By.id("your_element_id")).getText(), ...
1
vote
How to verify a success message using selenium webdriver?
I look to use css first and for the elements and attributes I try to be as specific as needed without being overly specific and tying myself into page structure. In this case I would consider using:
...
1
vote
Is it possible to display the assertion results in the View Results Tree listener itself in Jmeter?
View Results Tree Listener displays failed assertions:
If you're doing some functional testing with low number of virtual users (threads) and need to see verbose assertion results you need to choose ...
1
vote
What is the use of waitForPageLoad() method in Framework when our test scripts don't execute unless the page is loaded by default
But why to write this method as the selenium scripts doesn't execute
when we navigate to next page and the page isn't loaded completely.
Ok I totally get why you feel that piece of code is trivial. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
assert × 48selenium-webdriver × 28
automated-testing × 21
java × 18
testng × 11
soapui × 3
jmeter × 2
selenium2 × 2
xpath × 2
cucumber × 2
uiautomation × 2
junit × 2
learning × 2
integration-testing × 2
validation × 2
files × 2
verify × 2
test-management × 1
python × 1
test-design × 1
c# × 1
test-automation-framework × 1
javascript × 1
selenium-ide × 1
functional × 1