|
| 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 | +} |
0 commit comments