Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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 ...
PDHide's user avatar
  • 11.1k
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 ...
Niels van Reijmersdal's user avatar
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(&...
beatngu13's user avatar
  • 2,132
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 ...
Alexey R.'s user avatar
  • 11.6k
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 ...
Alexey R.'s user avatar
  • 11.6k
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() ...
Klynt's user avatar
  • 544
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 ...
501NotImplemented's user avatar
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()...
Bill Hileman's user avatar
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, ...
Bharat Mane's user avatar
  • 6,775
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 ...
Jose's user avatar
  • 191
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 ...
Peter M. - stands for Monica's user avatar
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 ...
Niels van Reijmersdal's user avatar
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. ...
Mykola Gurov's user avatar
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 "...
Yu Zhang's user avatar
  • 9,942
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 (\...
demouser123's user avatar
  • 3,532
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 ...
Jeroen Lamberts's user avatar
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 ...
Michael Durrant's user avatar
1 vote
Accepted

How to solve AssertionError in Selenium Python?

your text has a special character so you cannot convert to float see the error ValueError: could not convert string to float: Total Amount: $6.00 so the value of subtotalamt is Total Amount: $6.00 ...
PDHide's user avatar
  • 11.1k
1 vote
Accepted

How to compare big objects with FluentAssertsions?

I found an solution for comparing larger objects (specific to my case, since it's actually part of FluentAssertions). https://fluentassertions.com/objectgraphs/ From the documentation, it compares ...
Claudiu A's user avatar
  • 209
1 vote
Accepted

Assertion on static value or calculated one

Think from this perspective, lets say there is a function, Foo that takes in as input a set of values, say I and gives an output O. So, we have n equation like, O = Foo(I). Additionally, we are ...
Sumit Kumar's user avatar
1 vote
Accepted

NUnit Assert.This(obj, method) for C# - where to find list of evaluation methods?

Yes, if you want to use nUnit the Assert.That is the future, no new features will be added to the old model according to the documentation on GitHub: In NUnit 3.0, assertions are written primarily ...
Niels van Reijmersdal's user avatar
1 vote
Accepted

How to use assertion to compare both different size of the rows?

If you want to compare your these two variables then use this - Assert.assertEquals(firstnum, secondnum); In this line of code lets assume that firstnum is your actual value and secondnum is your ...
Upkar Singh's user avatar
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 ...
Zhivko.Kostadinov's user avatar
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. ...
Kate Paulk's user avatar
  • 31.5k
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'] }...
ammon0's user avatar
  • 11
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
João Farias's user avatar
  • 10.9k
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)
Marit's user avatar
  • 356
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())) { ...
Vel Guru's user avatar
  • 526
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(), ...
Narendra Chandratre's user avatar
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: ...
Michael Durrant's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible