I want both size of the rows shouldn't be matched.

int firstnum = 0;
        List<WebElement> preRoutlList = driver.findElements(By.xpath("//*[@id='txBottomTable']/table/tbody/tr"));
        firstnum = firstnum + preRoutlList.size();

 int secondnum = 0;
        List<WebElement> aftRoutlList = driver.findElements(By.xpath("//*[@id='txBottomTable']/table/tbody/tr"));
        secondnum = secondnum + aftRoutlList.size();

2 Answers 2


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 expected value

  • You do not need to declare any variables and I think whats OP is asking is to check if they don't match.
    – Moro
    May 15, 2019 at 9:12
  • Actually I was comparing both size shouldn't be match. I got the solution Assert.assertNotEquals(firstnum, secondnum, "Rows was not updated");
    – Samira
    May 15, 2019 at 9:15

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() call.

//Assert false that one equals the other

//Assert True that one doesn't equal the other

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.