2222import static org .openqa .selenium .remote .DriverCommand .GET_ELEMENT_SIZE ;
2323import static org .openqa .selenium .remote .DriverCommand .GET_PAGE_SOURCE ;
2424import static org .openqa .selenium .remote .DriverCommand .IS_ELEMENT_DISPLAYED ;
25- import static org .openqa .selenium .remote .DriverCommand .SEND_KEYS_TO_ACTIVE_ELEMENT ;
2625import static org .openqa .selenium .remote .DriverCommand .SEND_KEYS_TO_ELEMENT ;
2726import static org .openqa .selenium .remote .DriverCommand .SET_TIMEOUT ;
2827import static org .openqa .selenium .remote .DriverCommand .SUBMIT_ELEMENT ;
2928
30- import com .google .common .collect .ImmutableList ;
31- import com .google .common .collect .ImmutableMap ;
32-
33- import org .openqa .selenium .interactions .KeyInput ;
34- import org .openqa .selenium .interactions .Sequence ;
3529import org .openqa .selenium .remote .codec .w3c .W3CHttpCommandCodec ;
3630
37- import java .util .Collection ;
3831import java .util .Map ;
39- import java .util .stream .Collectors ;
40- import java .util .stream .Stream ;
4132
4233public class AppiumW3CHttpCommandCodec extends W3CHttpCommandCodec {
4334 /**
@@ -51,7 +42,6 @@ public AppiumW3CHttpCommandCodec() {
5142 defineCommand (GET_ELEMENT_ATTRIBUTE , get ("/session/:sessionId/element/:id/attribute/:name" ));
5243 defineCommand (IS_ELEMENT_DISPLAYED , get ("/session/:sessionId/element/:id/displayed" ));
5344 defineCommand (GET_PAGE_SOURCE , get ("/session/:sessionId/source" ));
54- defineCommand (SEND_KEYS_TO_ACTIVE_ELEMENT , post ("/session/:sessionId/actions" ));
5545 }
5646
5747 @ Override
@@ -76,23 +66,6 @@ public void alias(String commandName, String isAnAliasFor) {
7666 protected Map <String , ?> amendParameters (String name , Map <String , ?> parameters ) {
7767 // This blocks parent constructor from undesirable parameters amending
7868 switch (name ) {
79- case SEND_KEYS_TO_ACTIVE_ELEMENT :
80- Object rawValue = parameters .get ("value" );
81- //noinspection unchecked
82- Stream <CharSequence > source = (rawValue instanceof Collection )
83- ? ((Collection <CharSequence >) rawValue ).stream ()
84- : Stream .of ((CharSequence []) rawValue );
85- String text = source .collect (Collectors .joining ());
86-
87- final KeyInput keyboard = new KeyInput ("keyboard" );
88- Sequence sequence = new Sequence (keyboard , 0 );
89- for (int i = 0 ; i < text .length (); ++i ) {
90- sequence .addAction (keyboard .createKeyDown (text .charAt (i )))
91- .addAction (keyboard .createKeyUp (text .charAt (i )));
92- }
93- return ImmutableMap .<String , Object >builder ()
94- .put ("actions" , ImmutableList .of (sequence .toJson ()))
95- .build ();
9669 case SEND_KEYS_TO_ELEMENT :
9770 case SET_TIMEOUT :
9871 return super .amendParameters (name , parameters );
0 commit comments