@@ -425,7 +425,7 @@ impl Client {
425
425
}
426
426
} ) ;
427
427
(
428
- future:: Either :: A ( f ) ,
428
+ future:: Either :: A ( Box :: new ( f ) as Box < Future < Item = _ , Error = _ > > ) ,
429
429
future:: Either :: A ( rx. into_future ( ) . then ( |_| Ok ( ( ) ) ) ) ,
430
430
)
431
431
}
@@ -736,14 +736,16 @@ impl Client {
736
736
/// Navigate directly to the given URL.
737
737
pub fn goto ( & self , url : & str ) -> impl Future < Item = Self , Error = error:: CmdError > + ' static {
738
738
let url = url. to_owned ( ) ;
739
- self . current_url_ ( )
740
- . and_then ( move |( this, base) | Ok ( ( this, base. join ( & url) ?) ) )
741
- . and_then ( move |( this, url) | {
742
- this. issue_wd_cmd ( WebDriverCommand :: Get (
743
- webdriver:: command:: GetParameters { url : url. into_string ( ) } ,
744
- ) )
745
- } )
746
- . map ( |( this, _) | this)
739
+ Box :: new (
740
+ self . current_url_ ( )
741
+ . and_then ( move |( this, base) | Ok ( ( this, base. join ( & url) ?) ) )
742
+ . and_then ( move |( this, url) | {
743
+ this. issue_wd_cmd ( WebDriverCommand :: Get ( webdriver:: command:: GetParameters {
744
+ url : url. into_string ( ) ,
745
+ } ) )
746
+ } )
747
+ . map ( |( this, _) | this) ,
748
+ ) as Box < Future < Item = _ , Error = _ > >
747
749
}
748
750
749
751
#[ inline]
@@ -1020,13 +1022,15 @@ impl Client {
1020
1022
selector : & str ,
1021
1023
) -> impl Future < Item = Form , Error = error:: CmdError > + ' static {
1022
1024
let locator = Self :: mklocator ( selector) ;
1023
- self . dup ( )
1024
- . issue_wd_cmd ( WebDriverCommand :: FindElement ( locator) )
1025
- . map_err ( |e| e. into ( ) )
1026
- . and_then ( |( this, res) | {
1027
- let f = this. parse_lookup ( res) ;
1028
- f. map ( move |f| Form { c : this, f : f } )
1029
- } )
1025
+ Box :: new (
1026
+ self . dup ( )
1027
+ . issue_wd_cmd ( WebDriverCommand :: FindElement ( locator) )
1028
+ . map_err ( |e| e. into ( ) )
1029
+ . and_then ( |( this, res) | {
1030
+ let f = this. parse_lookup ( res) ;
1031
+ f. map ( move |f| Form { c : this, f : f } )
1032
+ } ) ,
1033
+ ) as Box < Future < Item = _ , Error = _ > >
1030
1034
}
1031
1035
1032
1036
// helpers
@@ -1036,13 +1040,15 @@ impl Client {
1036
1040
& self ,
1037
1041
locator : webdriver:: command:: LocatorParameters ,
1038
1042
) -> impl Future < Item = Element , Error = error:: CmdError > + ' static {
1039
- self . dup ( )
1040
- . issue_wd_cmd ( WebDriverCommand :: FindElement ( locator) )
1041
- . map_err ( |e| e. into ( ) )
1042
- . and_then ( |( this, res) | {
1043
- let e = this. parse_lookup ( res) ;
1044
- e. map ( move |e| Element { c : this, e : e } )
1045
- } )
1043
+ Box :: new (
1044
+ self . dup ( )
1045
+ . issue_wd_cmd ( WebDriverCommand :: FindElement ( locator) )
1046
+ . map_err ( |e| e. into ( ) )
1047
+ . and_then ( |( this, res) | {
1048
+ let e = this. parse_lookup ( res) ;
1049
+ e. map ( move |e| Element { c : this, e : e } )
1050
+ } ) ,
1051
+ ) as Box < Future < Item = _ , Error = _ > >
1046
1052
}
1047
1053
1048
1054
/// Extract the `WebElement` from a `FindElement` or `FindElementElement` command.
@@ -1187,24 +1193,26 @@ impl Element {
1187
1193
/// Note that since this *may* result in navigation, we give up the handle to the element.
1188
1194
pub fn follow ( self ) -> impl Future < Item = Client , Error = error:: CmdError > + ' static {
1189
1195
let cmd = WebDriverCommand :: GetElementAttribute ( self . e , "href" . to_string ( ) ) ;
1190
- self . c
1191
- . issue_wd_cmd ( cmd)
1192
- . and_then ( |( this, href) | match href {
1193
- Json :: String ( v) => Ok ( ( this, v) ) ,
1194
- Json :: Null => {
1195
- let e = WebDriverError :: new (
1196
- webdriver:: error:: ErrorStatus :: InvalidArgument ,
1197
- "cannot follow element without href attribute" ,
1198
- ) ;
1199
- Err ( error:: CmdError :: Standard ( e) )
1200
- }
1201
- v => Err ( error:: CmdError :: NotW3C ( v) ) ,
1202
- } )
1203
- . and_then ( |( this, href) | {
1204
- this. current_url_ ( )
1205
- . and_then ( move |( this, url) | Ok ( ( this, url. join ( & href) ?) ) )
1206
- } )
1207
- . and_then ( |( this, href) | this. goto ( href. as_str ( ) ) . map ( |this| this) )
1196
+ Box :: new (
1197
+ self . c
1198
+ . issue_wd_cmd ( cmd)
1199
+ . and_then ( |( this, href) | match href {
1200
+ Json :: String ( v) => Ok ( ( this, v) ) ,
1201
+ Json :: Null => {
1202
+ let e = WebDriverError :: new (
1203
+ webdriver:: error:: ErrorStatus :: InvalidArgument ,
1204
+ "cannot follow element without href attribute" ,
1205
+ ) ;
1206
+ Err ( error:: CmdError :: Standard ( e) )
1207
+ }
1208
+ v => Err ( error:: CmdError :: NotW3C ( v) ) ,
1209
+ } )
1210
+ . and_then ( |( this, href) | {
1211
+ this. current_url_ ( )
1212
+ . and_then ( move |( this, url) | Ok ( ( this, url. join ( & href) ?) ) )
1213
+ } )
1214
+ . and_then ( |( this, href) | this. goto ( href. as_str ( ) ) . map ( |this| this) ) ,
1215
+ ) as Box < Future < Item = _ , Error = _ > >
1208
1216
}
1209
1217
}
1210
1218
@@ -1270,24 +1278,26 @@ impl Form {
1270
1278
) -> impl Future < Item = Client , Error = error:: CmdError > + ' static {
1271
1279
let locator = Client :: mklocator ( button) ;
1272
1280
let locator = WebDriverCommand :: FindElementElement ( self . f , locator) ;
1273
- self . c
1274
- . issue_wd_cmd ( locator)
1275
- . map_err ( |e| e. into ( ) )
1276
- . and_then ( |( this, res) | {
1277
- let s = this. parse_lookup ( res) ;
1278
- s. map ( move |s| ( this, s) )
1279
- } )
1280
- . and_then ( move |( this, submit) | {
1281
- this. issue_wd_cmd ( WebDriverCommand :: ElementClick ( submit) )
1282
- } )
1283
- . and_then ( move |( this, res) | {
1284
- if res. is_null ( ) || res. as_object ( ) . map ( |o| o. is_empty ( ) ) . unwrap_or ( false ) {
1285
- // geckodriver returns {} :(
1286
- Ok ( this)
1287
- } else {
1288
- Err ( error:: CmdError :: NotW3C ( res) )
1289
- }
1290
- } )
1281
+ Box :: new (
1282
+ self . c
1283
+ . issue_wd_cmd ( locator)
1284
+ . map_err ( |e| e. into ( ) )
1285
+ . and_then ( |( this, res) | {
1286
+ let s = this. parse_lookup ( res) ;
1287
+ s. map ( move |s| ( this, s) )
1288
+ } )
1289
+ . and_then ( move |( this, submit) | {
1290
+ this. issue_wd_cmd ( WebDriverCommand :: ElementClick ( submit) )
1291
+ } )
1292
+ . and_then ( move |( this, res) | {
1293
+ if res. is_null ( ) || res. as_object ( ) . map ( |o| o. is_empty ( ) ) . unwrap_or ( false ) {
1294
+ // geckodriver returns {} :(
1295
+ Ok ( this)
1296
+ } else {
1297
+ Err ( error:: CmdError :: NotW3C ( res) )
1298
+ }
1299
+ } ) ,
1300
+ ) as Box < Future < Item = _ , Error = _ > >
1291
1301
}
1292
1302
1293
1303
/// Submit this form using the form submit button with the given label (case-insensitive).
@@ -1296,14 +1306,14 @@ impl Form {
1296
1306
pub fn submit_using (
1297
1307
self ,
1298
1308
button_label : & str ,
1299
- ) -> impl Future < Item = Client , Error = error:: CmdError > {
1309
+ ) -> impl Future < Item = Client , Error = error:: CmdError > + ' static {
1300
1310
let escaped = button_label. replace ( '\\' , "\\ \\ " ) . replace ( '"' , "\\ \" " ) ;
1301
- self . submit_with ( & format ! (
1311
+ Box :: new ( self . submit_with ( & format ! (
1302
1312
"input[type=submit][value=\" {}\" i],\
1303
1313
button[type=submit][value=\" {}\" i]",
1304
1314
escaped,
1305
1315
escaped
1306
- ) )
1316
+ ) ) ) as Box < Future < Item = _ , Error = _ > >
1307
1317
}
1308
1318
1309
1319
/// Submit this form directly, without clicking any buttons.
@@ -1329,16 +1339,18 @@ impl Form {
1329
1339
args : webdriver:: common:: Nullable :: Value ( args) ,
1330
1340
} ;
1331
1341
1332
- self . c
1333
- . issue_wd_cmd ( WebDriverCommand :: ExecuteScript ( cmd) )
1334
- . and_then ( move |( this, res) | {
1335
- if res. is_null ( ) || res. as_object ( ) . map ( |o| o. is_empty ( ) ) . unwrap_or ( false ) {
1336
- // geckodriver returns {} :(
1337
- Ok ( this)
1338
- } else {
1339
- Err ( error:: CmdError :: NotW3C ( res) )
1340
- }
1341
- } )
1342
+ Box :: new (
1343
+ self . c
1344
+ . issue_wd_cmd ( WebDriverCommand :: ExecuteScript ( cmd) )
1345
+ . and_then ( move |( this, res) | {
1346
+ if res. is_null ( ) || res. as_object ( ) . map ( |o| o. is_empty ( ) ) . unwrap_or ( false ) {
1347
+ // geckodriver returns {} :(
1348
+ Ok ( this)
1349
+ } else {
1350
+ Err ( error:: CmdError :: NotW3C ( res) )
1351
+ }
1352
+ } ) ,
1353
+ ) as Box < Future < Item = _ , Error = _ > >
1342
1354
}
1343
1355
1344
1356
/// Submit this form directly, without clicking any buttons, and with an extra field.
@@ -1371,16 +1383,18 @@ impl Form {
1371
1383
} ;
1372
1384
1373
1385
let f = self . f ;
1374
- self . c
1375
- . issue_wd_cmd ( WebDriverCommand :: ExecuteScript ( cmd) )
1376
- . and_then ( move |( this, res) | {
1377
- if res. is_null ( ) | res. as_object ( ) . map ( |o| o. is_empty ( ) ) . unwrap_or ( false ) {
1378
- // geckodriver returns {} :(
1379
- future:: Either :: A ( Form { f : f, c : this } . submit_direct ( ) )
1380
- } else {
1381
- future:: Either :: B ( future:: err ( error:: CmdError :: NotW3C ( res) ) )
1382
- }
1383
- } )
1386
+ Box :: new (
1387
+ self . c
1388
+ . issue_wd_cmd ( WebDriverCommand :: ExecuteScript ( cmd) )
1389
+ . and_then ( move |( this, res) | {
1390
+ if res. is_null ( ) | res. as_object ( ) . map ( |o| o. is_empty ( ) ) . unwrap_or ( false ) {
1391
+ // geckodriver returns {} :(
1392
+ future:: Either :: A ( Form { f : f, c : this } . submit_direct ( ) )
1393
+ } else {
1394
+ future:: Either :: B ( future:: err ( error:: CmdError :: NotW3C ( res) ) )
1395
+ }
1396
+ } ) ,
1397
+ ) as Box < Future < Item = _ , Error = _ > >
1384
1398
}
1385
1399
}
1386
1400
0 commit comments