Forum Discussion

makh_dv's avatar
makh_dv
Occasional Contributor
13 years ago

C# Extensions for Connected Application. TestComplete API roadmap.

Hello,



I probably miss some ability. However... using Connected Application with C#, we met following...



1.

Plenty dummy code like:



using tcVar = AutomatedQA.script.var;

namespace MyProject.TCFramework

{

    public static class TcVarExtension

    {

        #region Properties

        public static bool Exists(this tcVar alias)

        {

            return alias["Exists"];

        }

        public static bool Exists(this tcVar.VarDelegate alias)

        {

            return alias["Exists"];

        }

        public static bool Visible(this tcVar alias)

        {

            return alias["Visible"];

        }

        public static bool Visible(this tcVar.VarDelegate alias)

        {

            return alias["Visible"];

        }

        #endregion



        #region Common Methods

        public static void Click(this tcVar alias)

        {

            alias["Click"]();

        }

        public static void Click(this tcVar.VarDelegate alias)

        {

            alias["Click"]();

        }

        public static void ClickButton(this tcVar alias)

        {

            alias["ClickButton"]();

        }

        public static void ClickButton(this tcVar.VarDelegate alias)

        {

            alias["ClickButton"]();

        }

        #endregion

    }

}



Is there any built in code for these and similar methods/properties, without need to invent wheel? What could you suggest?



2.

No Exceptions on calling TestComplete Api...

It looks that using

var someTcObject;

someTcObject.ClickButton(); //TcObject["ClickButton"]()


never throws exceptions to C#, if there were any problems with this clicks.

And we have to monitor Log.Error events and store them... we cannot just throw Exception because axEventControl subscribers in different thread, and throwing Exception does nothing to e.g. NUnit thread.

As a result on each call to TestComplete api, check were there any Errors, and throw exception to NUnit thread if they were any. It is implemented in meaning of "Guards"

And code become look like this:

        public static void ClickButton(this tcVar alias)

        {

            alias["ClickButton"]();

            TestCompleteGuard.Guard(); //throws exception if there are Errors in internal queue

        }

        public static void ClickButton(this tcVar.VarDelegate alias)

        {

            alias["ClickButton"]();

            TestCompleteGuard.Guard(); //throws exception if there are Errors in internal queue

        }

        public static string ClrClassName(this tcVar alias)

        {

            return TestCompleteGuard.GuardString(alias["ClrClassName"]()); //throws exception if there are Errors in internal queue

        }

        public static string ClrClassName(this tcVar.VarDelegate alias)

        {

            return TestCompleteGuard.GuardString(alias["ClrClassName"]()); //throws exception if there are Errors in internal queue

        }



I'm not sure that this is really how it should be used, thus is there way to trow native Exceptions if TestComplete calls are actually fail.

Is it used properly or some misunderstanding of API?



3.

Are there any plans to make more convenient use of TestComplete Api to stay in Dev IDE, without plenty of rakes in test code? :-)

I do like IDEs with a lot of refactoring abilities more than Scripted/Keyword environment that TestComplete IDE can provide.



Maybe this explains popularity of a free tools like Wati(R/N) and Selenium (except of cost factor), because you just need to add library, and start using It. For TestComplete API to have accurate code requires a lot of support-code before this can be reached. Please I want to understand it more, and if I wrong, please open my eyes.



There are not much info in the internet about Connected Application experience.



