Reputation: 501
I need to check if a searchresult is more than 500. I can get the actual search result to print, but I'm having some trouble with the assertion that it is actually more than 500. This is what I have:
public void cucumberstuffblabla(Integer expectednumber) throws Throwable {
waitForElementPresent(By.locator);
int givennumber = Integer.parseInt(driver.findElement(By.locator)).getText());
Assert.assertTrue (givennumber, greaterThan(expectednumber));
Assuming the execptednumber integer is 500, the Assert is never giving me a propper assertion, but always a CannotResolveMethod.
Upvotes: 2
Views: 5233
Reputation: 77
Your code has answer of your question, just update your one line from
Assert.assertTrue (givennumber, greaterThan(expectednumber));
to
Assert.assertTrue(givennumber < expectednumber);
Upvotes: 1
Reputation: 1338
if you pass two arguments to AssertTrue it expects one is a message to print on failure. Here is the method signature:
assertTrue(java.lang.String message, boolean condition)
What you want to do is pass a boolean condition and optionally a message, so:
Assert.assertTrue("Given is less then expected", givennumber > expectednumber);
Upvotes: 0