This is a migrated thread and some comments may be shown as answers.

If...Else statement not working as expected

1 Answer 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ching ping
Top achievements
Rank 1
ching ping asked on 02 Dec 2010, 04:55 AM
Hi,

I tried to record a test with logical If...Else statement but encounter some problem here.

My test steps:
1. navigate to www.random.org
2. set the max value of true random number generator to 2
3. click on the 'Generate' button
4. if (verify the result generated contains 2),
5. then navigate to www.google.com
6. else,
7. navigate to www.yahoo.com

I noticed that my tests will always execute step 6,7 and never go to step 5 even the generated integer is 2. I suspect that WebUI dun even wait for the result generated to be populated, and tht is why step 4 will always be false and will always go to step 6. I tried to use 'Wait for textcontent contains 2' instead of 'verify textcontent contains 2'  before i add this verify step into the if statement, but it still give me the same result.

Did i miss out anything here? Any advice?

1 Answer, 1 is accepted

Sort by
0
Accepted
Keaegan
Telerik team
answered on 03 Dec 2010, 12:38 AM

Hi ching ping,

You are most likely correct with your assumption (since no value would be the same as not a 2), in that your test will run better if you input an execution delay before the If...Else logic occurs. 

I am attaching a copy of the test I made that is executing your suggested steps correctly. Please feel free to review it and compare it to your own to ensure that you are setting up the If...Else logic correctly. I tested this numerous times to confirm this was working correctly, please let me know if you are still seeing the same issues when using my version of this test.

Kind regards,
Keaegan
the Telerik team

Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Tags
General Discussions
Asked by
ching ping
Top achievements
Rank 1
Answers by
Keaegan
Telerik team
Share this question
or