1717
1818package org .openqa .selenium .bidi .browsingcontext ;
1919
20- import com .google .common .collect .ImmutableMap ;
2120import java .lang .reflect .Type ;
2221import java .util .ArrayList ;
2322import java .util .HashMap ;
@@ -110,46 +109,42 @@ public String getId() {
110109 private String create (WindowType type ) {
111110 return this .bidi .send (
112111 new Command <>(
113- "browsingContext.create" ,
114- ImmutableMap .of ("type" , type .toString ()),
115- browsingContextIdMapper ));
112+ "browsingContext.create" , Map .of ("type" , type .toString ()), browsingContextIdMapper ));
116113 }
117114
118115 private String create (WindowType type , String referenceContext ) {
119116 return this .bidi .send (
120117 new Command <>(
121118 "browsingContext.create" ,
122- ImmutableMap .of ("type" , type .toString (), "referenceContext" , referenceContext ),
119+ Map .of ("type" , type .toString (), "referenceContext" , referenceContext ),
123120 browsingContextIdMapper ));
124121 }
125122
126123 public NavigationResult navigate (String url ) {
127124 return this .bidi .send (
128125 new Command <>(
129- "browsingContext.navigate" ,
130- ImmutableMap .of (CONTEXT , id , "url" , url ),
131- navigationInfoMapper ));
126+ "browsingContext.navigate" , Map .of (CONTEXT , id , "url" , url ), navigationInfoMapper ));
132127 }
133128
134129 public NavigationResult navigate (String url , ReadinessState readinessState ) {
135130 return this .bidi .send (
136131 new Command <>(
137132 "browsingContext.navigate" ,
138- ImmutableMap .of (CONTEXT , id , "url" , url , "wait" , readinessState .toString ()),
133+ Map .of (CONTEXT , id , "url" , url , "wait" , readinessState .toString ()),
139134 navigationInfoMapper ));
140135 }
141136
142137 public List <BrowsingContextInfo > getTree () {
143138 return this .bidi .send (
144139 new Command <>(
145- "browsingContext.getTree" , ImmutableMap .of ("root" , id ), browsingContextInfoListMapper ));
140+ "browsingContext.getTree" , Map .of ("root" , id ), browsingContextInfoListMapper ));
146141 }
147142
148143 public List <BrowsingContextInfo > getTree (int maxDepth ) {
149144 return this .bidi .send (
150145 new Command <>(
151146 "browsingContext.getTree" ,
152- ImmutableMap .of (
147+ Map .of (
153148 "root" , id ,
154149 "maxDepth" , maxDepth ),
155150 browsingContextInfoListMapper ));
@@ -161,65 +156,56 @@ public List<BrowsingContextInfo> getTopLevelContexts() {
161156 }
162157
163158 public NavigationResult reload () {
164- return this .bidi .send (
165- new Command <>(RELOAD , ImmutableMap .of (CONTEXT , id ), navigationInfoMapper ));
159+ return this .bidi .send (new Command <>(RELOAD , Map .of (CONTEXT , id ), navigationInfoMapper ));
166160 }
167161
168162 // Yet to be implemented by browser vendors
169163 private NavigationResult reload (boolean ignoreCache ) {
170164 return this .bidi .send (
171165 new Command <>(
172- RELOAD ,
173- ImmutableMap .of (CONTEXT , id , "ignoreCache" , ignoreCache ),
174- navigationInfoMapper ));
166+ RELOAD , Map .of (CONTEXT , id , "ignoreCache" , ignoreCache ), navigationInfoMapper ));
175167 }
176168
177169 // TODO: Handle timeouts in case of Readiness state "interactive" and "complete".
178170 // Refer https://github.com/w3c/webdriver-bidi/issues/188
179171 public NavigationResult reload (ReadinessState readinessState ) {
180172 return this .bidi .send (
181173 new Command <>(
182- RELOAD ,
183- ImmutableMap .of (CONTEXT , id , "wait" , readinessState .toString ()),
184- navigationInfoMapper ));
174+ RELOAD , Map .of (CONTEXT , id , "wait" , readinessState .toString ()), navigationInfoMapper ));
185175 }
186176
187177 // Yet to be implemented by browser vendors
188178 private NavigationResult reload (boolean ignoreCache , ReadinessState readinessState ) {
189179 return this .bidi .send (
190180 new Command <>(
191181 RELOAD ,
192- ImmutableMap .of (
193- CONTEXT , id , "ignoreCache" , ignoreCache , "wait" , readinessState .toString ()),
182+ Map .of (CONTEXT , id , "ignoreCache" , ignoreCache , "wait" , readinessState .toString ()),
194183 navigationInfoMapper ));
195184 }
196185
197186 public void handleUserPrompt () {
198- this .bidi .send (new Command <>(HANDLE_USER_PROMPT , ImmutableMap .of (CONTEXT , id )));
187+ this .bidi .send (new Command <>(HANDLE_USER_PROMPT , Map .of (CONTEXT , id )));
199188 }
200189
201190 public void handleUserPrompt (boolean accept ) {
202- this .bidi .send (
203- new Command <>(HANDLE_USER_PROMPT , ImmutableMap .of (CONTEXT , id , "accept" , accept )));
191+ this .bidi .send (new Command <>(HANDLE_USER_PROMPT , Map .of (CONTEXT , id , "accept" , accept )));
204192 }
205193
206194 public void handleUserPrompt (String userText ) {
207- this .bidi .send (
208- new Command <>(HANDLE_USER_PROMPT , ImmutableMap .of (CONTEXT , id , "userText" , userText )));
195+ this .bidi .send (new Command <>(HANDLE_USER_PROMPT , Map .of (CONTEXT , id , "userText" , userText )));
209196 }
210197
211198 public void handleUserPrompt (boolean accept , String userText ) {
212199 this .bidi .send (
213200 new Command <>(
214- HANDLE_USER_PROMPT ,
215- ImmutableMap .of (CONTEXT , id , "accept" , accept , "userText" , userText )));
201+ HANDLE_USER_PROMPT , Map .of (CONTEXT , id , "accept" , accept , "userText" , userText )));
216202 }
217203
218204 public String captureScreenshot () {
219205 return this .bidi .send (
220206 new Command <>(
221207 "browsingContext.captureScreenshot" ,
222- ImmutableMap .of (CONTEXT , id ),
208+ Map .of (CONTEXT , id ),
223209 jsonInput -> {
224210 Map <String , Object > result = jsonInput .read (Map .class );
225211 return (String ) result .get ("data" );
@@ -230,11 +216,11 @@ public String captureBoxScreenshot(double x, double y, double width, double heig
230216 return this .bidi .send (
231217 new Command <>(
232218 "browsingContext.captureScreenshot" ,
233- ImmutableMap .of (
219+ Map .of (
234220 CONTEXT ,
235221 id ,
236222 "clip" ,
237- ImmutableMap .of (
223+ Map .of (
238224 "type" , "viewport" ,
239225 "x" , x ,
240226 "y" , y ,
@@ -250,15 +236,15 @@ public String captureElementScreenshot(String elementId) {
250236 return this .bidi .send (
251237 new Command <>(
252238 "browsingContext.captureScreenshot" ,
253- ImmutableMap .of (
239+ Map .of (
254240 CONTEXT ,
255241 id ,
256242 "clip" ,
257- ImmutableMap .of (
243+ Map .of (
258244 "type" ,
259245 "element" ,
260246 "element" ,
261- ImmutableMap .of ("sharedId" , elementId ),
247+ Map .of ("sharedId" , elementId ),
262248 "scrollIntoView" ,
263249 false )),
264250 jsonInput -> {
@@ -271,15 +257,15 @@ public String captureElementScreenshot(String elementId, boolean scrollIntoView)
271257 return this .bidi .send (
272258 new Command <>(
273259 "browsingContext.captureScreenshot" ,
274- ImmutableMap .of (
260+ Map .of (
275261 CONTEXT ,
276262 id ,
277263 "clip" ,
278- ImmutableMap .of (
264+ Map .of (
279265 "type" ,
280266 "element" ,
281267 "element" ,
282- ImmutableMap .of ("sharedId" , elementId ),
268+ Map .of ("sharedId" , elementId ),
283269 "scrollIntoView" ,
284270 scrollIntoView )),
285271 jsonInput -> {
@@ -323,6 +309,6 @@ public void close() {
323309 // This might need more clean up actions once the behavior is defined.
324310 // Specially when last tab or window is closed.
325311 // Refer: https://github.com/w3c/webdriver-bidi/issues/187
326- this .bidi .send (new Command <>("browsingContext.close" , ImmutableMap .of (CONTEXT , id )));
312+ this .bidi .send (new Command <>("browsingContext.close" , Map .of (CONTEXT , id )));
327313 }
328314}
0 commit comments