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

Method to test a successfully condition

2 Answers 36 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.
Alex
Top achievements
Rank 1
Alex asked on 09 Dec 2010, 09:25 PM

I'm having trouble figuring out a way to test if a successful message was received from my code. I know the code below is incorrect, I just can't seem to figure out a way to make it work.

What I would like it to do is to wait 10 sec for the text 'Successful' to display and when it doesn't refresh the search and check again, repeat as necessary. I'm having trouble determining a way to test the successful condition.

[CodedStep(@"Wait for Successful completion of processing")]
        public void CO_CBCOMP_AU_SA_EN_VerifyFunctionalityBlowup_CodedStep4()
        {
  
            HtmlSpan UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan = Pages.UMDealerBusiness7.UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan;
  
            int n = 0;
            while ( n < 1)
            {            
            UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan.Wait.ForExists(10000);
            Wait.For<HtmlSpan>(c => c.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "Successful"), UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan, 10000);
  
            if (UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan = "Successful")
            {
                n++;
            }
            else
            Actions.InvokeScript("javascript:__doPostBack('UserControl9921DBIREVIEWCOMPOSITEQUEUE$searchLinkButton','')");
            }
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 11 Dec 2010, 05:17 AM
Hello Alex,

Try this code instead:

[CodedStep(@"Wait for Successful completion of processing")]
public void CO_CBCOMP_AU_SA_EN_VerifyFunctionalityBlowup_CodedStep4()
{
    int numTries = 10;
    HtmlSpan UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan = Pages.UMDealerBusiness7.UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan;
    int n = 0;
    while (n++ < numTries)
    {
        UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan.Wait.ForExists(10000);
        try
        {
            Wait.For<HtmlSpan>(c => c.TextContent.Contains("Successful"), UserControl9921DBIREVIEWCOMPOSITEQUEUEReviewCompositeQueueListJobStatusSpan, 10000);
        }
        catch (TimeoutException)
        {
            Assert.AreNotEqual(n, numTries);
            Actions.InvokeScript("javascript:__doPostBack('UserControl9921DBIREVIEWCOMPOSITEQUEUE$searchLinkButton','')");
        }
    }
}

If any part of the code is unclear to you don't hesitate to ask about it.

Regards,
Cody
the Telerik team
Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
0
Alex
Top achievements
Rank 1
answered on 16 Dec 2010, 11:12 PM
Hi Cody,

It works perfectly, Thank you for the support!
Tags
General Discussions
Asked by
Alex
Top achievements
Rank 1
Answers by
Cody
Telerik team
Alex
Top achievements
Rank 1
Share this question
or