本文整理汇总了C++中ParametersMap::end方法的典型用法代码示例。如果您正苦于以下问题:C++ ParametersMap::end方法的具体用法?C++ ParametersMap::end怎么用?C++ ParametersMap::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParametersMap
的用法示例。
在下文中一共展示了ParametersMap::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteInternal
void SetTimeoutCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator type_parameter_iterator = command_parameters.find("type");
ParametersMap::const_iterator ms_parameter_iterator = command_parameters.find("ms");
if (type_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter: type");
return;
} else if (ms_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter: ms");
return;
} else {
std::string timeout_type = type_parameter_iterator->second.asString();
int timeout = ms_parameter_iterator->second.asInt();
IECommandExecutor& mutable_executor = const_cast<IECommandExecutor&>(executor);
if (timeout_type == "implicit") {
mutable_executor.set_implicit_wait_timeout(timeout);
} else if (timeout_type == "script") {
mutable_executor.set_async_script_timeout(timeout);
} else if (timeout_type == "page load") {
mutable_executor.set_page_load_timeout(timeout);
} else {
response->SetErrorResponse(EUNHANDLEDERROR, "Invalid timeout type specified: " + timeout_type);
return;
}
response->SetSuccessResponse(Json::Value::null);
}
}
示例2: ExecuteInternal
void GetElementPropertyCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("id");
ParametersMap::const_iterator name_parameter_iterator = command_parameters.find("name");
if (id_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: id");
return;
} else if (name_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: name");
return;
} else {
std::string element_id = id_parameter_iterator->second.asString();
std::string name = name_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to get browser");
return;
}
ElementHandle element_wrapper;
status_code = this->GetElement(executor, element_id, &element_wrapper);
if (status_code == WD_SUCCESS) {
std::string value = "";
bool is_null;
status_code = element_wrapper->GetPropertyValue(name,
&value,
&is_null);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get property");
return;
} else {
if (is_null) {
response->SetSuccessResponse(Json::Value::null);
return;
} else {
response->SetSuccessResponse(value);
return;
}
}
} else {
response->SetErrorResponse(ERROR_STALE_ELEMENT_REFERENCE, "Element is no longer valid");
return;
}
}
}
示例3: ExecuteInternal
void SetWindowPositionCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("windowHandle");
ParametersMap::const_iterator x_parameter_iterator = command_parameters.find("x");
ParametersMap::const_iterator y_parameter_iterator = command_parameters.find("y");
if (id_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter in URL: windowHandle");
return;
} else if (x_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter: x");
return;
} else if (y_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(400, "Missing parameter: y");
return;
} else {
int status_code = WD_SUCCESS;
int x = x_parameter_iterator->second.asInt();
int y = y_parameter_iterator->second.asInt();
std::string window_id = id_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
if (window_id == "current") {
status_code = executor.GetCurrentBrowser(&browser_wrapper);
} else {
status_code = executor.GetManagedBrowser(window_id, &browser_wrapper);
}
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Error retrieving window with handle " + window_id);
return;
}
HWND window_handle = browser_wrapper->GetTopLevelWindowHandle();
POINT desired_location;
desired_location.x = x;
desired_location.y = y;
BOOL set_window_pos_result = ::SetWindowPos(window_handle, NULL, desired_location.x, desired_location.y, 0, 0, SWP_NOSIZE);
if (!set_window_pos_result) {
response->SetErrorResponse(EUNHANDLEDERROR,
"Unexpected error setting window size (SetWindowPos API failed)");
return;
}
response->SetSuccessResponse(Json::Value::null);
}
}
示例4: ExecuteInternal
void ActionsCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get current browser");
return;
}
ParametersMap::const_iterator actions_parameter_iterator = command_parameters.find("actions");
if (actions_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: actions");
return;
}
if (!actions_parameter_iterator->second.isArray()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Actions value is not an array");
return;
}
std::string error_info = "";
status_code = executor.input_manager()->PerformInputSequence(browser_wrapper,
actions_parameter_iterator->second,
&error_info);
if (status_code != WD_SUCCESS) {
if (status_code == EMOVETARGETOUTOFBOUNDS) {
response->SetErrorResponse(status_code, error_info);
} else {
response->SetErrorResponse(status_code, "Unexpected error performing action sequence.");
}
return;
}
response->SetSuccessResponse(Json::Value::null);
}
示例5: ExecuteInternal
void DeleteCookieCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator name_parameter_iterator = command_parameters.find("name");
if (name_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: name");
return;
}
std::string cookie_name = name_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get browser");
return;
}
BrowserCookie cookie;
cookie.set_name(cookie_name);
browser_wrapper->cookie_manager()->DeleteCookie(
browser_wrapper->GetCurrentUrl(),
cookie);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to delete cookie");
return;
}
response->SetSuccessResponse(Json::Value::null);
}
示例6: ExecuteInternal
void IsElementSelectedCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("id");
if (id_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: id");
return;
} else {
std::string element_id = id_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to get browser");
return;
}
ElementHandle element_wrapper;
status_code = this->GetElement(executor, element_id, &element_wrapper);
if (status_code == WD_SUCCESS) {
bool is_selected = element_wrapper->IsSelected();
response->SetSuccessResponse(is_selected);
} else {
response->SetErrorResponse(ERROR_STALE_ELEMENT_REFERENCE, "Element is no longer valid");
return;
}
}
}
示例7: parseParameters
void BayesFilter::parseParameters(const ParametersMap & parameters)
{
ParametersMap::const_iterator iter;
if((iter=parameters.find(Parameters::kBayesVirtualPlacePriorThr())) != parameters.end())
{
this->setVirtualPlacePrior(std::atof((*iter).second.c_str()));
}
if((iter=parameters.find(Parameters::kBayesPredictionLC())) != parameters.end())
{
this->setPredictionLC((*iter).second);
}
if((iter=parameters.find(Parameters::kBayesFullPredictionUpdate())) != parameters.end())
{
_fullPredictionUpdate = uStr2Bool((*iter).second.c_str());
}
}
示例8: RecreateJsonParameterObject
Json::Value IECommandHandler::RecreateJsonParameterObject(const ParametersMap& command_parameters) {
Json::Value result;
ParametersMap::const_iterator param_iterator = command_parameters.begin();
for (; param_iterator != command_parameters.end(); ++param_iterator) {
std::string key = param_iterator->first;
Json::Value value = param_iterator->second;
result[key] = value;
}
return result;
}
示例9: ExecuteInternal
void GetElementTextCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator id_parameter_iterator = command_parameters.find("id");
if (id_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter in URL: id");
return;
} else {
std::string element_id = id_parameter_iterator->second.asString();
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get browser");
return;
}
ElementHandle element_wrapper;
status_code = this->GetElement(executor, element_id, &element_wrapper);
if (status_code == WD_SUCCESS) {
// The atom is just the definition of an anonymous
// function: "function() {...}"; Wrap it in another function so
// we can invoke it with our arguments without polluting the
// current namespace.
std::wstring script_source = L"(function() { return (";
script_source += atoms::asString(atoms::GET_TEXT);
script_source += L")})();";
CComPtr<IHTMLDocument2> doc;
browser_wrapper->GetDocument(&doc);
Script script_wrapper(doc, script_source, 1);
script_wrapper.AddArgument(element_wrapper->element());
status_code = script_wrapper.Execute();
if (status_code == WD_SUCCESS) {
std::string text = "";
bool is_null = script_wrapper.ConvertResultToString(&text);
response->SetSuccessResponse(text);
return;
} else {
response->SetErrorResponse(status_code,
"Unable to get element text");
return;
}
} else {
response->SetErrorResponse(ERROR_STALE_ELEMENT_REFERENCE, "Element is no longer valid");
return;
}
}
}
示例10: parseParameters
void Camera::parseParameters(const ParametersMap & parameters)
{
UDEBUG("");
ParametersMap::const_iterator iter;
//Keypoint detector
KeypointDetector::DetectorType detector = KeypointDetector::kDetectorUndef;
if((iter=parameters.find(Parameters::kKpDetectorStrategy())) != parameters.end())
{
detector = (KeypointDetector::DetectorType)std::atoi((*iter).second.c_str());
}
if(detector!=KeypointDetector::kDetectorUndef)
{
ULOGGER_DEBUG("new detector strategy %d", int(detector));
if(_keypointDetector)
{
delete _keypointDetector;
_keypointDetector = 0;
}
if(_keypointDescriptor)
{
delete _keypointDescriptor;
_keypointDescriptor = 0;
}
switch(detector)
{
case KeypointDetector::kDetectorSift:
_keypointDetector = new SIFTDetector(parameters);
_keypointDescriptor = new SIFTDescriptor(parameters);
break;
case KeypointDetector::kDetectorSurf:
default:
_keypointDetector = new SURFDetector(parameters);
_keypointDescriptor = new SURFDescriptor(parameters);
break;
}
}
else
{
if(_keypointDetector)
{
_keypointDetector->parseParameters(parameters);
}
if(_keypointDescriptor)
{
_keypointDescriptor->parseParameters(parameters);
}
}
}
示例11: GetNumericParameter
bool SetWindowRectCommandHandler::GetNumericParameter(
const ParametersMap& command_parameters,
const std::string& argument_name,
int* argument_value,
std::string* error_message) {
ParametersMap::const_iterator parameter_iterator = command_parameters.find(argument_name);
if (parameter_iterator != command_parameters.end()) {
if (!parameter_iterator->second.isNumeric()) {
*error_message = argument_name + " must be a numeric parameter.";
return false;
}
int value = parameter_iterator->second.asInt();
if (value < 0) {
*error_message = argument_name + " must be a numeric parameter greater than zero.";
return false;
}
*argument_value = value;
return true;
}
return true;
}
示例12: setupUi
void ParametersToolBox::setupUi(const ParametersMap & parameters)
{
parameters_ = parameters;
QWidget * currentItem = 0;
QStringList groups;
for(ParametersMap::const_iterator iter=parameters.begin();
iter!=parameters.end();
++iter)
{
QStringList splitted = QString::fromStdString(iter->first).split('/');
QString group = splitted.first();
QString name = splitted.last();
if(currentItem == 0 || currentItem->objectName().compare(group) != 0)
{
groups.push_back(group);
QScrollArea * area = new QScrollArea(this);
stackedWidget_->addWidget(area);
currentItem = new QWidget();
currentItem->setObjectName(group);
QVBoxLayout * layout = new QVBoxLayout(currentItem);
layout->setSizeConstraint(QLayout::SetMinimumSize);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
area->setWidget(currentItem);
addParameter(layout, iter->first, iter->second);
}
else
{
addParameter((QVBoxLayout*)currentItem->layout(), iter->first, iter->second);
}
}
comboBox_->addItems(groups);
connect(comboBox_, SIGNAL(currentIndexChanged(int)), stackedWidget_, SLOT(setCurrentIndex(int)));
updateParametersVisibility();
}
示例13: ExecuteInternal
void ExecuteAsyncScriptCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator script_parameter_iterator = command_parameters.find("script");
ParametersMap::const_iterator args_parameter_iterator = command_parameters.find("args");
if (script_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: script");
return;
} else if (args_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: args");
return;
} else {
wchar_t page_id_buffer[GUID_STRING_LEN] = {0};
GUID page_id_guid;
::CoCreateGuid(&page_id_guid);
::StringFromGUID2(page_id_guid, page_id_buffer, GUID_STRING_LEN);
std::wstring page_id = &page_id_buffer[0];
wchar_t pending_id_buffer[GUID_STRING_LEN] = {0};
GUID pending_id_guid;
::CoCreateGuid(&pending_id_guid);
::StringFromGUID2(pending_id_guid, pending_id_buffer, GUID_STRING_LEN);
std::wstring pending_id = &pending_id_buffer[0];
Json::Value json_args = args_parameter_iterator->second;
int timeout_value = executor.async_script_timeout();
std::wstring timeout = std::to_wstring(static_cast<long long>(timeout_value));
std::wstring script_body = StringUtilities::ToWString(script_parameter_iterator->second.asString());
std::wstring async_script = L"(function() { return function(){\n";
async_script += L"document.__$webdriverAsyncExecutor = {\n";
async_script += L" pageId: '" + page_id + L"',\n";
async_script += L" asyncTimeout: 0\n";
async_script += L"};\n";
async_script += L"var timeoutId = window.setTimeout(function() {\n";
async_script += L" window.setTimeout(function() {\n";
async_script += L" document.__$webdriverAsyncExecutor.asyncTimeout = 1;\n";
async_script += L" }, 0);\n";
async_script += L"}," + timeout + L");\n";
async_script += L"var callback = function(value) {\n";
async_script += L" document.__$webdriverAsyncExecutor.asyncTimeout = 0;\n";
async_script += L" document.__$webdriverAsyncExecutor.asyncScriptResult = value;\n";
async_script += L" window.clearTimeout(timeoutId);\n";
async_script += L"};\n";
async_script += L"var argsArray = Array.prototype.slice.call(arguments);\n";
async_script += L"argsArray.push(callback);\n";
async_script += L"if (document.__$webdriverAsyncExecutor.asyncScriptResult !== undefined) {\n";
async_script += L" delete document.__$webdriverAsyncExecutor.asyncScriptResult;\n";
async_script += L"}\n";
async_script += L"(function() {" + script_body + L"}).apply(null, argsArray);\n";
async_script += L"};})();";
std::wstring polling_script = L"(function() { return function(){\n";
polling_script += L"var pendingId = '" + pending_id + L"';\n";
polling_script += L"if ('__$webdriverAsyncExecutor' in document) {\n";
polling_script += L" if (document.__$webdriverAsyncExecutor.pageId != '" + page_id + L"') {\n";
polling_script += L" return [pendingId, -1];\n";
polling_script += L" } else if ('asyncScriptResult' in document.__$webdriverAsyncExecutor) {\n";
polling_script += L" var value = document.__$webdriverAsyncExecutor.asyncScriptResult;\n";
polling_script += L" delete document.__$webdriverAsyncExecutor.asyncScriptResult;\n";
polling_script += L" return value;\n";
polling_script += L" } else {\n";
polling_script += L" return [pendingId, document.__$webdriverAsyncExecutor.asyncTimeout];\n";
polling_script += L" }\n";
polling_script += L"} else {\n";
polling_script += L" return [pendingId, -1];\n";
polling_script += L"}\n";
polling_script += L"};})();";
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get browser");
return;
}
CComPtr<IHTMLDocument2> doc;
browser_wrapper->GetDocument(&doc);
Script async_script_wrapper(doc, async_script, json_args.size());
status_code = this->PopulateArgumentArray(executor,
async_script_wrapper,
json_args);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code,
"Error setting arguments for script");
return;
}
status_code = async_script_wrapper.Execute();
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code,
"JavaScript error in async script.");
return;
} else {
Script polling_script_wrapper(doc, polling_script, 0);
while (true) {
//.........这里部分代码省略.........
示例14: ExecuteInternal
void FindElementCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator using_parameter_iterator = command_parameters.find("using");
ParametersMap::const_iterator value_parameter_iterator = command_parameters.find("value");
if (using_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: using");
return;
}
if (!using_parameter_iterator->second.isString()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "using parameter must be a string");
return;
}
if (value_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Missing parameter: value");
return;
}
if (!value_parameter_iterator->second.isString()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "value parameter must be a string");
return;
}
std::string mechanism = using_parameter_iterator->second.asString();
std::string value = value_parameter_iterator->second.asString();
if (mechanism != "css selector" &&
mechanism != "tag name" &&
mechanism != "link text" &&
mechanism != "partial link text" &&
mechanism != "xpath") {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "using parameter value '" + mechanism + "' is not a valid value");
return;
}
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Currently focused window has been closed.");
return;
}
int timeout = static_cast<int>(executor.implicit_wait_timeout());
clock_t end = clock() + (timeout / 1000 * CLOCKS_PER_SEC);
if (timeout > 0 && timeout < 1000) {
end += 1 * CLOCKS_PER_SEC;
}
status_code = WD_SUCCESS;
Json::Value found_element;
do {
status_code = executor.LocateElement(ElementHandle(),
mechanism,
value,
&found_element);
if (status_code == WD_SUCCESS) {
response->SetSuccessResponse(found_element);
return;
}
if (status_code == ENOSUCHWINDOW) {
response->SetErrorResponse(ERROR_NO_SUCH_WINDOW, "Unable to find element on closed window");
return;
}
if (status_code != ENOSUCHELEMENT) {
response->SetErrorResponse(status_code, found_element.asString());
return;
}
// Release the thread so that the browser doesn't starve.
::Sleep(FIND_ELEMENT_WAIT_TIME_IN_MILLISECONDS);
} while (clock() < end);
response->SetErrorResponse(ERROR_NO_SUCH_ELEMENT,
"Unable to find element with " + mechanism + " == " + value);
return;
}
示例15: ExecuteInternal
void ExecuteAsyncScriptCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
ParametersMap::const_iterator script_parameter_iterator = command_parameters.find("script");
ParametersMap::const_iterator args_parameter_iterator = command_parameters.find("args");
if (script_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
"Missing parameter: script");
return;
}
if (!script_parameter_iterator->second.isString()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
"script parameter must be a string");
return;
}
if (args_parameter_iterator == command_parameters.end()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
"Missing parameter: args");
return;
}
if (!args_parameter_iterator->second.isArray()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT,
"args parameter must be an array");
return;
}
std::vector<wchar_t> page_id_buffer(GUID_STRING_LEN);
GUID page_id_guid;
::CoCreateGuid(&page_id_guid);
::StringFromGUID2(page_id_guid, &page_id_buffer[0], GUID_STRING_LEN);
std::wstring page_id = &page_id_buffer[0];
std::vector<wchar_t> pending_id_buffer(GUID_STRING_LEN);
GUID pending_id_guid;
::CoCreateGuid(&pending_id_guid);
::StringFromGUID2(pending_id_guid, &pending_id_buffer[0], GUID_STRING_LEN);
std::wstring pending_id = &pending_id_buffer[0];
Json::Value json_args = args_parameter_iterator->second;
unsigned long long timeout_value = executor.async_script_timeout();
std::wstring timeout = std::to_wstring(static_cast<long long>(timeout_value));
std::wstring script_body = StringUtilities::ToWString(script_parameter_iterator->second.asString());
std::wstring async_script = L"(function() { return function(){\n";
async_script += L"document.__$webdriverAsyncExecutor = {\n";
async_script += L" pageId: '" + page_id + L"',\n";
async_script += L" asyncTimeout: 0\n";
async_script += L"};\n";
async_script += L"var timeoutId = window.setTimeout(function() {\n";
async_script += L" window.setTimeout(function() {\n";
async_script += L" document.__$webdriverAsyncExecutor.asyncTimeout = 1;\n";
async_script += L" }, 0);\n";
async_script += L"}," + timeout + L");\n";
async_script += L"var callback = function(value) {\n";
async_script += L" document.__$webdriverAsyncExecutor.asyncTimeout = 0;\n";
async_script += L" document.__$webdriverAsyncExecutor.asyncScriptResult = value;\n";
async_script += L" window.clearTimeout(timeoutId);\n";
async_script += L"};\n";
async_script += L"var argsArray = Array.prototype.slice.call(arguments);\n";
async_script += L"argsArray.push(callback);\n";
async_script += L"if (document.__$webdriverAsyncExecutor.asyncScriptResult !== undefined) {\n";
async_script += L" delete document.__$webdriverAsyncExecutor.asyncScriptResult;\n";
async_script += L"}\n";
async_script += L"(function() {\n" + script_body + L"\n}).apply(null, argsArray);\n";
async_script += L"};})();";
std::wstring polling_script = L"(function() { return function(){\n";
polling_script += L"var pendingId = '" + pending_id + L"';\n";
polling_script += L"if ('__$webdriverAsyncExecutor' in document) {\n";
polling_script += L" if (document.__$webdriverAsyncExecutor.pageId != '" + page_id + L"') {\n";
polling_script += L" return {'status': 'reload', 'id': pendingId, 'value': -1};\n";
polling_script += L" } else if ('asyncScriptResult' in document.__$webdriverAsyncExecutor) {\n";
polling_script += L" var value = document.__$webdriverAsyncExecutor.asyncScriptResult;\n";
polling_script += L" delete document.__$webdriverAsyncExecutor.asyncScriptResult;\n";
polling_script += L" return {'status': 'complete', 'id': pendingId, 'value': value};\n";
polling_script += L" } else if (document.__$webdriverAsyncExecutor.asyncTimeout == 0) {\n";
polling_script += L" return {'status': 'pending', 'id': pendingId, 'value': document.__$webdriverAsyncExecutor.asyncTimeout};\n";
polling_script += L" } else {\n";
polling_script += L" return {'status': 'timeout', 'id': pendingId, 'value': document.__$webdriverAsyncExecutor.asyncTimeout};\n";
polling_script += L" }\n";
polling_script += L"} else {\n";
polling_script += L" return {'status': 'reload', 'id': pendingId, 'value': -1};\n";
polling_script += L"}\n";
polling_script += L"};})();";
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get browser");
return;
}
CComPtr<IHTMLDocument2> doc;
browser_wrapper->GetDocument(&doc);
//.........这里部分代码省略.........