If...Else statement not working as expected

2 posts, 1 answers
  1. ching ping
    ching ping avatar
    3 posts
    Member since:
    Sep 2010

    Posted 01 Dec 2010 Link to this post


    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?
  2. Answer
    Keaegan avatar
    126 posts

    Posted 02 Dec 2010 Link to this post

    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,
    the Telerik team

    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Back to Top