Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ signing.secretKeyRingFile=PathToYourKeyRingFile
ossrhUsername=your-jira-id
ossrhPassword=your-jira-password

selenium.version=4.2.1
selenium.version=4.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@
import static org.openqa.selenium.remote.DriverCommand.GET_ELEMENT_SIZE;
import static org.openqa.selenium.remote.DriverCommand.GET_PAGE_SOURCE;
import static org.openqa.selenium.remote.DriverCommand.IS_ELEMENT_DISPLAYED;
import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ACTIVE_ELEMENT;
import static org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ELEMENT;
import static org.openqa.selenium.remote.DriverCommand.SET_TIMEOUT;
import static org.openqa.selenium.remote.DriverCommand.SUBMIT_ELEMENT;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.interactions.KeyInput;
import org.openqa.selenium.interactions.Sequence;
import org.openqa.selenium.remote.codec.w3c.W3CHttpCommandCodec;

import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class AppiumW3CHttpCommandCodec extends W3CHttpCommandCodec {
/**
Expand All @@ -51,7 +42,6 @@ public AppiumW3CHttpCommandCodec() {
defineCommand(GET_ELEMENT_ATTRIBUTE, get("/session/:sessionId/element/:id/attribute/:name"));
defineCommand(IS_ELEMENT_DISPLAYED, get("/session/:sessionId/element/:id/displayed"));
defineCommand(GET_PAGE_SOURCE, get("/session/:sessionId/source"));
defineCommand(SEND_KEYS_TO_ACTIVE_ELEMENT, post("/session/:sessionId/actions"));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org.openqa.selenium.remote.DriverCommand.SEND_KEYS_TO_ACTIVE_ELEMENT is removed in SeleniumHQ/selenium@4dcc9c4

}

@Override
Expand All @@ -76,23 +66,6 @@ public void alias(String commandName, String isAnAliasFor) {
protected Map<String, ?> amendParameters(String name, Map<String, ?> parameters) {
// This blocks parent constructor from undesirable parameters amending
switch (name) {
case SEND_KEYS_TO_ACTIVE_ELEMENT:
Object rawValue = parameters.get("value");
//noinspection unchecked
Stream<CharSequence> source = (rawValue instanceof Collection)
? ((Collection<CharSequence>) rawValue).stream()
: Stream.of((CharSequence[]) rawValue);
String text = source.collect(Collectors.joining());

final KeyInput keyboard = new KeyInput("keyboard");
Sequence sequence = new Sequence(keyboard, 0);
for (int i = 0; i < text.length(); ++i) {
sequence.addAction(keyboard.createKeyDown(text.charAt(i)))
.addAction(keyboard.createKeyUp(text.charAt(i)));
}
return ImmutableMap.<String, Object>builder()
.put("actions", ImmutableList.of(sequence.toJson()))
.build();
case SEND_KEYS_TO_ELEMENT:
case SET_TIMEOUT:
return super.amendParameters(name, parameters);
Expand Down