NUnit Test problem

7 posts, 0 answers
  1. Wai-Kit
    Wai-Kit avatar
    4 posts
    Member since:
    Sep 2010

    Posted 02 Nov 2010 Link to this post

    Hi Telerik Team,

    I have a problem with the NUnit tests code after conversion from telerik web ui test.
    It is working perfectly fine running the test in telerik web ui test.
    However, it does not work after conversion to NUnit code.

    I have a test flow that occurs as below.
    1) Press a button that triggers a very long execution time(less than 5min)
    2) Wait for the button trigger to be over
    3) Compare the label control's Text for pass or fail.

    I have enabled the "Set As Wait" in telerik web ui test for step(2).
    However, i don't find this configuration/setting in the NUnit code for the WaitonElementsTimeout.

    Here's a sample of the NUnit Code for the above test flow

     

    // Click 'ContentPlaceHolder1BtnCaptureCommitmentButton'
    Pages.FactoryPlanningSystem_2.ContentPlaceHolder1BtnCaptureCommitmentButton.Click(false);
    // Wait for 'InnerText' 'Exact' 'Commitment Successfully Captured' on 'ContentPlaceHolder1LblCaptureCommitMessageSpan'
    HtmlSpan ContentPlaceHolder1LblCaptureCommitMessageSpan = Pages.FactoryPlanningSystem_2.ContentPlaceHolder1LblCaptureCommitMessageSpan;
    Wait.For<HtmlSpan>(c => c.AssertContent().InnerText(ArtOfTest.Common.StringCompareType.Exact, "Commitment Successfully Captured"), ContentPlaceHolder1LblCaptureCommitMessageSpan, 10000);

     

     

     

     

     

     

     

     

    Thanks
    Wai Kit

  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 04 Nov 2010 Link to this post

    Hello Wai-Kit,

    What error do you get when you run the NUnit version of the test?

    Your "Set as wait" step is present in your code, but perhaps you're not recognizing it. It is represented as these two lines of code:

    HtmlSpan ContentPlaceHolder1LblCaptureCommitMessageSpan = Pages.FactoryPlanningSystem_2.ContentPlaceHolder1LblCaptureCommitMessageSpan; 
     
    Wait.For<HtmlSpan>(c => c.AssertContent().InnerText(ArtOfTest.Common.StringCompareType.Exact, "Commitment Successfully Captured"), ContentPlaceHolder1LblCaptureCommitMessageSpan, 10000); 

    The number, 10000, is the wait timeout value. 10000 = 10 seconds. If your process takes a very long time, then this is the number you need to increase.

    Kind regards,
    Cody
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. ching ping
    ching ping avatar
    3 posts
    Member since:
    Sep 2010

    Posted 04 Nov 2010 Link to this post

    Hi,

    It doesn't work even we increase the time. Even we tried to add in code "Thread.Sleep(30000)" to let the browser sleep for some time, the result is still the same.
  4. Wai-Kit
    Wai-Kit avatar
    4 posts
    Member since:
    Sep 2010

    Posted 07 Nov 2010 Link to this post

    Hi Cody,

    I recognize the code for the "Set as wait" step.
    But the configuration for it is partially missing.
    The value you suggested to me is the "TimeOut" value but the value that i am more interested in is the "WaitOnElementsTimeOut" value.

    I have implemented a simple web application that helps to re-create the main problem, not only this missing configuration.
    In the solution that i have uploaded, the test step contains these 2 values where
    "TimeOut" is 50,000
    "WaitOnElementsTimeOut" is 99,999

    After converting to NUnit, the "WaitOnElementsTimeOut" value is not reflected.
    The test is able to pass on Telereik Web Tests but has run-time errors and fails on NUnit test.


    Instructions to use the Solution
    Open solution, just right-click on "Default.aspx" and "View in Browser" to start up the web site on your machine.
    Run the tests and covert tests to NUnit to run.
    You need to have Telerik RadControls and VS 2008 on your machine.

    Cheers
    Wai Kit
  5. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 09 Nov 2010 Link to this post

    Hi Wai-Kit,

    Thank you for sending the sample web application and test project. I see exactly now what the problem is. Bottom line it is a bug in our code generation. This code:

    // Wait for 'InnerText' 'Exact' 'SUCCESS' on 'LblCaptureCommitMessageSpan'
    HtmlSpan LblCaptureCommitMessageSpan = Pages.HttpLocalhost48730.LblCaptureCommitMessageSpan;
    Wait.For<HtmlSpan>(c => c.AssertContent().InnerText(ArtOfTest.Common.StringCompareType.Exact, "SUCCESS"), LblCaptureCommitMessageSpan, 50000);

    Needs to be changed to this:

    // Wait for 'InnerText' 'Exact' 'SUCCESS' on 'LblCaptureCommitMessageSpan'
    HtmlSpan LblCaptureCommitMessageSpan = Pages.HttpLocalhost48730.LblCaptureCommitMessageSpan;
    Wait.For<HtmlSpan>(c => c.InnerText.Equals("SUCCESS"), LblCaptureCommitMessageSpan, 50000);

    In a Wait For step, the Wait On Elements timeout actually turns into a don't care value. This is because the Wait.For call constantly looks for the element to exist and for it to have the correct property/value. Thus in this specific instance the code is waiting 50 seconds for the Pages.HttpLocalhost48730.LblCaptureCommitMessageSpan element to exist AND for it to contain the text "SUCCESS". Under the covers it checks every 200 milliseconds for both conditions to be true. This is done with the TimeOut property only. The WaitOnElement property is not used.

    Thank you for pointing out this bug in our code generation. I have filed bug 78570 for this problem.


    Greetings,
    Cody
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Kalyan
    Kalyan avatar
    1 posts
    Member since:
    Oct 2011

    Posted 05 Oct 2011 Link to this post

    Hi NUnit team
    i have an issue in OpenFileDialogTester class 
    My problem is how to go  back to actual form or modal on clicking on open button in openfiledialog  and how to get the name of  button control  in openfiledialog
    will any one plz  send me solution to this issue 
    this is my code 

    private

     

    void button1_Click(object sender, EventArgs e)

     

    {

     

     

    OpenFileDialog f = new OpenFileDialog();

     

    f.Title =

    "Select Source Pcap";

     

    f.InitialDirectory =

    @"c:\";

     

     

    if (f.ShowDialog() == DialogResult.OK)

     

    {

     

    this.Refresh();

     

    button1.Enabled =

    false;

     

    comboBox1.Enabled =

    false;

     

    label6.Text =

    "";

     

    label7.Text =

    "";

     

    label8.Text =

    "";

     

    label9.Text =

    "";

     

    comboBox1.Items.Clear();

     

     

    string check = Path.GetExtension(f.FileName);

     

     

    if (check == ".pcap")

     

    {

    label6.Text = f.FileName;

    button.Enabled =

    false;

     

    button1.Enabled =

    true;

     

    }

     

    else

     

    {

    label6.Text =

    "This File is not supported";

     

    }

    }

     

    }
    Test method is

     

    [

    Test][STAThread]

     

     

    public void Test1()

     

    {

     

    ControlTester button = new ControlTester("button",f);

     

     

    LabelTester lt = new LabelTester("label6", f);

     

     

    Assert.AreEqual(true, lt.Properties.Enabled);

     

     

    ExpectFileDialog(

    "OpenHandler");

     

    button.FireEvent(

    "Click");

     

    ExpectModal(

    "Form1", Formhandler);

     

     

    ButtonTester open_btn = new ButtonTester("btOpenFile");

     

     

    // LabelTester label10 = new LabelTester("lblFilename");

     

     

     

     

     

     

    open_btn.FireEvent(

    "Click");

     

     

     

     

     

    string fileName = "C:/Documents and Settings/guttakac/My Documents/pcap";

     

     

    // Assert.AreEqual(label10.Text, fileName);

     

     

     

     

     

    }

     

    public void OpenHandler()

     

    {

     

    ControlTester button = new ControlTester("button", f);

     

    button.FireEvent(

    "Click");

     

     

     

     

    OpenFileDialogTester opt = new OpenFileDialogTester("Select Source Pcap");

     

     

    opt.OpenFile(

    "rtmp");

     

    opt.ClickCancel();

     

     

    }

     

    public void Formhandler()

     

    {

     

    Form1 f1 = new Form1();

     

    f1.Show();

    }

     

    i m getting controlnotvisibleException btOpenFile and openfiledialog it is not responding to click on open or cancel buttons
     

  7. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 06 Oct 2011 Link to this post

    Hi Kalyan,

    Thanks for the post. Unfortunately, your application appears to be a WinForms application. Test Studio does not currently support the testing of WinForms applications.

    Presently Test Studio is capable of automating these types of applications:
        - HTML based web applications 
        - Silverlight based applications, both in browser and out of browser
        - WPF based desktop applications

    Please check our online documentation for more information.

    Regards,

    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!