Web API testing in Test studio

22 posts, 0 answers
  1. SURAJ
    SURAJ avatar
    2 posts
    Member since:
    May 2014

    Posted 05 Jun 2014 Link to this post

    Please any one help me out on Web API testing. How we can do the Web API testing in telerik test studio? or there is another way please suggest.
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 09 Jun 2014 Link to this post

    Hello SURAJ,

    Before I say whether or not Test Studio can help you what does "Web API testing" mean to you? What exactly are you trying to test? Are you planning to make HTTP calls to verify a web service is functioning? Or are you planning to make API calls directly? How do you want to make these calls? What results will you want to verify and how do you want to verify them?

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. SURAJ
    SURAJ avatar
    2 posts
    Member since:
    May 2014

    Posted 09 Jun 2014 in reply to Cody Link to this post

    In our project we use REST web API's. Currently I just want check GET and POST call responses by calling those REST API directly and depends on response receive I am going to do Asserts. So please suggest me the solution how I can accomplish it  in Telerik test studio or what will be the better framework I can use?
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 12 Jun 2014 Link to this post

    Hi SURAJ,

    Thank you for the clarification. I don't think Test Studio, our full IDE is going to be the right solution for you. Test Studio was designed to do UI automation, to drive a browser window, or WPF application, as if a real person were sitting there interacting with it directly. It does this through UI automation. We don't have built-in method for making direct GET and POST call's and validating the responses.

    If it were me I'd use either our free framework or create a Microsoft coded unit test to do this. Either way you'll need to write your own code for making the GET and POST call's and validating the responses.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  5. Tim
    Tim avatar
    5 posts
    Member since:
    Nov 2013

    Posted 15 May 2015 in reply to SURAJ Link to this post

    Found this post by searching "API Testing" and thought I would reply for posterity's sake. 

    Check out my code sample and see if that helps. 

    http://www.telerik.com/support/code-library/testing-rest-api-using-test-studio

  6. Pravallika
    Pravallika avatar
    14 posts
    Member since:
    Dec 2014

    Posted 09 Jun 2015 Link to this post

    Hi,

     I use the following code in my project for Rest GET and POST calls. Hope this works for you too! :)

     

    GET METHOD:

    public String get(String restURL, Boolean AuthFlag, string UserName, string password)
            {
                Manager.Current.Log.WriteLine("*********** RESTURL**********" + restURL);
                var request = WebRequest.Create(restURL);
                request.Method = "GET";
                request.ContentType = "application/json";
                var networkCredential = new NetworkCredential(UserName, password);
                request.Credentials = networkCredential;
                string responsetext = null;

                try
                {
                    using (var response = request.GetResponse())
                    {
                        Debug.WriteLine(((HttpWebResponse)response).StatusDescription);

                        var receiveStream = response.GetResponseStream();
                        var readStream = new StreamReader(receiveStream, Encoding.UTF8);

                        Manager.Current.Log.WriteLine("Response stream received.");
                        responsetext = readStream.ReadToEnd();
                        Manager.Current.Log.WriteLine(responsetext);
                        response.Close();
                        readStream.Close();
                        return responsetext;
                    }
                }
                catch (Exception e1)
                {
                    Manager.Current.Log.WriteLine(e1.Message);
                                    Manager.Current.Log.WriteLine(responsetext);
                }

                return responsetext;
            }

    POST METHOD:

    public string Post(string restURL, Boolean AuthFlag, string payload, string UserName, string password)
            {
                Manager.Current.Log.WriteLine("****** restUrl *****" + restURL);
                Manager.Current.Log.WriteLine("****** payload *****" + payload);
                var request = WebRequest.Create(restURL);
                request.Method = "POST";
                var postData = payload;
                var byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentType = "application/json";
                var networkCredential = new NetworkCredential(UserName, password);
                request.Credentials = networkCredential;
                var dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                var response = request.GetResponse();
                Debug.WriteLine(((HttpWebResponse)response).StatusDescription);
                dataStream = response.GetResponseStream();
                var reader = new StreamReader(dataStream);
                var responseFromServer = reader.ReadToEnd();
                Manager.Current.Log.WriteLine(responseFromServer);
                reader.Close();
                dataStream.Close();
                response.Close();
                return responseFromServer;
            }

  7. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 12 Jun 2015 Link to this post

    Hello Pravallika,

    Thank you for sharing your knowledge with our community.

    We really appreciate it!

    Thank you again!

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  8. Max
    Max avatar
    1 posts
    Member since:
    Jul 2014

    Posted 14 Mar in reply to Pravallika Link to this post

    Hi Pravallika/Boyan/TIM,

    I found this post while searching in the net how to test the Web API for my project through Telerik Test Studio. I am using Telerik Test Studio for Functional testing. How I can use this code and where I need to write this to do my testing. I have never used the coding while doing the testing. I am using only recording. Could you please guide me how to incorporate the coding part.I would really appreciate for your help.

    Thanks, 

    Satya

  9. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 17 Mar Link to this post

    Hello Satyanarayan,

    Thank you for contacting us.

    This is some custom implementation which we do not support. 

    @Pravalika could you please give us some information about your approach.

    @Satyanarayan we will introduce API Testing as part of Test Studio during the next releases this year and it will be officially supported.

    Hope that helps.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  10. akhila
    akhila avatar
    1 posts
    Member since:
    Apr 2016

    Posted 12 Apr Link to this post

    can we use telerik for API testing. Please let me know is it possible or not.

     

    Thanks

  11. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 15 Apr Link to this post

    Hi Akhila,

    We are now implementing this functionality in Test Studio.

    It is expected to go live in June this year.

    Hope that helps.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  12. Vivek
    Vivek avatar
    2 posts
    Member since:
    Apr 2016

    Posted 11 May Link to this post

    Hi

    I want to automate my APIs like i want to test my API request and responses using Test Studio. But  i am not able to get the option to do the same. So please let me know if API funtional automation testing is possible using Test Studio.

    Thanks

  13. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 11 May Link to this post

    Hello,

    This functionality will be available in Test Studio in June this year.

    We are now implementing it.

    Thank you for your understandings. 

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  14. Pitt
    Pitt avatar
    1 posts
    Member since:
    Aug 2014

    Posted 02 Jun in reply to Boyan Boev Link to this post

    Hi Boyan, 

    Do you have a release date of when the API testing part will be released?
    Will it be a fully working api testing functionality or limited and you will continue to improve and add new features?

    kind regards,

  15. Govind
    Govind avatar
    13 posts
    Member since:
    Aug 2014

    Posted 06 Jun in reply to SURAJ Link to this post

    Hi Suraj,

    You can automate Web API testing using RESTSHARP & NewtonSoft. There are very simple http calls that you need to make and easy to code. I have attached a sample of what we have done on our project.

    If you don't have Visual Studio, the the latest version of Test Studio can be used for your automation. You need to take help from your developers in understanding on how to make calls and create POCO.

    In my case, i have stored all the data in an excel spread sheet, parse the sheet, use NewtonSoft to serialize and Deserialize the objects (POCO). I also store all the JSONs for completeness and correctness.

     

    Hope this helps, have attached a sample. You need to include the libraries for restsharp & newtonsoft.

     

    You may use Telerik Fiddler which can also be used to automate WebAPI. This is more simple, there is an article on Telerik site

    http://www.telerik.com/blogs/api-testing-with-telerik-fiddler

    cheers

    govind

  16. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 07 Jun Link to this post

    Hi Pitt,

    The release which includes the API testing is expected at the end of this month.

    This will be a complete API testing solution, which of course will be improved with a lot of new features in the feature release. We are constantly improving our products.

    Thank you!

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  17. Govind
    Govind avatar
    13 posts
    Member since:
    Aug 2014

    Posted 07 Jun in reply to SURAJ Link to this post

    Hello Suraj,

    You can try using RestSharp & NewtonSoft, they are simple to use. Your developer should be able to set this up for you in quick time.

    Unfortunately the admin on telerik removed my last post.

    regards

    govind

  18. Boyan Boev
    Admin
    Boyan Boev avatar
    1043 posts

    Posted 09 Jun Link to this post

    Hello Govind,

    You post is not removed, it is right above mine. We do not remove any post from our customers especially when it is a knowledge sharing.

    Thank you for sharing your knowledge with the community.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  19. Jyoti
    Jyoti avatar
    3 posts
    Member since:
    Sep 2016

    Posted 07 Oct Link to this post

    Telerik Team,
    From past few weeks am working on your tool: Test Studio for APIs, there are so many things which are not clear in your document guide and webinar demo. This tool is new for me in terms of API testing. I would really appreciate if I can get some solutions on my following queries from your team with respect to this tool:

    1. Does Telerik Test Studio for APIs supports Web API testing?
    2. How do I pass the Web API URL to perform some GET and POST methods? (Should I simply add it as a base-url under Project?).
    3. While accessing some sample APIs like Google Maps (geocode) or Youtube API, it shows an Proxy Authorization issue status i.e. 407. This is blocking me from exploring the tool and its features.
    4. Your built-in demo application has no clear definition as to how it is connected with the tool. If I want to connect such .exe or console application with the tool, how should I proceed?

    Kindly help me with some solution as my organization is looking forward to use Test Studio API tool for future API projects.

  20. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    254 posts

    Posted 12 Oct Link to this post

    Hi Jyoti,

    Here are my comments on your topics: 
    1. Test Studio for APIs supports any REST service so if you mean testing a REST service based on ASP.Net Web Api you should be able to test it. 
    2. You can add it directly as a url, or you can create a project or test-level variable.
    3. Probably your APIs need some kind of authorization. Based on the type of authorization, in most cases you can use an Authorization header with an access token to perform the authorized request. This is specific and you need to research what kind of authorization these APIs require. 
    4. The demo application is designed to send requests against it for testing purposes. Here is an article for the demo project in Test Studio for APIs. 

    I hope this information will be helpful to you. 

    Regards,
    Elena Tsvetkova
    Telerik by Progress
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  21. Jyoti
    Jyoti avatar
    3 posts
    Member since:
    Sep 2016

    Posted 12 Oct in reply to Elena Tsvetkova Link to this post

    Hi Elena,

    Thank-you for helping me out, your comments have solved most of my queries.

    Regards,

    Jyoti Shanbal

  22. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    254 posts

    Posted 14 Oct Link to this post

    Hi Jyoti,

    I am glad to hear the shared information was helpful to you. Feel free to contact Test Studio Support Team in case of any further queries. 

    Regards,
    Elena Tsvetkova
    Telerik by Progress
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top