Path: blob/trunk/cpp/iedriver/CommandHandlers/ActionsCommandHandler.cpp
2868 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the "License");5// you may not use this file except in compliance with the License.6// You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS,12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13// See the License for the specific language governing permissions and14// limitations under the License.1516#include "ActionsCommandHandler.h"17#include "errorcodes.h"18#include "json.h"19#include "../Alert.h"20#include "../Browser.h"21#include "../IECommandExecutor.h"22#include "../InputManager.h"2324namespace webdriver {2526ActionsCommandHandler::ActionsCommandHandler(void) {27}2829ActionsCommandHandler::~ActionsCommandHandler(void) {30}3132void ActionsCommandHandler::ExecuteInternal(33const IECommandExecutor& executor,34const ParametersMap& command_parameters,35Response* response) {36BrowserHandle browser_wrapper;37int status_code = executor.GetCurrentBrowser(&browser_wrapper);38if (status_code != WD_SUCCESS) {39response->SetErrorResponse(status_code, "Unable to get current browser");40return;41}42ParametersMap::const_iterator actions_parameter_iterator = command_parameters.find("actions");43if (actions_parameter_iterator == command_parameters.end()) {44response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: actions");45return;46}47if (!actions_parameter_iterator->second.isArray()) {48response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Actions value is not an array");49return;50}51std::string error_info = "";52status_code = executor.input_manager()->PerformInputSequence(browser_wrapper,53actions_parameter_iterator->second,54&error_info);55if (status_code != WD_SUCCESS) {56if (status_code == EMOVETARGETOUTOFBOUNDS) {57response->SetErrorResponse(status_code, error_info);58} else {59response->SetErrorResponse(status_code, "Unexpected error performing action sequence.");60}61return;62}63response->SetSuccessResponse(Json::Value::null);64}6566} // namespace webdriver676869