Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/iedriver/CommandHandlers/ActionsCommandHandler.cpp
2868 views
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 "License");
6
// you may not use this file except in compliance with the License.
7
// 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, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#include "ActionsCommandHandler.h"
18
#include "errorcodes.h"
19
#include "json.h"
20
#include "../Alert.h"
21
#include "../Browser.h"
22
#include "../IECommandExecutor.h"
23
#include "../InputManager.h"
24
25
namespace webdriver {
26
27
ActionsCommandHandler::ActionsCommandHandler(void) {
28
}
29
30
ActionsCommandHandler::~ActionsCommandHandler(void) {
31
}
32
33
void ActionsCommandHandler::ExecuteInternal(
34
const IECommandExecutor& executor,
35
const ParametersMap& command_parameters,
36
Response* response) {
37
BrowserHandle browser_wrapper;
38
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
39
if (status_code != WD_SUCCESS) {
40
response->SetErrorResponse(status_code, "Unable to get current browser");
41
return;
42
}
43
ParametersMap::const_iterator actions_parameter_iterator = command_parameters.find("actions");
44
if (actions_parameter_iterator == command_parameters.end()) {
45
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: actions");
46
return;
47
}
48
if (!actions_parameter_iterator->second.isArray()) {
49
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Actions value is not an array");
50
return;
51
}
52
std::string error_info = "";
53
status_code = executor.input_manager()->PerformInputSequence(browser_wrapper,
54
actions_parameter_iterator->second,
55
&error_info);
56
if (status_code != WD_SUCCESS) {
57
if (status_code == EMOVETARGETOUTOFBOUNDS) {
58
response->SetErrorResponse(status_code, error_info);
59
} else {
60
response->SetErrorResponse(status_code, "Unexpected error performing action sequence.");
61
}
62
return;
63
}
64
response->SetSuccessResponse(Json::Value::null);
65
}
66
67
} // namespace webdriver
68
69