Run test code from a Win Form program

6 posts, 0 answers
  1. Juan
    Juan avatar
    18 posts
    Member since:
    Mar 2012

    Posted 20 Apr 2012 Link to this post

    Hi everyone,

    I've created a Win Forms program in Visual Studio C#. The program is very simple:
    1 combo box where I have the four browser supported by Telerik TS (Chrome, IE, Safari and Firefox)
    1 "Start Test" button

    Basically, I have my test code in the button, so I just need to choice the browser and click the button to start the automated code.

    To create the code that test the web site, I've added the Telerik references to the Win Forms. 
    Everything is good with Chrome, but with the other browser I just get this error:

    ?myManager.ActiveBrowser.Find.ByAttributes<HtmlAnchor>("id=1245").Click()

    '((ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl)(myManager.ActiveBrowser.Find.ByAttributes<HtmlAnchor>("id=1245")))' is null


    I don't know why the test is not finding the reference to the object with id "1245", the only thing that occurs is that the code can open the URL in the browser.

    My question is, do you know if is possible to do this? or... I'm getting this error because this is not completely possible?

    Please let me know if you need more details about my problem,
    Thanks in advance,
    Juan



  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 21 Apr 2012 Link to this post

    Hi Juan,

    Let me see if I understand correctly:
    1) You create a WinForms application
    2) This applications sole purpose is life is to be a Test Studio test launcher i.e. you select the browser to use and the test to run then click a "Start" button to launch the execution of the test.
    3) This process appears to be working fine when using the Chrome browser, but with any other browser you get a null reference exception. 

    Do I understand your steps correctly? First, yes that is certainly doable. In fact we have a code sample showing one approach for doing this very thing - though it's different in that it demonstrates a console application and using the Telerik Testing Framework instead of running Test Studio tests.

    Without seeing your code and reproducing the problem locally it's impossible to say what is causing it.

    Kind regards,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Juan
    Juan avatar
    18 posts
    Member since:
    Mar 2012

    Posted 23 Apr 2012 Link to this post

    Hi Cody,
    Thanks for your response.

    Yes, you are correct! That is what I want. Actually, I made a console program and it works great.
    I know is difficult to say what is my problem if you can't see my code. But I just wanted to know if that is possible.
    If is possible to do the same in a Win forms program? (This is just to have a friendly UI for the final user.

    Thanks,
    Juan
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 23 Apr 2012 Link to this post

    Hi Juan,

    Yes it is absolutely possible (and shouldn't be all that difficult) to create a WinForms test launcher the way you want, with browser selection support. We'll be happy to help diagnose why your WinForms app isn't working once we have something in our hands to analyze.

    Kind regards,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Juan
    Juan avatar
    18 posts
    Member since:
    Mar 2012

    Posted 23 Apr 2012 Link to this post

    I'll give it a try to see what is happening, I'll let you know if I need help.

    Thanks Cody for all your support!
    Juan
  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 23 Apr 2012 Link to this post

    Hi Juan,

    Very good. We'll be here.

    Greetings,
    Cody
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!