MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / WaitForPollingScript

Method WaitForPollingScript

cpp/iedriver/AsyncScriptExecutor.cpp:381–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381bool AsyncScriptExecutor::WaitForPollingScript(void) {
382 LOG(TRACE) << "Entering AsyncScriptExecutor::WaitForPollingScript";
383 Script polling_script(this->script_host_, this->polling_script_source_code_, 0);
384 while (this->is_listener_attached_ && this->status_code_ == WD_SUCCESS) {
385 int polling_status_code = polling_script.Execute();
386 if (polling_status_code != WD_SUCCESS) {
387 this->status_code_ = EUNEXPECTEDJSERROR;
388 this->script_result_ = "Page reload detected during async script";
389 } else {
390 Json::Value polling_script_result;
391 polling_script.ConvertResultToJsonValue(this, &polling_script_result);
392 if (!polling_script_result.isObject()) {
393 this->status_code_ = EUNEXPECTEDJSERROR;
394 this->script_result_ = "Polling script did not return expected object";
395 }
396 if (!polling_script_result.isMember("status")) {
397 this->status_code_ = EUNEXPECTEDJSERROR;
398 this->script_result_ = "Polling script did not return expected object";
399 }
400 std::string polling_script_status = polling_script_result["status"].asString();
401 if (polling_script_status == "reload") {
402 this->status_code_ = EUNEXPECTEDJSERROR;
403 this->script_result_ = "Page reload detected during async script";
404 }
405 if (polling_script_status == "timeout") {
406 this->status_code_ = ESCRIPTTIMEOUT;
407 this->script_result_ = "Timeout expired waiting for async script";
408 }
409 if (polling_script_status == "complete") {
410 this->status_code_ = WD_SUCCESS;
411 this->script_result_ = polling_script_result["value"];
412 break;
413 }
414 }
415 }
416 return this->status_code_ == WD_SUCCESS;
417}
418
419unsigned int WINAPI AsyncScriptExecutor::ThreadProc(LPVOID lpParameter) {
420 LOG(TRACE) << "Entering AsyncScriptExecutor::ThreadProc";

Callers 1

OnExecuteScriptMethod · 0.95

Calls 4

asStringMethod · 0.80
LOGClass · 0.50
ExecuteMethod · 0.45

Tested by

no test coverage detected