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

Method Wait

cpp/iedriver/Browser.cpp:583–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583bool Browser::Wait(const std::string& page_load_strategy) {
584 LOG(TRACE) << "Entering Browser::Wait";
585
586 if (page_load_strategy == NONE_PAGE_LOAD_STRATEGY) {
587 LOG(DEBUG) << "Page load strategy is 'none'. Aborting wait.";
588 this->set_wait_required(false);
589 return true;
590 }
591
592 if (this->is_awaiting_new_process()) {
593 return false;
594 }
595
596 bool is_navigating = true;
597
598 LOG(DEBUG) << "Navigate Events Completed.";
599 this->is_navigation_started_ = false;
600
601 HWND dialog = this->GetActiveDialogWindowHandle();
602 if (dialog != NULL) {
603 LOG(DEBUG) << "Found alert. Aborting wait.";
604 this->set_wait_required(false);
605 return true;
606 }
607
608 // Navigate events completed. Waiting for browser.Busy != false...
609 is_navigating = this->is_navigation_started_;
610 if (is_navigating || (page_load_strategy == NORMAL_PAGE_LOAD_STRATEGY && this->IsBusy())) {
611 if (is_navigating) {
612 LOG(DEBUG) << "DocumentComplete event fired, indicating a new navigation.";
613 } else {
614 LOG(DEBUG) << "Browser busy property is true.";
615 }
616 return false;
617 }
618
619 READYSTATE expected_ready_state = READYSTATE_COMPLETE;
620 if (page_load_strategy == EAGER_PAGE_LOAD_STRATEGY) {
621 expected_ready_state = READYSTATE_INTERACTIVE;
622 }
623
624 // Waiting for browser.ReadyState >= expected ready state
625 is_navigating = this->is_navigation_started_;
626 READYSTATE ready_state;
627 HRESULT hr = this->browser_->get_ReadyState(&ready_state);
628 if (is_navigating || FAILED(hr) || ready_state < expected_ready_state) {
629 if (is_navigating) {
630 LOG(DEBUG) << "DocumentComplete event fired, indicating a new navigation.";
631 } else if (FAILED(hr)) {
632 LOGHR(DEBUG, hr) << "IWebBrowser2::get_ReadyState failed.";
633 } else {
634 LOG(DEBUG) << "Browser ReadyState is not at least '" << expected_ready_state << "'; it was " << ready_state;
635 }
636 return false;
637 }
638
639 // Waiting for document property != null...
640 is_navigating = this->is_navigation_started_;

Callers 3

OnWaitMethod · 0.45
OnAfterNewWindowMethod · 0.45
OpenNewBrowserTabMethod · 0.45

Calls 6

IsBusyMethod · 0.95
IsDocumentNavigatingMethod · 0.95
set_wait_requiredMethod · 0.80
LOGClass · 0.50

Tested by

no test coverage detected