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. – Aulis Ronkainen Oct 9 '18 at 3:06
  • 4
    I'm voting to close this question as off-topic because this is a software developement question. – João Farias Oct 9 '18 at 14:48
  • There is nothing specific to selenium in this question. – Vishal Aggarwal Oct 10 '18 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. – Martin Spamer Oct 10 '18 at 17:13
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.