How to call web api service from Test User Code

Best practices, code snippets for common functionality, examples, and guidelines.
txrackack
Posts: 8
Joined: Fri Mar 11, 2016 5:21 pm

How to call web api service from Test User Code

Post by txrackack » Fri Jul 15, 2016 5:32 pm

I have a .net library that I use with unit tests that will call web api service provided by qTest to update tests in qTest as pass or fail. This library is working fine in the specflow solution and unit tests but when I try to use the same code in a user code module created from a validation step the call to create the object fails citing a timeout trying to connect to the web api service while creating the instance. I have validated my connection information and it matches what I am using in the spec flow test. Is there something about Ranorex code modules that prevents calling to web api or web services?

txrackack
Posts: 8
Joined: Fri Mar 11, 2016 5:21 pm

Re: How to call web api service from Test User Code

Post by txrackack » Fri Jul 15, 2016 6:46 pm

As of now it appears that the service is taking much longer when called via Ranorex but I have had it work correctly a few times. Will update if I find more but in the meantime if there are any ideas on if anything in Ranorex or its processes could be slowing this down I would greatly appreciate the input.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to call web api service from Test User Code

Post by Support Team » Mon Jul 18, 2016 2:07 pm

Hello txrackack,

I'm wondering where exactly you are adding your user code. What exactly does this mean "....try to use the same code in a user code module created from a validation step". Do you use the Recording.UserCode file?

If yes, you can create a separate user code module instead converting a validation action within a recording module.
Is there something about Ranorex code modules that prevents calling to web api or web services?
Actually no, there is nothing that I can think of preventing an web API call.

Regards,
Bernhard
.
Image