Idea: I don't think that using DLR (from .NET 4.0) will help to provide refactor abilities, however somewhere it can be useful at least porting code from JScript to C#.
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Dmytro,


    1.

    Is there any built in code for these and similar methods/properties, without need to invent wheel? What could you suggest?


    As far as I know, there is no need to write code like this. Everything should work fine without it:


    var myObj = SomeTestedObject();

    if (! myObj["Exists"])

      // Do something...


    The [] operator is redefined for var objects. It automatically checks the availability of the specified method or property and calls this method or property. We have been using it for years to make it easier to call methods via "late binding" in C# (earlier C# versions did not have the dynamic type and, therefore, didn't provide easy late-binding calls).


    As far as I understand, you write test code directly in Visual Studio IDE and you "invented a wheel" :-) to make it possible to choose the needed methods and properties from the Code Completion window. Unfortunately, it is impossible to modify the var object definition to provide this kind of Code Completion information, as in general case, the var object corresponds to an arbitrary test object, and the set of its methods and properties is not strictly defined.


    When developing the concept of Connected Applications, we expected that users would record (or create) C#Script code in TestComplete and then copy it to C# applications, but not write test commands from scratch in Visual Studio IDE. :-)


    2.

    No Exceptions on calling TestComplete Api...


    This is how TestComplete works. An error in a call to some method or property does not necessarily cause an exception. In many test scenarios, users typically expect that an error in a call will cause an error in the test log rather than an exception and, eventually, stop of the test run. An exception occurs only if something is wrong with a test script, for instance, if you use invalid script statements (e.g. "wihle" instead of "while"). In Connected Applications these errors typically cause compiling errors.


    3.

    I do like IDEs with a lot of refactoring abilities...

    ...

    For TestComplete API to have accurate code requires a lot of support-code before this can be reached. Please I want to understand it more, and if I wrong, please open my eyes.


    Dmytro, I'd say you are untypical QA engineer :-). Quote often, testers don't know any IDE and have little or no programming experience. For these users, working with keyword tests and scripts is easier and more natural. So, we are always attempting to make TestComplete IDE more convenient, powerful and easy-to-use. Nevertheless, we are open to discussing possible Connected App improvements. You can post your suggestions here for discussion, or send them to our Support Team.

  • makh_dv's avatar
    makh_dv
    Occasional Contributor
    Alex,



    Thanks for your comments.



    1.

    I was not clear enough.

    I don't expect that each "var" object will become typed object, and it will show me Click method if it only exists.

    My concern is that I cannot count hours that me or people around me spend to find the "typo", when after several ours of debug you are becoming some how blind and simplest mistake become error.

    Extensions at least now, does allow to avoid this instead of:

    ["Exist"], ["Eksists"] and etc,

    now I can just type Exists().

    AutomatedQA.TestComplete.CSConnectedApp for sure can have these extensions at least for basic functions (don't ask me what is basic) :-)

    Maybe there could be set of extensions... E.g. linq has data, enum, xml separate extenstions, and maybe the same can be done for test complete.



    2.

    Honestly Exceptions in connected app is not only issues that we had to found workaround. It was a challenge to make "UiBaseTest" to make Ui test work under NUnit more naturally.

    I think I'll need to make an article about this challenges :-)



    3.

    I would not say I'm untypical... In Ukraine community of automation testers I know dozens of testers with Developers background. Also I see popularity of selenium because it can "easily" work as API, because FireFox's IDE is quite limited. And I see plenty of articles about suggested tests architecture for Java/.NET using PageObject, Facade, Chain, Singleton, Factory and etc patterns using Selenium.

    And customers are interested to build team with manual testers in soul and take "Developers in test" just to perform tasks of automation.

    If I can vote somewhere and my colleagues can vote too, TestComplete API is for sure is are of improvement.



    4.

    >>When
    developing the concept of Connected Applications, we expected that users
    would record (or create) C#Script code in TestComplete and then copy it
    to C# applications, but not write test commands from scratch in Visual
    Studio IDE. :-)

    Alex, let me join to discussions... :-)

    In time pressure it was easier to us understand more what developers does, and what are benefits in MVP architecture (my biggest project based on). And we found interesting applying approach of Automation Pyramid



      <Manual>

          /GUI\

        / API   \

      /   Unit     \



    And also taking in account that from native (in my case .NET, MS Studio) ide it is easier to get access to Domain, without need to do manipulation with UI, and in the most cases it is reasonable by required time to prepare environment (direct AppServer calls in hundred times faster than UI).

    Our tests look like:

    SetUp: Do something with Domain

    Test: Login, act and assert on UI that it is ok. (For async UI it is: navigate to UI, simulate Domain calls, assert on UI)

    TearDown: close UI, remove created objects

    So it is more naturally to write tests from "scratch" using Framework.



    And be honest my project is not alone in a such approach. And some WPF based projects have selected CodedUi.



    P.S. I have sent in Support "Idea".

    P.P.S. skype me: makh_dv, if we can do something more in this direction.
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Hi Dmytro,


    I see your points, thank you. We need to think and decide what we can implement and when.


    Btw, you said that you'd sent your suggestions to the Support Team. Do you have the issue number? It looks like Mnnnnn. You can find it in the e-mail that you received from SmartBear after you had sent your request via the Contact Support form. I ask about this, because I spoke to the support guys and we failed to find anything from you...

  • makh_dv's avatar
    makh_dv
    Occasional Contributor
    Alex,



    I just posted it, I found the window in browser was still opened to confirm request, I haven't seen this functionality on my previous usages.

    There is no numbers in request you mentioned. The exact subject is "Improve usage of TestComplete API". I assume it didn't pass "After your submission passes the initial processing and enters the Support Queue, you will get an e-mail notification with an Issue#
    assigned to your submission."
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Dmytro,


    It is here, thank you. The support guys will deal with it.

  • jyothi_pp_1's avatar
    jyothi_pp_1
    Occasional Contributor
    Hello ,



    I would like to know more information about connected application in C#.. In our project we are planning to use Visual studio. When we add the 2 dlls. we are able to access Sys, Log objects by using Connect Class.

    But third party plug in objects like "Browsers' is not accessible. I read that we have to use Integration object for this. But his concept is not clear to me. I have used this integration object to identify Browsers object.

    var MyObject = Connect.Integration["GetObjectByName"]("Browsers"); But it is returning null. They have told to get the object TestComplete should run a test. What exactly we have to do here?

    Can anyone help on this?

    Thanks

    jyothi