David Z
David Z

Reputation: 17

Selenium Java Junit - Assert if the result is greater than 1000

I am using Java Junit to verify the search result if greater than 1000

but Selenium can only storeText which is (String)

Than I try to convert (String) to (Int)

So that I can compare the search result(String) to 1000.

However, it doesn't work.

Also, I am not sure if I use assetThat in the right way.

Anyone knows the answer please help!

Thank you!

In Java code:

    String result = selenium.getText("css=span.rcnt");
    System.out.println("Search result is: " + result);

    int foo = Integer.parseInt(result);

    assertThat("Pass", foo, greaterThan(1000));

Upvotes: 0

Views: 4171

Answers (1)

ratsstack
ratsstack

Reputation: 1021

I don't use asserThat, preferring assertTrue.

However I see from link below that assertTrue has only two arguments:

http://www.objectpartners.com/2013/09/18/the-benefits-of-using-assertthat-over-other-assert-methods-in-unit-tests/

Try:

 assertThat(foo, greaterThan(1000);

Upvotes: 2

Related Questions