Forum Discussion

frank_vanderstr's avatar
frank_vanderstr
Contributor
11 years ago

C# in Code Testing.

I am attempting to add test code to a C# application so that I can automate testing on the file and functionality of the application.

 

My first issue comes from when I include 'using AutomatedQA.script;' in my source file

 

many of my variable declarations now have an error which states: Cannot implicitly convert type 'System.Web.HttpCookie' to 'AutomatedQA.script.var'   

An example of where this occurs is: var requestCookie = Request.Cookies[AntiXsrfTokenKey];

 

I am stumped as to why the referance of AutomatedQA.script is somehow overriding things.

 

My second issue is I am unsure how to write the testing portion, here is a sample of what I am going to start with, I just don't know if it is in the right direction or not.

 

var conn = Connect.Sys;

var usernameobject = Connect.Integration["GetObjectByName"]("username");
usernameobject["Click"]();

 

This is written at the end of source file.

 

Any insight is appreciated, and I have also already read the Smartbear articles on C# connected applications.

5 Replies

  • In my C# source file I am trying to use the AutomatedQA.script to automate testing for the application.

     

    I get the error

    A first chance exception of type 'System.NullReferenceException' occurred in AutomatedQA.script.dll

     

    When the below code is reached. 

    AutomatedQA.script.var usernameobject = Connect.Integration["GetObjectByName"]("username");
    usernameobject["Click"]();
    usernameobject["Keys"]("test");

     

    I am not sure why the null reference is occuring.

     

    I also included using using AutomatedQA.TestComplete; in my source file.

  • Hi Frank,

     

    Please make sure that you added two libraries into your project: 

    1. AutomatedQA.script.dll
    2. AutomatedQA.TestComplete.CSConnectedApp.dll

    I recommend that you refer to the following article: it contains a step-by-step instruction on how to set up a connected application as well as several samples: http://support.smartbear.com/viewarticle/56954/

    • frank_vanderstr's avatar
      frank_vanderstr
      Contributor

      AutomatedQA.TestComplete.CSConnectedApp.dll has been added but AutomatedQA.script.dll must be used in a reference as it takes total overship over the "var" type, so other code in the file that utilize the var type for storing other data hit an error on build.

       

      I'm afraid the articles are not very descriptive in applied use.

       

      There are no examples of code proerply interacting in both the C# project and testing scripts.

       

      I got as far as using the RunTest function to get TestComplete is script running mode, but after some digging I found out it doesn't actually execute anything in your scripts, talk about a misleading function name.

       

      I then tried to utilize the Integration object that might allow me to execute my scripts functions, but there is no clear documentation on how to get that working with the intergration object provided by the Connect Object.

      • AlexKaras's avatar
        AlexKaras
        Icon for Champion Level 2 rankChampion Level 2

        Hi Frank,

         

        Have you tried to go through the samples from the "C:\Users\Public\Documents\TestComplete 10 Samples\Desktop\Connected Applications\" folder?

        Maybe, they will help...