Skip to content

Commit 179bd93

Browse files
committed
Add an endpoint for the W3C Actions commands to the standalone server
Slowly getting there.
1 parent ec8ff72 commit 179bd93

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
lines changed

java/server/src/org/openqa/selenium/remote/server/JsonHttpCommandHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import org.openqa.selenium.remote.server.handler.SwitchToParentFrame;
106106
import org.openqa.selenium.remote.server.handler.SwitchToWindow;
107107
import org.openqa.selenium.remote.server.handler.UploadFile;
108+
import org.openqa.selenium.remote.server.handler.W3CActions;
108109
import org.openqa.selenium.remote.server.handler.html5.ClearLocalStorage;
109110
import org.openqa.selenium.remote.server.handler.html5.ClearSessionStorage;
110111
import org.openqa.selenium.remote.server.handler.html5.GetAppCacheStatus;
@@ -348,6 +349,8 @@ private void setUpMappings() {
348349
addNewMapping(IME_DEACTIVATE, ImeDeactivate.class);
349350
addNewMapping(IME_ACTIVATE_ENGINE, ImeActivateEngine.class);
350351

352+
addNewMapping(ACTIONS, W3CActions.class);
353+
351354
// Advanced Touch API
352355
addNewMapping(TOUCH_SINGLE_TAP, SingleTapOnElement.class);
353356
addNewMapping(TOUCH_DOWN, Down.class);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.openqa.selenium.remote.server.handler;
19+
20+
import static org.openqa.selenium.remote.DriverCommand.ACTIONS;
21+
22+
import org.openqa.selenium.remote.Command;
23+
import org.openqa.selenium.remote.CommandExecutor;
24+
import org.openqa.selenium.remote.ErrorHandler;
25+
import org.openqa.selenium.remote.RemoteWebDriver;
26+
import org.openqa.selenium.remote.Response;
27+
import org.openqa.selenium.remote.server.JsonParametersAware;
28+
import org.openqa.selenium.remote.server.Session;
29+
30+
import java.util.Map;
31+
32+
33+
public class W3CActions extends WebDriverHandler<Void> implements JsonParametersAware {
34+
35+
private Map<String, Object> allParameters;
36+
37+
public W3CActions(Session session) {
38+
super(session);
39+
}
40+
41+
@Override
42+
public void setJsonParameters(Map<String, Object> allParameters) throws Exception {
43+
this.allParameters = allParameters;
44+
}
45+
46+
@Override
47+
public Void call() throws Exception {
48+
RemoteWebDriver driver = (RemoteWebDriver) getUnwrappedDriver();
49+
CommandExecutor executor = (driver).getCommandExecutor();
50+
51+
long start = System.currentTimeMillis();
52+
Command command = new Command(driver.getSessionId(), ACTIONS, allParameters);
53+
Response response = executor.execute(command);
54+
55+
new ErrorHandler(true)
56+
.throwIfResponseFailed(response, System.currentTimeMillis() - start);
57+
58+
return null;
59+
}
60+
}

java/server/src/org/openqa/selenium/remote/server/rest/ResultConfig.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,7 @@ public RestishHandler<?> createHandler(SessionId sessionId) throws Exception {
226226

227227
final Constructor<? extends RestishHandler> norags = getConstructor(handlerClazz);
228228
if (norags != null) {
229-
return new HandlerFactory() {
230-
@Override
231-
public RestishHandler<?> createHandler(SessionId sessionId) throws Exception {
232-
return norags.newInstance();
233-
}
234-
};
229+
return norags::newInstance;
235230
}
236231

237232
throw new IllegalArgumentException("Don't know how to construct " + handlerClazz);

0 commit comments

Comments
 (0)