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

Method SendKeysInternal

cpp/iedriver/Alert.cpp:149–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149int Alert::SendKeysInternal(const std::string& keys,
150 TextBoxFindInfo* text_box_find_info) {
151 LOG(TRACE) << "Entering Alert::SendKeysInternal";
152 if (!this->is_standard_alert_) {
153 return EUNSUPPORTEDOPERATION;
154 }
155 // Alert present, find the text box.
156 // Retry up to 10 times to find the dialog.
157 int max_wait = 10;
158 while ((text_box_find_info->textbox_handle == NULL) && --max_wait) {
159 ::EnumChildWindows(this->alert_handle_,
160 &Alert::FindTextBox,
161 reinterpret_cast<LPARAM>(text_box_find_info));
162 if (text_box_find_info->textbox_handle == NULL) {
163 ::Sleep(50);
164 }
165 }
166
167 if (text_box_find_info->textbox_handle == NULL) {
168 LOG(WARN) << "Text box not found on alert";
169 return EELEMENTNOTDISPLAYED;
170 } else {
171 LOG(DEBUG) << "Sending keystrokes to alert using SendMessage";
172 std::wstring text = StringUtilities::ToWString(keys);
173 ::SendMessage(text_box_find_info->textbox_handle,
174 WM_SETTEXT,
175 NULL,
176 reinterpret_cast<LPARAM>(text.c_str()));
177 }
178 return WD_SUCCESS;
179}
180
181std::string Alert::GetText() {
182 LOG(TRACE) << "Entering Alert::GetText";

Callers 2

SendKeysMethod · 0.95
SetPasswordMethod · 0.95

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected