If statements

Thursday, July 27, 2023
Avatar

Hello,

 

I have been learning a bit about automation and javascript. I am very much a novice so I appoligige if this question is dub. I am trying to do an if statement to verify text but I can't get it to run. Could somone advise me on how to get this working?

 

if (Tester.AssertEqual("Verify that: Text=Log In", SeS('Log_In').GetText(), "Log In") == "Log In");

    {    Tester.AssertEqual("Verify that: Text=Log In", SeS('Log_Out').GetText(), "Log In");    }

   else       

{        Tester.AssertEqual("Num2", SeS('Log_Out').GetText(), "Log In");        }

1 Replies
Friday, July 28, 2023
Avatar
re: sharris Thursday, July 27, 2023

Hi Sharris,

If you do just if statement then in JavaScript it will be

if( SeS('Log_In').GetText() == "Log In" )
{
	Tester.Message("Inside if statement");
}


// or

if( SeS('Log_In').GetText() == "Log In" )
{
	Tester.Message("Inside if statement");
}
else
{
    Tester.Message("Inside else branch");
}

Also you may do an Assert statement

Tester.AssertEqual("Verify that: Text=Log In", SeS('Log_In').GetText(), "Log In" );

Regards,
Max

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Thursday, July 27, 2023
  • Last Reply: Friday, July 28, 2023
  • Replies: 1
  • Views: 739