1

I'm getting the text as string and i need to compare it with a number, If its grater than that number then execute an if statement and if not then else.

I'm using following code :

string sato = driver.FindElement(By.CssSelector(".user_reward_points")).Text;
if (sato > 1200)
{
     driver.FindElement(By.CssSelector("#free_points_rewards > .effect2:nth-
    child(2) .large-3:nth-child(3) > .reward_link_redeem_button_style")).Click();
}
4
  • Parse the String as an Integer. Oct 9, 2018 at 3:06
  • 4
    I'm voting to close this question as off-topic because this is a software developement question. Oct 9, 2018 at 14:48
  • There is nothing specific to selenium in this question. Oct 10, 2018 at 0:33
  • The code does not reflect good test practice and the criteria for expected behaviour are unclear. Please make an effort to clarify your question. Oct 10, 2018 at 17:13

1 Answer 1

1

You need to parse string value to an integer. Try the below code:

String sato = driver.FindElement(By.CssSelector(".user_reward_points")).Text;
if (Int32.Parse(sato)> 1200)
{
    driver.FindElement(By.CssSelector("#free_points_rewards > 
   .effect2:nth-child(2) .large-3:nth-child(3) > .reward_link_redeem_button_style")).Click();
}

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