.NET Connected.TestedApps["Items"]("appName") execute well in TC IDE, but giving null exception in C
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
.NET Connected.TestedApps["Items"]("appName") execute well in TC IDE, but giving null exception in C
This code execute successfully in TC-IDE
function Test1()
{
var appName = "TestApp";
var appObj = TestedApps["Items"](appName);
if (appObj != null)
{
Log["Message"](appObj["ItemName"]);
Log["Message"](appObj["FullFileName"]);
}
}
but giving null exception in C# ConnectedApp:
using tcVar = AutomatedQA.script.var;
using AutomatedQA.TestComplete;
public static void StartApp(string AppName)
{
tcVar app = AppNAme;
tcVar appObj = Connect.TestedApps["Items"](app);
if (appObj != null)
{
tcVar str = "The project contains following TestedApps: " + objApp["FileName"];
Connect.Log["Message"](str);
str = "Full Name with Path of Application: " + objApp["FullFileName"];
}
}
What is wrong with my code. I had write the same code using VBScripts in TC-IDE, it runs OK, but same error if i tried to run in VB.NET connected app.
An early response will be appreciated.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
https://support.smartbear.com/testleft/docs/
https://smartbear.com/product/testleft/overview/
> giving null exception in C# ConnectedApp
Without knowing at least what line of your code throws the exception, my first wild guess is that TestComplete is not in script-running mode:
https://support.smartbear.com/testcomplete/docs/testing-with/advanced/connected/running.html
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @asadc,
Have you performed all the steps listed in the Creating Scripting Objects From Visual Basic .NET Application Objects?
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alex,
Now I changed the Connected App scenario, I put my code in a VB.Net Dll, and I added the Dll in TC using CLR_Bridge. It was successfully registered in, I write following code
Sub TstXlsRdr
Dim p
p = dotNET.CMSIntergrationLib.DriverTC.ProcessBatchFile("D:\TestComplete\BatchRN2.xlsx", "CTA")
End Sub
The subroutine reads an excel file successfully, Connect.Log.Message can also successfully write the strings in TC log. But as I try to read following statement it give error [Object variable or With block variable not set]
Private Function CheckRegApps(appName As String) As String
Dim AppName As String = appName
Dim tstAppObj
Try
tstAppObj = Connect.TestedApps.Items(AppName)
Catch ex As Exception
Throw ex
End Try
End Function
What is wrong with this code, looks like tstAppObj is unable to get TestedApp type of object.
I am new to TC environment, please need guideness in this matter.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can you describe for what and how you are going to use TestComplete? What type(s) of tested application(s) are you going to work with?
The case is that the initial idea and the purpose of Connected applications support in TestComplete was to provide support for self-testing applications while make it possible for them to use some functionality of TestComplete in order to not invent the same just for the testing purposes. For example - use test log provided by TestComplete and not create custom logging.
Self-testing applications are applications that do some test actions from within their own code using full access to application's code - a kind of highly extended unit testing. For example, your application, if started with some additional parameter, may expose additional toolbar with buttons that trigger some business workflows that regular human users are expected to follow, but without user interface and additional messages (like 'Do you really want to delete this order?').
Considering the above, some functionality provided by TestComplete may be irrelevant for self-testing applications and might be not supported. (This should be checked with TestComplete's documentation.) For example, what for your self-testing application might need to get the list of the Tested Applications from TestComplete's project while it (application) is already running and has all information about itself?
If for any reason you need to have self-testing application then, as I wrote it in my initial reply, I would recommend you to consider TestLeft as it better suits this testing scenario.
The primary area for TestComplete is external control of the tested application from the point of view of the human user. This means that (primarily) TestComplete has no idea about application it will drive. That is why this is specified as the Tested Application. When TestComplete starts the Tested Application, it analyses started application in order to control it more efficently. In certain cases, it is possible to call native internal public methods of the tested application from TestComplete's test code, but this is an exceptional case, not the usual recommended approach. The usual approach with TestComplete is to emulate end-user's actions via sending operating system messages to the tested application (like type some keys, click mouse button, etc.) like the human user, who has no access to source code and application's internals, does.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Alex,
Thank you for detailed response. Actually here is what our automation team is doing, their testing scenarios:
There are 2+ .xlsx files, the first one is batchInit.xlsx file having data as follows:
SeqNo | Key/Action | Excel Path | Tab | Iterations | Data Column |
1 | CheckApp | D:\TestComplete\TC_XlsRdrTestApp\XlsRdrApp.exe | cms_app | 1 | 0 |
2 | SwitchUser | netsol1 | a/netsolpk1 | 1 | 29 |
3 | TestCase | D:\TestComplete\CmsRN.xlsx | PickApplication | 2 | 29 |
And the additional files contains Test-Case instructions e.g. CmsRN.xlsx file has data as follows:
Step# | Mapped Object | Action | QATC1 |
1 |
| readVariables | Contracts |
2 | Aliases.cms_app.CMS | selectMenu | Management|Workflow|Pick/Re-Pick CAP Deals |
3 | Aliases.cms_app.RetrievalOptions.RetrieveDatewise | skip |
|
4 | Aliases.cms_app.RetrievalOptions.Main.FromDate | skip |
|
5 | Aliases.cms_app.RetrievalOptions.Main.ToDate | skip |
|
6 | Aliases.cms_app.RetrievalOptions.OK | set |
|
7 |
| tooltip | SearchApp |
8 | SearchOptions.ApplicationNo | check | set |
9 |
| delay | 2000 |
10 | Aliases.cms_app.SearchOptions.AppNo | set | #2 |
11 |
| delay | 2000 |
12 | Aliases.cms_app.SearchOptions.ApplicationType | check | set |
13 | Aliases.cms_app.SearchOptions.ApplicationType | check | unset |
14 | Aliases.cms_app.SearchOptions.Close | set | close |
15 |
| delay | 2000 |
16 | Aliases.cms_app.CMS.mainWindow.PickWindow.Main.Text("applicant_name") | set | application_name |
17 |
| delay | 2000 |
18 | Aliases.cms_app.CMS | tooltip | PickApp |
19 |
| delay | 10000 |
20 | Aliases.cms_app.Window("#32770", "Success", 1).Window("Button", "OK", 1) | button |
|
21 | Aliases.cms_app.CMS | tooltip | Close |
The automation team has written scripts in Test-Complete for different command processing.
One process start reading first file and process steps mentioned in it e.g
Step1: CheckApp, test weather specific application is in the list on TestdApp.Items list and validate its Fullname+Path.
Step2: SwitchUser, check it application is running, terminate it and re-execute the app.
Step3: TestCase, reads the 2nd Test=Case file specified with Path, open it and give the table to the 2nd Process which actually runs the Test-Case steps.
The 2nd process runs the test case Actions using Mapped-Object with the test data given in QACT1 column.
So my task was to convert all those scripts written in TC-Scripts, into a Dll, so we can give the Dll to our testing resources running TC, they will prepare the .xlsx files and run automation.
Before we give our testing resources the whole project .pjs folder, they open the project and prepare .xlsx sheets, and run the automation.
Now one of our client has request, they will buy the Test-Complete. Since they do not have technical-testing resource, they want us to give them the testing framework i.e. Testing-Scripts we had developed, so that they will run the .xlsx file w.r.t the newly Change-Request implemented in the software on their site for integration testing.
That is why we want to convert the testing-scripts framework to put in VB.Net Dll, so user cannot change the scripts, and only focus on integration side only.
Thanks.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Well, I don't know all your details, but my personal opinion is "Why not to provide a client with TestComplete project that already does what is needed?".
While providing TestComplete project to the client you may warn them that if they change something in test code this will be on their own and you will not support this. What you will support is their change requests in response to which they will get updated TestComplete project.
Or your expectation was not to support provided .dll?
What you are trying to implement sounds to me like connected self-testing application where TestComplete is supposed to act as this self-testing application. Not sure to what extent this is supported in TestComplete.
Slightly different approach that you may consider: when your test code is running, it may call Sys.OleObject("TestComplete.Application") and get an access to the COM object of the current TestComplete instance. This COM object provides some child objects like Integration and others (if I remember their names correctly) that can be used from test code.
The problem is that these child objects are not well documented and it will not be easy to figure out how this or that can be done. If ever can.
I would recommend to ask Support for their comments directly via the https://support.smartbear.com/message/?prod=TestComplete form and reference this thread.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
