Repository navigation
Expand file tree
/
Copy pathAirMeetStatusCheck
More file actions
171 lines (110 loc) · 5.03 KB
/
Copy pathAirMeetStatusCheck
File metadata and controls
171 lines (110 loc) · 5.03 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import java.util.ArrayList;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.jayway.jsonpath.JsonPath;
import com.testsigma.customfunc.common.CustomTestStep;
import com.testsigma.customfunc.common.TestsigmaCustomFunctions;
import com.testsigma.customfunc.result.ResultConstants;
import com.testsigma.customfunc.result.TestStepResult;
import com.testsigma.testengine.exceptions.TestEngineException;
import io.appium.java_client.android.AndroidDriver;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class AirMeetApi extends TestsigmaCustomFunctions {
TestStepResult result = new TestStepResult();
AndroidDriver d = (AndroidDriver)driver;
@CustomTestStep
public TestStepResult validateeventstatus(String EventURLforAPI , String XpathofElement) throws TestEngineException {
try {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
//RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url(EventURLforAPI)
.method("GET", null)
.addHeader("Cookie", "__cf_bm=ZbVcZPu5EGlPoTiv8S7COt2r9pwqtJeliiuMA6EHrSw-1655113754-0-AcGem2SRct4g+MKkaS42dVIHfu+Y2qNly05omKC/eCxEvPvtrGprPGkwuDjq8zGLV0FIZZv0uFwAaHXXdrW0LLU=; _cfuvid=II4gnYbhnG4OfqASe74Xqt1ECwQBcqFMS_Gnq_GGlj4-1655113754383-0-604800000")
.build();
Response response = client.newCall(request).execute();
String responsebody=response.body().string();
WebElement wb = d.findElement(By.xpath(""+XpathofElement+""));
String value = wb.getText();
String status1 = JsonPath.parse(responsebody).read("$.status");
switch(status1) {
case "ONGOING" :
if (value.equals("Started")) {
result.setStatus(ResultConstants.SUCCESS);
result.setMessage("API status is ONGOING and UI status is Started");
}else {
result.setStatus(ResultConstants.FAILURE);
result.setMessage("API and UI status doesnot match:::Value from the UI is "+value);
}
break;
case "FINISHED" :
if (value.equals("Ended")) {
result.setStatus(ResultConstants.SUCCESS);
result.setMessage("API status is FINISHED and UI status is Ended");
}else {
result.setStatus(ResultConstants.FAILURE);
result.setMessage("API and UI status doesnot match:::Value from the UI is "+value);
}
break;
case "PAUSED" :
if (value.equals("Paused")) {
result.setStatus(ResultConstants.SUCCESS);
result.setMessage("API status is PAUSED and UI status is Paused");
}else {
result.setStatus(ResultConstants.FAILURE);
result.setMessage("API and UI status doesnot match:::Value from the UI is "+value);
}
break;
case "CREATED" :
if (value.equals("Not Started")) {
result.setStatus(ResultConstants.SUCCESS);
result.setMessage("API status is CREATED and UI status is Not Started");
}else {
result.setStatus(ResultConstants.FAILURE);
result.setMessage("API and UI status doesnot match:::Value from the UI is "+value);
}
break;
}
}catch(Exception e) {
result.setStatus(ResultConstants.FAILURE);
result.setMessage(e.getMessage());
}
return result;
}
@CustomTestStep
public TestStepResult validatespeakerlist(String EventURLforAPI, String XpathofSpeakerName) {
try {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
//RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url(EventURLforAPI)
.method("GET", null)
.addHeader("Cookie", "__cf_bm=ZbVcZPu5EGlPoTiv8S7COt2r9pwqtJeliiuMA6EHrSw-1655113754-0-AcGem2SRct4g+MKkaS42dVIHfu+Y2qNly05omKC/eCxEvPvtrGprPGkwuDjq8zGLV0FIZZv0uFwAaHXXdrW0LLU=; _cfuvid=II4gnYbhnG4OfqASe74Xqt1ECwQBcqFMS_Gnq_GGlj4-1655113754383-0-604800000")
.build();
Response response = client.newCall(request).execute();
String responsebody=response.body().string();
WebElement wb = d.findElement(By.xpath(""+XpathofSpeakerName+""));
String value = wb.getText();
ArrayList<String> speakerarr= JsonPath.parse(responsebody).read("$.sessions[*].speakerList[*].name");
if(speakerarr.contains(value)) {
result.setStatus(ResultConstants.SUCCESS);
result.setMessage("Speaker with name "+value+" is found in the API response");
}else {
result.setStatus(ResultConstants.FAILURE);
result.setMessage("Speaker with name "+value+" is not found in the API response");
}
}
catch(Exception e) {
result.setStatus(ResultConstants.FAILURE);
result.setMessage(e.getMessage());
}
return result;
}
}