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

Method GetDialogButton

cpp/iedriver/Alert.cpp:432–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432Alert::DialogButtonInfo Alert::GetDialogButton(BUTTON_TYPE button_type) {
433 LOG(TRACE) << "Entering Alert::GetDialogButton";
434 // Return the simple version of the struct so that subclasses do not
435 // have to know anything about the function pointer definition.
436 DialogButtonInfo button_info;
437 if (this->is_standard_alert_ || !this->is_security_alert_) {
438 DialogButtonFindInfo button_find_info;
439 button_find_info.button_handle = NULL;
440 button_find_info.button_control_id = this->is_standard_alert_ ? IDOK : INVALID_CONTROL_ID;
441 if (button_type == OK) {
442 button_find_info.match_proc = &Alert::IsOKButton;
443 } else {
444 button_find_info.match_proc = &Alert::IsCancelButton;
445 }
446
447 int max_wait = 10;
448 // Retry up to 10 times to find the dialog.
449 while ((button_find_info.button_handle == NULL) && --max_wait) {
450 ::EnumChildWindows(this->alert_handle_,
451 &Alert::FindDialogButton,
452 reinterpret_cast<LPARAM>(&button_find_info));
453 if (button_find_info.button_handle == NULL) {
454 ::Sleep(50);
455 } else {
456 break;
457 }
458 }
459 button_info.button_handle = button_find_info.button_handle;
460 button_info.button_control_id = button_find_info.button_control_id;
461 button_info.button_exists = button_find_info.button_handle != NULL;
462 button_info.accessibility_id = "";
463 button_info.use_accessibility = false;
464 } else {
465 button_info.button_handle = NULL;
466 button_info.button_control_id = 0;
467 button_info.button_exists = true;
468 button_info.accessibility_id = button_type == OK ? "OKButton" : "CancelButton";
469 button_info.use_accessibility = true;
470 }
471
472 return button_info;
473}
474
475int Alert::ClickAlertButtonUsingAccessibility(const std::string& automation_id) {
476 CComPtr<IUIAutomation> ui_automation;

Callers 3

AlertMethod · 0.95
AcceptMethod · 0.95
DismissMethod · 0.95

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected