"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/cpp/iedriver/Alert.h" (17 Feb 2023, 3444 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "Alert.h" see the
Fossies "Dox" file reference documentation.
1 // Licensed to the Software Freedom Conservancy (SFC) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The SFC licenses this file
5 // to you under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16
17 #ifndef WEBDRIVER_ALERT_H_
18 #define WEBDRIVER_ALERT_H_
19
20 #include <memory>
21 #include <string>
22 #include <vector>
23
24 namespace webdriver {
25
26 // Forward declaration of classes.
27 class DocumentHost;
28
29 class Alert {
30 public:
31 Alert(std::shared_ptr<DocumentHost> browser, HWND handle);
32 virtual ~Alert(void);
33
34 int Accept(void);
35 int Dismiss(void);
36 int SendKeys(const std::string& keys);
37 std::string GetText(void);
38 int SetUserName(const std::string& username);
39 int SetPassword(const std::string& password);
40
41 bool is_standard_alert(void) const { return this->is_standard_alert_; }
42 bool is_security_alert(void) const { return this->is_security_alert_; }
43
44 private:
45 typedef bool (__cdecl *ISBUTTONMATCHPROC)(HWND);
46 typedef bool (__cdecl *ISEDITMATCHPROC)(HWND);
47
48 struct DialogButtonInfo {
49 HWND button_handle;
50 int button_control_id;
51 bool button_exists;
52 std::string accessibility_id;
53 bool use_accessibility;
54 };
55
56 struct DialogButtonFindInfo {
57 HWND button_handle;
58 int button_control_id;
59 ISBUTTONMATCHPROC match_proc;
60 };
61
62 struct TextLabelFindInfo {
63 HWND label_handle;
64 int control_id_found;
65 int excluded_control_id;
66 };
67
68 struct TextBoxFindInfo {
69 HWND textbox_handle;
70 ISEDITMATCHPROC match_proc;
71 };
72
73 enum BUTTON_TYPE {
74 OK,
75 CANCEL
76 };
77
78 int SendKeysInternal(const std::string& keys,
79 TextBoxFindInfo* text_box_find_info);
80
81 DialogButtonInfo GetDialogButton(BUTTON_TYPE button_type);
82 int ClickAlertButton(DialogButtonInfo button_info);
83 int ClickAlertButtonUsingAccessibility(const std::string& automation_id);
84 std::string GetStandardDialogText(void);
85 std::string GetDirectUIDialogText(void);
86 HWND GetDirectUIChild(void);
87 IAccessible* GetChildWithRole(IAccessible* parent,
88 long expected_role,
89 int index);
90
91 static bool IsOKButton(HWND button_handle);
92 static bool IsCancelButton(HWND button_handle);
93 static bool IsLinkButton(HWND button_handle);
94 static bool IsSimpleEdit(HWND edit_handle);
95 static bool IsPasswordEdit(HWND edit_handle);
96 static BOOL CALLBACK FindDialogButton(HWND hwnd, LPARAM arg);
97 static BOOL CALLBACK FindTextBox(HWND hwnd, LPARAM arg);
98 static BOOL CALLBACK FindTextLabel(HWND hwnd, LPARAM arg);
99 static BOOL CALLBACK FindDirectUIChild(HWND hwnd, LPARAM arg);
100 static BOOL CALLBACK FindTextBoxes(HWND hwnd, LPARAM arg);
101
102 HWND alert_handle_;
103 std::shared_ptr<DocumentHost> browser_;
104 bool is_standard_alert_;
105 bool is_security_alert_;
106 bool is_standard_control_alert_;
107 };
108
109
110 } // namespace webdriver
111
112 #endif // WEBDRIVER_IE_BROWSER_H_