Other Useful Links:
- Manual Testing Interview Questions (01-40)
- Manual Testing Interview Questions (41-80)
- Selenium With Java Interview Questions - (01-35)
- Selenium With Java Interview Questions - (36-70)
- Java Interview Questions for QA (01-50)
- Java Interview Questions for QA (51-100)
- Java Programs for QA Automation Interview (01-15)
- Java Programs for QA Automation Interview (16-30)
- TestNG Interview Questions for QA (01-20)
- TestNG Interview Questions for QA (21-40)
- Maven Interview Questions for QA Automation Interview (01-15)
- Maven Interview Questions for QA Automation Interview (16-30)
21. What is the upper limit for a payload to pass in the POST method?
22. Is it possible to hack API while testing?
23. How should we test the API security?
- <GET> appends data to the service URL. However, it should not be longer than the maximum URL length. However, <POST> doesn’t have any such limit.
- As a result, a user can theoretically give a limitless amount of data as the payload to the POST method. However, in a real-world scenario, sending a POST with a huge payload will take more bandwidth. It will take longer and cause performance issues for your server.
22. Is it possible to hack API while testing?
- Yes, it is possible. This is due to the fact that we are sending queries over the internet using the HTTP protocol. This protocol is written in text and is easier to understand.
23. How should we test the API security?
To test the security of the API during API testing, we need to validate 2 things:
24. What is the most commonly used command-line tool to explore API?
- Authentication: Whether the end-identity user's is correct.
- Authorization: Whether the user has permission to use the resource.
- We can also check whether or not the TLS or SSL certificate used over the HTTPS protocol is legitimate.
24. What is the most commonly used command-line tool to explore API?
- Curl
- API Gateway
26. What among the following options provides security to JWT token content?
- Signature
27. API testing belongs to which among the following categories?
- Black Box Testing
28. What is Latency in API testing?
- The response time or delay that the request takes to reach the server is referred to as latency. We need to ensure that the latency involved in reaching the server is minimum as higher the latency, greater is the impact on the application’s speed and performance.
29. What is Rest Assured?
- Rest Assured is a java-based framework for evaluating RESTful Web Services. It accesses REST services as a headless client. REST Assured comes with a slew of capabilities that make API automation testing a breeze. It offers friendly DSL-like syntax, XPath-Validation, Specification Reuse, Easy file uploads.
30. What is the difference between 406 (Not Acceptable) and 415 (Unsupported Media Type)?
- The server returns 406 when it is unable to respond based on the request headers.
- 415 is returned by the server when the entity sent in a request (content in a POST or PUT) has an unsupported media type
- so, 406 when you don’t send what they want, 415 when they send what you don't want.
31. What is a postman? Why do we need it?
- Postman is an application that is used for API Testing.
- Postman sends an API request to the server and receives the response.
- No extra work or set up framework is required while sending and receiving
- request/response in postman.
- Extensively used by testers and developers.
- Easy to use and friendly interface.
- We can get scripts in different programming language.
32. What are Collections in Postman?
Collections in postman is a group of API requests that are already saved in Postman and can be arranged into a folder. Advantages:
- Easy API import and export.
- For convenient access, requests can be organised into folders and collections.
- Data can be sent across API queries using scripts.
- Run Collection option is available.
- API documentation.
- Time Saving
33. Web Services vs API
34. SOAP vs REST
35. Get vs Post
36. PUT vs POST
37. PUT vs PATCH
38. Points to remember while writing test cases for API scenarios.
Positive Testing:
- Execute with valid and required request parameters.
- Check whether it supports different parameters like XML, JOSN.
- Validate response contents.
- Validate response code.
- Validate header.
- Validate Json schema
- Validation in Database
- Validation in server/access logs.
- Performance: if it returns the response in a timely manner.
- Output support: XML and JSON
- Valid input but illegal operations: Attempt to create a resource with duplicate name
- Attempt to delete a resource that doesn’t exist.
- Update resource with illegal/incorrect data.
- Missing / invalid authentication.
- Missing Required Parameters
- Invalid endpoints
- Invalid payload
- Huge Payload
- Executing same requests multiple times: DOS, D-DOS scenarios
- Incorrect content types.
- Maximum number of characters in a filed.
- If a third party server is used and is down.
39. Sample Code: GET Request With Query Params:
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.*;
import static io.restassured.RestAssured.given;
public class RestAssuredRequests {
@BeforeAll
public static void setup() {
RestAssured.baseURI = "https://jsonplaceholder.typicode.com";
}
@Test
public void getRequestWithQueryParam() {
Response response = given()
.contentType(ContentType.JSON)
.param("postId", "2")
.when()
.get("/comments")
.then()
.extract().response();
Assertions.assertEquals(200, response.statusCode());
Assertions.assertEquals("abc@test.com", response.jsonPath().getString("email[3]"));
}
}
POST Request:
import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.junit.jupiter.api.*;
import static io.restassured.RestAssured.given;
public class RestAssuredRequests {
private static String requestBody = "{\n" +
" \"title\": \"foo\",\n" +
" \"body\": \"bar\",\n" +
" \"userId\": \"1\" \n}";
@BeforeAll
public static void setup() {
RestAssured.baseURI = "https://jsonplaceholder.typicode.com";
}
@Test
public void postRequest() {
Response response = given()
.header("Content-type", "application/json")
.and()
.body(requestBody)
.when()
.post("/posts")
.then()
.extract().response();
Assertions.assertEquals(201, response.statusCode());
Assertions.assertEquals("TestTitle", response.jsonPath().getString("title"));
Assertions.assertEquals("TestBody", response.jsonPath().getString("body"));
Assertions.assertEquals("1", response.jsonPath().getString("userId"));
Assertions.assertEquals("101", response.jsonPath().getString("id"));
}
}
40. API Automation Using Robot FrameWork: Link
Greetings, reader! Your input is highly important to us. Please share your thoughts in the comments section below.
Contact:
Email: piyushagrawal.automation@gmail.com
Follow on LinkedIn: Piyush Agrawal - LinkedIn
Follow on YouTube: Piyush Agrawal - Youtube
No comments:
Post a Comment