2

I am using the following method to parse some text on the page

getNumberText().getText()

and want to do a assert/comparison using greaterThanOrEqualTo

So How do I convert the getText() result to integer value for comparison?

1
  • Well this largely depends on the language being used? Which is what? Java? .NET? Ruby? Commented Jan 17, 2014 at 10:59

4 Answers 4

1

You could do the following, from this:

getNumberText().getText()

... create as one of answers was another method, which will return desired object in Your case int:

public int getNumber(){
    return Integer.parseInt(getNumberText().getText());
}

so usage would be:

Assert.assertTrue(getNumber(), intNumber);

Hope this helps,

Sign up to request clarification or add additional context in comments.

Comments

0

You need to Integer class to do this. Integer.parseInt(yourStringNumber). If the value is double then Double.parseInt(yourStringDouble).

Comments

0

int number = Integer.parseInt(getNumberText().getText());

In case that String is not parseable (thus not integer), NumberFormatException is thrown.

Comments

0
public int getNumberText(elem)
{
    return int.Parse(elem.Text());
}

element = driver.FindElement(By.Id("something"));

actual_result = getNumberText(element)

if (actual_result == expected_result)
{
   // do something
}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.