cancel
Showing results for 
Search instead for 
Did you mean: 

How to provide an object from third party components to TestExecute REST API?

SOLVED
Contributor

How to provide an object from third party components to TestExecute REST API?

Hello.

I'm trying to communicate with TestExecute API.
When executing GET/POST requests with parameters simple data types everything is Ok.
But there are some methods from third party components that are expecting an object from some their class.
How to obtain this?
SomeMethod(id, someObject)
where id is an identification for object whoes method is trying to be executed and 
someObject is object from third party components, which identifications also is available.

Thanks in advance,
Maria

9 REPLIES
Community Hero

Re: How to provide an object from third party components to TestExecute REST API?

Hi Maria,

 

It might help to understand the problem better if you provide your code here.

But generally speaking,

> GET/POST requests

pass data in textual form. As JSON, text, some encoding etc.

Thus, it is my expectation that serialized representation of the object is required as the value for the someObject parameter.

 

P.S.

> I'm trying to communicate with TestExecute API.

Can you describe what for?

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members 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. Postings made by [Community Expert Group] members
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.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: How to provide an object from third party components to TestExecute REST API?

 Hello.

   I'm trying to communicate with TestExecute API as alternative of Connected/Self-Testing applications which are deprecated by Smartbear. (These technologies will be removed in one of the future releases of TestComplete.)
Because our tests are based on this approach, I'm trying to find a way to work with TestComplete using REST API.


Example:
this is an example of usage of TestComplete in documentation
https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/grids/devexpress-xtragrid...

function FindRowByCellText (Grid, View, ColumnId, Text)
{
  var Column;
  if (View == null)
    View = Grid["MainView"];
  Column = GetColumn (Grid, View, ColumnId);
  return View["LocateByDisplayText"](0, Column, Text);
}

function GetColumn (Grid, View, ColumnId)
{
  var Columns;

  Columns = View["Columns"];
    // The column is specified by index
    return Columns["Item_2"](ColumnId);
}

My question is how to call using REST API methods like this one:
View["LocateByDisplayText"](0, Column, Text);

where the Column is an object.


And there is a rough sample for CallMethod using REST API:

private static void CallMethod(string id, string methodName, params object[] methodParams)
{
methodName = AddArguments(methodName, methodParams);
RestRequest request = new RestRequest("1/sys/" + id + "/method/" + methodName, Method.GET);
string content = ExecuteRequest(request);
RMReturn r = JsonConvert.DeserializeObject<RMReturn>(content);
if (!r.success) throw new Exception("CallMethod: " + r.result);
}

 

CallMethod(ViewId, "LocateByDisplayText", 0, Column, Text);

Regards,
Maria

Community Hero

Re: How to provide an object from third party components to TestExecute REST API?

Those aren't REST API calls.  They are methods that are associated with the component itself.  As far as I know, there's not an API as such in TestComplete/TestExecute.  So, the question itself doesn't make sense since there isn't a published API.

The replacement for connected/self-testing applications is the product called "TestLeft".  Take a look at that and see if that will solve your problems.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.


I’ll be talking about “Hidden Treasures – TestComplete Script Extensions” at #SBConnect in October! Who’s joining me? Click here for tickets
Extensions available
Contributor

Re: How to provide an object from third party components to TestExecute REST API?

Hello

This is not correct, there is such API in TestComplete/TestExecute.
See: https://support.smartbear.com/testcomplete/docs/working-with/integration/testleft-rest-api.html?q=re...

You can use the API to control TestComplete options, to access applications running on your computer (as well as their internal objects) and to simulate user actions over them.

Regards,
Maria

Community Hero

Re: How to provide an object from third party components to TestExecute REST API?

Well, learned something new. Smiley Happy

 

OK... brief investigation... if you go to http://localhost:2377, you get the web interface for the API giving you the available API calls.

 

I haven't gotten a chance to play with this yet... but I'll tell you it looks REALLY cool....  

Anyways, looks like what you want is the one for calling a method of an object

 

APICallMethod.png

Obviously, you need to get the object ID before you can call the method so there's some additional code with finding objects, etc., that you would need to call to get the ID but then it would be a matter of just substituting {id} and {method} with the necessary segments.

 

Obviously, this is a new piece of tech in TestComplete that I haven't played with before so I can't give you much in the way of expert advice but I'd start with that Swagger UI interface to the API and go from there.

 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.


I’ll be talking about “Hidden Treasures – TestComplete Script Extensions” at #SBConnect in October! Who’s joining me? Click here for tickets
Extensions available
Contributor

Re: How to provide an object from third party components to TestExecute REST API?

Hello.

Yes. this is a new part of Test Complete/Execute. I've palyed withSwagger UI interface to the API.
I know the object ID before calling the method.
The problem is that this method requeres as a parameter another object, which object ID also is known.
But calling the method with object ID instead of object itself doesn't work.
And I don't have the object itself also.

Regards,
Maria

Community Hero

Re: How to provide an object from third party components to TestExecute REST API?

Ah, I see that now.  Yeah, without playing with it a bit more, not sure what help I can be (as I'm just learning about this COOL new feature).  There doesn't appear to be a way to pass in an object as a parameter for a method in the API.  This MIGHT be a question for someone on the SmartBear tech support team.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.


I’ll be talking about “Hidden Treasures – TestComplete Script Extensions” at #SBConnect in October! Who’s joining me? Click here for tickets
Extensions available
Contributor

Re: How to provide an object from third party components to TestExecute REST API?

Hello,

If someone is interested in this, that is the way to resolve my issue:
methodName = "LocateByDisplayText";
            request = new RestRequest("1/sys/" + mainViewId + "/method/" + methodName, Method.GET);
            request.AddParameter("arg1", 0); 
            request.AddParameter("arg2", request.JsonSerializer.Serialize(new { id = gridColumnId })); // Making a JSON based on the GridColumn id
            request.AddParameter("arg3", "\"Nissan\"");
            response = restClient.Execute(request);

Regards,
Maria

 

Community Hero

Re: How to provide an object from third party components to TestExecute REST API?

Hi Maria,

 

Thank you a lot for the update. Pretty useful indeed.

 

It is my understanding that REST API we are talking about was added to TestExecute (and thus it appeared in TestComplete as well) in order to be able to control TestExecute from TestLeft (https://smartbear.com/product/testleft/overview/).

Generally speaking, TestLeft might appear to be a good solution for you, but considering that you already have test code in TestComplete, your current approach with REST API may work better.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members 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. Postings made by [Community Expert Group] members
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.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Share Your Stories
Read Latest News
Top Kudoed Authors