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
Solved! Go to Solution.
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
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?
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
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.
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
Well, learned something new.
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
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.
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
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.
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
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.
Subject | Author | Latest Post |
---|---|---|