-
Notifications
You must be signed in to change notification settings - Fork 0
/
Questions_And_Answers
72 lines (61 loc) · 2.29 KB
/
Questions_And_Answers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
TOP 10 REST Assured API Automation Interview Questions and Answers
1. What is Rest assured and Why it is used?
--> Rest Assured is one of the most populer java based library which is highly used in API test automation
--> It helps in writing powerful and maintainable tests for RESTful APIs.
2. What is URI, endpoint and query parameter?
https:// regres.in /api/users ? page=2
protocol URI/base URL end point query parameter
3. What are the static imports in Rest Assured and why we need it?
import static io.restassured.RestAssured.*;
import static io.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
4. What are the given, when and then methods in Rest-assured?
given()
.param("page","2")
.auth().none().
when()
.get("https://regres.in/api/users").
then()
.statusCode(200)
.body("page",equalTo(2));
5. What are the different authentication methods in Rest-assured?
Basic authentication
Digest authentication
Form authentication
OAuth 1 and OAuth 2
6. How to check Response time for an API?
-->getTime() - The response time in milliseconds.
-->getTimeIn(TimeUnit timeunit) - The response time in the given time unit.
-->time() - The response time in milliseconds.
-->timeIn(TimeUnit timeunit) - The response time in the given time unit.
7. How to send a complex payload for a post API using POJO classes?
Post Url = https://regres.in/api/users
payload
{
"name":"bahadir",
"job":"qa engineer",
"skills":["selenium","java"],
"details":{
"companyName":"XYZ",
"emailId":"bahadir@test.com"
}
}
8. How to log request and response for a post API?
Response response = PetEndPoints.readPet(createdId);
response.then().log().all();
Assert.assertEquals(response.getStatusCode(), 200);
HTTP/1.1 200 OK
Date: Sat, 14 Dec 2024 23:14:04 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Server: Jetty(9.2.9.v20150224)
9. How to validate the response of a POST API?
10. How to verify cookie, headers & content-type in API response?
Using below methods.
-->getHeaders()
-->getCookies()
-->getContentType()