API testing using Selenium

6,032 views
Skip to first unread message

Biplab

unread,
Nov 10, 2011, 1:27:38 AM11/10/11
to Selenium Users
Could you some one explain me how to test API using selenium or API
testing with selenium.

Krishnan Mahadevan

unread,
Nov 10, 2011, 9:41:06 AM11/10/11
to seleniu...@googlegroups.com
Selenium is for browser based testing. How are you invoking your APIs manually?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


On Thu, Nov 10, 2011 at 11:57 AM, Biplab <bgbi...@gmail.com> wrote:
Could you some one explain me how to test API using selenium or API
testing with selenium.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Mark Collin

unread,
Nov 10, 2011, 9:56:09 AM11/10/11
to seleniu...@googlegroups.com
Selenium is a designed to automate browser interactions. It is not an API
testing framework.

--


You received this message because you are subscribed to the Google Groups
"Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to
selenium-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/selenium-users?hl=en.


--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

If you have received this email in error please notify postm...@ardescosolutions.com

Priyanka Shetty

unread,
Apr 26, 2012, 5:02:04 PM4/26/12
to seleniu...@googlegroups.com
I need a tool which I can use to test PHP API, Java API, C# API, Ruby API and Python API, Can I use Selenium for the same??

sandeep srivastava

unread,
Apr 27, 2012, 4:06:00 AM4/27/12
to seleniu...@googlegroups.com
Better read about testNG for java API testing. NUNIT for C#
 
 


 
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Ytpb1cjb4IwJ.

gopal thota

unread,
Jun 2, 2015, 12:35:57 AM6/2/15
to seleniu...@googlegroups.com
If you want to test REST API using selenium. You can create a FF profile and install REST client in it.Open Webdriver with FF with profile and access the client url.and pass the api url and other parameters to the client.

If you can able to open client in browser , you can do anything using selenium

Krishnan Mahadevan

unread,
Jun 2, 2015, 1:18:44 AM6/2/15
to Selenium Users
Gopal

Thats a real convoluted way of doing API testing.
Assuming that you are going to be using Java, why not use resort to using HttpClient from apache, build your request, post/get them against your end point and then validate the response ?

IMO involving Selenium for doing things such as REST based API call testing is just an overkill and is bound to only add more pain and misery.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Varadharajan Srinivasan

unread,
Jun 4, 2015, 11:34:01 PM6/4/15
to seleniu...@googlegroups.com
Selenium is for Browser automation

If you looking for a framework for API automatio, I suggest using RestAssured - https://code.google.com/p/rest-assured/

Mukesh otwani

unread,
Jun 5, 2015, 2:29:10 PM6/5/15
to seleniu...@googlegroups.com
Hi Biplab,

You can use HTTPClient to test API (Web Services).

I have create a post which cover request response in JSON and XML Format and I have covered one scenario as well.

You can check below post might be it will help you and you will get a base line to start with API testing


Note- It is freeware.

On Thursday, November 10, 2011 at 11:57:38 AM UTC+5:30, Biplab wrote:

Jon Thor Austen

unread,
Jun 6, 2015, 1:09:22 PM6/6/15
to seleniu...@googlegroups.com
I would like to add 2 points about this question:

1.  I use Jmeter to do API testing because it is designed to do so: https://github.com/djangofan/launch-jmeter

2.  Using Selenium for 'load testing' would be silly BUT using Selenium for 'performance testing" along with using BrowserMob Proxy to generate .HAR performance artifacts that can be then analyzed, is a totally legit thing to do.  https://github.com/lightbody/browsermob-proxy

-Jon

ak.mc...@gmail.com

unread,
May 23, 2016, 1:33:49 PM5/23/16
to Selenium Users
package automationFramework;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;

import org.json.JSONArray;
import org.json.JSONObject;
import org.testng.Reporter;
import org.testng.annotations.Test;

@SuppressWarnings("unused")
public class RestAPI{
@Test
public void aptTesting() throws Exception {
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept”, “application/json", null);

if (conn.getResponseCode() != 200) {
throw new RuntimeException("HTTP error code:" + conn.getResponseCode());
}

Scanner scan = new Scanner(url.openStream());
String entireResponse = new String();
while (scan.hasNext())
entireResponse += scan.nextLine();

System.out.println("Response :" + entireResponse);

scan.close();

JSONObject obj = new JSONObject(entireResponse );
String responseCode = obj.getString("status");
System.out.println("status :" + responseCode);

JSONArray arr = obj.getJSONArray("results");
for (int i = 0; i < arr.length(); i++) {
String placeid = arr.getJSONObject(i).getString("place_id");
System.out.println("Place id :"  + placeid);
String formatAddress = arr.getJSONObject(i).getString("formatted_address");
System.out.println("Address :" + formatAddress);

//validating Address as per the requirement
if(formatAddress.equalsIgnoreCase("Chicago, IL, USA"))
{
System.out.println("Address is as Expected");
}
else
{
System.out.println("Address is not as Expected");
}
}

conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}
}

On Thursday, November 10, 2011 at 11:57:38 AM UTC+5:30, Biplab wrote:

Shirley Perkins

unread,
Sep 27, 2016, 5:53:22 AM9/27/16
to Selenium Users

anemuday

unread,
Sep 27, 2016, 8:43:18 AM9/27/16
to Selenium Users

Check this:

An easy way to automate the WebService APIs.

Thanks,
Uday

Nag Selenium

unread,
Sep 29, 2016, 6:21:50 AM9/29/16
to seleniu...@googlegroups.com
Check this : We can do webservice testing automation using JerseyClient

Thanks
Nag

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/8ddda81f-1633-4819-8c8a-fb8237c7a526%40googlegroups.com.

Vikram

unread,
Sep 29, 2016, 11:44:39 AM9/29/16
to Selenium Users
+1 REST Assured , found best in class.

Regards,
Vikram
Reply all
Reply to author
Forward
0 new messages