@redhat-developer/page-objects 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +5 -0
  3. package/out/components/AbstractElement.d.ts +35 -0
  4. package/out/components/AbstractElement.js +69 -0
  5. package/out/components/ElementWithContextMenu.d.ts +11 -0
  6. package/out/components/ElementWithContextMenu.js +38 -0
  7. package/out/components/WebviewMixin.d.ts +29 -0
  8. package/out/components/WebviewMixin.js +70 -0
  9. package/out/components/activityBar/ActionsControl.d.ts +18 -0
  10. package/out/components/activityBar/ActionsControl.js +27 -0
  11. package/out/components/activityBar/ActivityBar.d.ts +30 -0
  12. package/out/components/activityBar/ActivityBar.js +71 -0
  13. package/out/components/activityBar/ViewControl.d.ts +23 -0
  14. package/out/components/activityBar/ViewControl.js +56 -0
  15. package/out/components/bottomBar/AbstractViews.d.ts +38 -0
  16. package/out/components/bottomBar/AbstractViews.js +88 -0
  17. package/out/components/bottomBar/BottomBarPanel.d.ts +47 -0
  18. package/out/components/bottomBar/BottomBarPanel.js +123 -0
  19. package/out/components/bottomBar/ProblemsView.d.ts +88 -0
  20. package/out/components/bottomBar/ProblemsView.js +149 -0
  21. package/out/components/bottomBar/Views.d.ts +75 -0
  22. package/out/components/bottomBar/Views.js +195 -0
  23. package/out/components/bottomBar/WebviewView.d.ts +12 -0
  24. package/out/components/bottomBar/WebviewView.js +21 -0
  25. package/out/components/dialog/ModalDialog.d.ts +32 -0
  26. package/out/components/dialog/ModalDialog.js +56 -0
  27. package/out/components/editor/Breakpoint.d.ts +18 -0
  28. package/out/components/editor/Breakpoint.js +38 -0
  29. package/out/components/editor/ContentAssist.d.ts +34 -0
  30. package/out/components/editor/ContentAssist.js +94 -0
  31. package/out/components/editor/CustomEditor.d.ts +26 -0
  32. package/out/components/editor/CustomEditor.js +45 -0
  33. package/out/components/editor/DiffEditor.d.ts +19 -0
  34. package/out/components/editor/DiffEditor.js +31 -0
  35. package/out/components/editor/Editor.d.ts +17 -0
  36. package/out/components/editor/Editor.js +29 -0
  37. package/out/components/editor/EditorAction.d.ts +10 -0
  38. package/out/components/editor/EditorAction.js +17 -0
  39. package/out/components/editor/EditorView.d.ts +153 -0
  40. package/out/components/editor/EditorView.js +350 -0
  41. package/out/components/editor/SettingsEditor.d.ts +121 -0
  42. package/out/components/editor/SettingsEditor.js +278 -0
  43. package/out/components/editor/TextEditor.d.ts +265 -0
  44. package/out/components/editor/TextEditor.js +707 -0
  45. package/out/components/editor/WebView.d.ts +11 -0
  46. package/out/components/editor/WebView.js +38 -0
  47. package/out/components/menu/ContextMenu.d.ts +37 -0
  48. package/out/components/menu/ContextMenu.js +123 -0
  49. package/out/components/menu/MacTitleBar.d.ts +16 -0
  50. package/out/components/menu/MacTitleBar.js +41 -0
  51. package/out/components/menu/Menu.d.ts +38 -0
  52. package/out/components/menu/Menu.js +53 -0
  53. package/out/components/menu/MenuItem.d.ts +24 -0
  54. package/out/components/menu/MenuItem.js +36 -0
  55. package/out/components/menu/TitleBar.d.ts +36 -0
  56. package/out/components/menu/TitleBar.js +78 -0
  57. package/out/components/menu/WindowControls.d.ts +28 -0
  58. package/out/components/menu/WindowControls.js +59 -0
  59. package/out/components/sidebar/SideBarView.d.ts +18 -0
  60. package/out/components/sidebar/SideBarView.js +29 -0
  61. package/out/components/sidebar/ViewContent.d.ts +57 -0
  62. package/out/components/sidebar/ViewContent.js +76 -0
  63. package/out/components/sidebar/ViewItem.d.ts +97 -0
  64. package/out/components/sidebar/ViewItem.js +192 -0
  65. package/out/components/sidebar/ViewSection.d.ts +98 -0
  66. package/out/components/sidebar/ViewSection.js +164 -0
  67. package/out/components/sidebar/ViewTitlePart.d.ts +35 -0
  68. package/out/components/sidebar/ViewTitlePart.js +59 -0
  69. package/out/components/sidebar/WelcomeContent.d.ts +47 -0
  70. package/out/components/sidebar/WelcomeContent.js +72 -0
  71. package/out/components/sidebar/debug/DebugView.d.ts +33 -0
  72. package/out/components/sidebar/debug/DebugView.js +70 -0
  73. package/out/components/sidebar/extensions/ExtensionsViewItem.d.ts +48 -0
  74. package/out/components/sidebar/extensions/ExtensionsViewItem.js +93 -0
  75. package/out/components/sidebar/extensions/ExtensionsViewSection.d.ts +33 -0
  76. package/out/components/sidebar/extensions/ExtensionsViewSection.js +117 -0
  77. package/out/components/sidebar/scm/NewScmView.d.ts +34 -0
  78. package/out/components/sidebar/scm/NewScmView.js +155 -0
  79. package/out/components/sidebar/scm/ScmView.d.ts +110 -0
  80. package/out/components/sidebar/scm/ScmView.js +275 -0
  81. package/out/components/sidebar/tree/TreeSection.d.ts +14 -0
  82. package/out/components/sidebar/tree/TreeSection.js +55 -0
  83. package/out/components/sidebar/tree/custom/CustomTreeItem.d.ts +15 -0
  84. package/out/components/sidebar/tree/custom/CustomTreeItem.js +36 -0
  85. package/out/components/sidebar/tree/custom/CustomTreeSection.d.ts +26 -0
  86. package/out/components/sidebar/tree/custom/CustomTreeSection.js +66 -0
  87. package/out/components/sidebar/tree/debug/BreakpointSectionItem.d.ts +33 -0
  88. package/out/components/sidebar/tree/debug/BreakpointSectionItem.js +63 -0
  89. package/out/components/sidebar/tree/debug/DebugBreakpointSection.d.ts +7 -0
  90. package/out/components/sidebar/tree/debug/DebugBreakpointSection.js +12 -0
  91. package/out/components/sidebar/tree/debug/DebugVariablesSection.d.ts +7 -0
  92. package/out/components/sidebar/tree/debug/DebugVariablesSection.js +12 -0
  93. package/out/components/sidebar/tree/debug/SectionBreakpoint.d.ts +3 -0
  94. package/out/components/sidebar/tree/debug/SectionBreakpoint.js +8 -0
  95. package/out/components/sidebar/tree/debug/VariableSectionItem.d.ts +33 -0
  96. package/out/components/sidebar/tree/debug/VariableSectionItem.js +60 -0
  97. package/out/components/sidebar/tree/default/DefaultTreeItem.d.ts +14 -0
  98. package/out/components/sidebar/tree/default/DefaultTreeItem.js +39 -0
  99. package/out/components/sidebar/tree/default/DefaultTreeSection.d.ts +9 -0
  100. package/out/components/sidebar/tree/default/DefaultTreeSection.js +44 -0
  101. package/out/components/statusBar/StatusBar.d.ts +96 -0
  102. package/out/components/statusBar/StatusBar.js +159 -0
  103. package/out/components/workbench/DebugToolbar.d.ts +52 -0
  104. package/out/components/workbench/DebugToolbar.js +93 -0
  105. package/out/components/workbench/Notification.d.ts +78 -0
  106. package/out/components/workbench/Notification.js +134 -0
  107. package/out/components/workbench/NotificationsCenter.d.ts +27 -0
  108. package/out/components/workbench/NotificationsCenter.js +57 -0
  109. package/out/components/workbench/Workbench.d.ts +69 -0
  110. package/out/components/workbench/Workbench.js +135 -0
  111. package/out/components/workbench/input/Input.d.ts +107 -0
  112. package/out/components/workbench/input/Input.js +249 -0
  113. package/out/components/workbench/input/InputBox.d.ts +30 -0
  114. package/out/components/workbench/input/InputBox.js +75 -0
  115. package/out/components/workbench/input/QuickOpenBox.d.ts +15 -0
  116. package/out/components/workbench/input/QuickOpenBox.js +41 -0
  117. package/out/conditions/WaitForAttribute.d.ts +8 -0
  118. package/out/conditions/WaitForAttribute.js +17 -0
  119. package/out/errors/NullAttributeError.d.ts +3 -0
  120. package/out/errors/NullAttributeError.js +11 -0
  121. package/out/index.d.ts +67 -0
  122. package/out/index.js +95 -0
  123. package/out/locators/loader.d.ts +20 -0
  124. package/out/locators/loader.js +108 -0
  125. package/out/locators/locators.d.ts +463 -0
  126. package/out/locators/locators.js +52 -0
  127. package/package.json +48 -0
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workbench = void 0;
4
+ const AbstractElement_1 = require("../AbstractElement");
5
+ const selenium_webdriver_1 = require("selenium-webdriver");
6
+ const TitleBar_1 = require("../menu/TitleBar");
7
+ const SideBarView_1 = require("../sidebar/SideBarView");
8
+ const ActivityBar_1 = require("../activityBar/ActivityBar");
9
+ const StatusBar_1 = require("../statusBar/StatusBar");
10
+ const EditorView_1 = require("../editor/EditorView");
11
+ const BottomBarPanel_1 = require("../bottomBar/BottomBarPanel");
12
+ const Notification_1 = require("./Notification");
13
+ const QuickOpenBox_1 = require("./input/QuickOpenBox");
14
+ const SettingsEditor_1 = require("../editor/SettingsEditor");
15
+ const InputBox_1 = require("./input/InputBox");
16
+ /**
17
+ * Handler for general workbench related actions
18
+ */
19
+ class Workbench extends AbstractElement_1.AbstractElement {
20
+ constructor() {
21
+ super(Workbench.locators.Workbench.constructor);
22
+ }
23
+ /**
24
+ * Get a title bar handle
25
+ */
26
+ getTitleBar() {
27
+ return new TitleBar_1.TitleBar();
28
+ }
29
+ /**
30
+ * Get a side bar handle
31
+ */
32
+ getSideBar() {
33
+ return new SideBarView_1.SideBarView();
34
+ }
35
+ /**
36
+ * Get an activity bar handle
37
+ */
38
+ getActivityBar() {
39
+ return new ActivityBar_1.ActivityBar();
40
+ }
41
+ /**
42
+ * Get a status bar handle
43
+ */
44
+ getStatusBar() {
45
+ return new StatusBar_1.StatusBar();
46
+ }
47
+ /**
48
+ * Get a bottom bar handle
49
+ */
50
+ getBottomBar() {
51
+ return new BottomBarPanel_1.BottomBarPanel();
52
+ }
53
+ /**
54
+ * Get a handle for the editor view
55
+ */
56
+ getEditorView() {
57
+ return new EditorView_1.EditorView();
58
+ }
59
+ /**
60
+ * Get all standalone notifications (notifications outside the notifications center)
61
+ * @returns Promise resolving to array of Notification objects
62
+ */
63
+ async getNotifications() {
64
+ const notifications = [];
65
+ let container;
66
+ try {
67
+ container = await this.findElement(Workbench.locators.Workbench.notificationContainer);
68
+ }
69
+ catch (err) {
70
+ return [];
71
+ }
72
+ const elements = await container.findElements(Workbench.locators.Workbench.notificationItem);
73
+ for (const element of elements) {
74
+ notifications.push(await new Notification_1.StandaloneNotification(element).wait());
75
+ }
76
+ return notifications;
77
+ }
78
+ /**
79
+ * Opens the notifications center
80
+ * @returns Promise resolving to NotificationsCenter object
81
+ */
82
+ async openNotificationsCenter() {
83
+ return await new StatusBar_1.StatusBar().openNotificationsCenter();
84
+ }
85
+ /**
86
+ * Opens the settings editor
87
+ *
88
+ * @returns promise that resolves to a SettingsEditor instance
89
+ */
90
+ async openSettings() {
91
+ await this.executeCommand('open user settings');
92
+ await new EditorView_1.EditorView().openEditor('Settings');
93
+ await Workbench.driver.wait(selenium_webdriver_1.until.elementLocated(Workbench.locators.Editor.constructor));
94
+ await new Promise((res) => setTimeout(res, 500));
95
+ return new SettingsEditor_1.SettingsEditor();
96
+ }
97
+ /**
98
+ * Open the VS Code command line prompt
99
+ * @returns Promise resolving to InputBox (vscode 1.44+) or QuickOpenBox (vscode up to 1.43) object
100
+ */
101
+ async openCommandPrompt() {
102
+ const webview = await new EditorView_1.EditorView().findElements(EditorView_1.EditorView.locators.EditorView.webView);
103
+ if (webview.length > 0) {
104
+ const tab = await new EditorView_1.EditorView().getActiveTab();
105
+ if (tab) {
106
+ await tab.sendKeys(selenium_webdriver_1.Key.F1);
107
+ return await InputBox_1.InputBox.create();
108
+ }
109
+ }
110
+ const driver = this.getDriver();
111
+ await driver.actions().keyDown(Workbench.ctlKey).keyDown(selenium_webdriver_1.Key.SHIFT).sendKeys('p').perform();
112
+ if (Workbench.versionInfo.version >= '1.44.0') {
113
+ return await InputBox_1.InputBox.create();
114
+ }
115
+ return await QuickOpenBox_1.QuickOpenBox.create();
116
+ }
117
+ /**
118
+ * Open the command prompt, type in a command and execute
119
+ * @param command text of the command to be executed
120
+ * @returns Promise resolving when the command prompt is confirmed
121
+ */
122
+ async executeCommand(command) {
123
+ const prompt = await this.openCommandPrompt();
124
+ await prompt.setText(`>${command}`);
125
+ const quickPicks = await Promise.all((await prompt.getQuickPicks()).map(item => item.getLabel()));
126
+ if (quickPicks.includes(command)) {
127
+ await prompt.selectQuickPick(command);
128
+ }
129
+ else {
130
+ await prompt.confirm();
131
+ }
132
+ }
133
+ }
134
+ exports.Workbench = Workbench;
135
+ //# sourceMappingURL=Workbench.js.map
@@ -0,0 +1,107 @@
1
+ import { AbstractElement } from "../../AbstractElement";
2
+ /**
3
+ * Abstract page object for input fields
4
+ */
5
+ export declare abstract class Input extends AbstractElement {
6
+ /**
7
+ * Get current text of the input field
8
+ * @returns Promise resolving to text of the input field
9
+ */
10
+ getText(): Promise<string>;
11
+ /**
12
+ * Set (by selecting all and typing) text in the input field
13
+ * @param text text to set into the input field
14
+ * @returns Promise resolving when the text is typed in
15
+ */
16
+ setText(text: string): Promise<void>;
17
+ /**
18
+ * Get the placeholder text for the input field
19
+ * @returns Promise resolving to input placeholder
20
+ */
21
+ getPlaceHolder(): Promise<string>;
22
+ /**
23
+ * Confirm the input field by pressing Enter
24
+ * @returns Promise resolving when the input is confirmed
25
+ */
26
+ confirm(): Promise<void>;
27
+ /**
28
+ * Cancel the input field by pressing Escape
29
+ * @returns Promise resolving when the input is cancelled
30
+ */
31
+ cancel(): Promise<void>;
32
+ /**
33
+ * Clear the inpur field
34
+ * @returns Promise resolving when the field is cleared
35
+ */
36
+ clear(): Promise<void>;
37
+ /**
38
+ * Select (click) a quick pick option. Will scroll through the quick picks to find the item.
39
+ * Search for the item can be done by its text, or index in the quick pick menu.
40
+ * Note that scrolling does not affect the item's index, but it will
41
+ * replace some items in the DOM (thus they become unreachable)
42
+ *
43
+ * @param indexOrText index (number) or text (string) of the item to search by
44
+ * @returns Promise resolving when the given quick pick is selected
45
+ */
46
+ selectQuickPick(indexOrText: string | number): Promise<void>;
47
+ /**
48
+ * Select/Deselect all quick picks using the 'select all' checkbox
49
+ * If multiple selection is disabled on the input box, no action is performed
50
+ *
51
+ * @param state true to select all, false to deselect all
52
+ * @returns Promise resolving when all quick picks have been toggled to desired state
53
+ */
54
+ toggleAllQuickPicks(state: boolean): Promise<void>;
55
+ /**
56
+ * Scroll through the quick picks to find an item by the name or index
57
+ * @param indexOrText index (number) or text (string) of the item to search by
58
+ * @returns Promise resolvnig to QuickPickItem if found, to undefined otherwise
59
+ */
60
+ findQuickPick(indexOrText: string | number): Promise<QuickPickItem | undefined>;
61
+ /**
62
+ * Retrieve the title of an input box if it has one
63
+ * @returns Promise resolving to title if it exists, to undefined otherwise
64
+ */
65
+ getTitle(): Promise<string | undefined>;
66
+ /**
67
+ * Click on the back button if it exists
68
+ * @returns Promise resolving to true if a button was clicked, to false otherwise
69
+ */
70
+ back(): Promise<boolean>;
71
+ /**
72
+ * Find whether the input box has an active progress bar
73
+ * @returns Promise resolving to true/false
74
+ */
75
+ abstract hasProgress(): Promise<boolean>;
76
+ /**
77
+ * Retrieve the quick pick items currently available in the DOM
78
+ * (visible in the quick pick menu)
79
+ * @returns Promise resolving to array of QuickPickItem objects
80
+ */
81
+ abstract getQuickPicks(): Promise<QuickPickItem[]>;
82
+ private resetPosition;
83
+ }
84
+ /**
85
+ * Page object representing a quick pick option in the input box
86
+ */
87
+ export declare class QuickPickItem extends AbstractElement {
88
+ private index;
89
+ constructor(index: number, input: Input, isMultiSelect?: boolean);
90
+ /**
91
+ * Get the label of the quick pick item
92
+ */
93
+ getLabel(): Promise<string>;
94
+ /**
95
+ * Get the description of the quick pick item
96
+ */
97
+ getDescription(): Promise<string | undefined>;
98
+ /**
99
+ * Get the index of the quick pick item
100
+ */
101
+ getIndex(): number;
102
+ /**
103
+ * Select (click) the quick pick item
104
+ * @returns Promise resolving when the item has been clicked
105
+ */
106
+ select(): Promise<void>;
107
+ }
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuickPickItem = exports.Input = void 0;
4
+ const AbstractElement_1 = require("../../AbstractElement");
5
+ const selenium_webdriver_1 = require("selenium-webdriver");
6
+ const __1 = require("../../..");
7
+ /**
8
+ * Abstract page object for input fields
9
+ */
10
+ class Input extends AbstractElement_1.AbstractElement {
11
+ /**
12
+ * Get current text of the input field
13
+ * @returns Promise resolving to text of the input field
14
+ */
15
+ async getText() {
16
+ const input = await this.findElement(Input.locators.Input.inputBox)
17
+ .findElement(Input.locators.Input.input);
18
+ return await input.getAttribute('value');
19
+ }
20
+ /**
21
+ * Set (by selecting all and typing) text in the input field
22
+ * @param text text to set into the input field
23
+ * @returns Promise resolving when the text is typed in
24
+ */
25
+ async setText(text) {
26
+ const clipboard = (await import('clipboardy')).default;
27
+ let originalClipboard = '';
28
+ try {
29
+ originalClipboard = clipboard.readSync();
30
+ }
31
+ catch (error) {
32
+ // workaround issue https://github.com/redhat-developer/vscode-extension-tester/issues/835
33
+ // do not fail if clipboard is empty
34
+ }
35
+ const input = await this.findElement(Input.locators.Input.inputBox)
36
+ .findElement(Input.locators.Input.input);
37
+ await this.clear();
38
+ await new Promise(res => setTimeout(res, 200));
39
+ if ((await this.getText()).length > 0) {
40
+ await input.sendKeys(selenium_webdriver_1.Key.END, selenium_webdriver_1.Key.chord(selenium_webdriver_1.Key.SHIFT, selenium_webdriver_1.Key.HOME));
41
+ }
42
+ await input.sendKeys(text);
43
+ // fallback to clipboard if the text gets malformed
44
+ if ((await this.getText()) !== text) {
45
+ await clipboard.write(text);
46
+ await input.sendKeys(selenium_webdriver_1.Key.END, selenium_webdriver_1.Key.chord(selenium_webdriver_1.Key.SHIFT, selenium_webdriver_1.Key.HOME));
47
+ await input.sendKeys(selenium_webdriver_1.Key.chord(Input.ctlKey, 'v'));
48
+ if (originalClipboard.length > 0) {
49
+ clipboard.writeSync(originalClipboard);
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * Get the placeholder text for the input field
55
+ * @returns Promise resolving to input placeholder
56
+ */
57
+ async getPlaceHolder() {
58
+ return await this.findElement(Input.locators.Input.inputBox)
59
+ .findElement(Input.locators.Input.input).getAttribute('placeholder');
60
+ }
61
+ /**
62
+ * Confirm the input field by pressing Enter
63
+ * @returns Promise resolving when the input is confirmed
64
+ */
65
+ async confirm() {
66
+ const input = await this.findElement(Input.locators.Input.inputBox)
67
+ .findElement(Input.locators.Input.input);
68
+ await input.click();
69
+ await input.sendKeys(selenium_webdriver_1.Key.ENTER);
70
+ }
71
+ /**
72
+ * Cancel the input field by pressing Escape
73
+ * @returns Promise resolving when the input is cancelled
74
+ */
75
+ async cancel() {
76
+ const input = await this.findElement(Input.locators.Input.inputBox)
77
+ .findElement(Input.locators.Input.input);
78
+ await input.sendKeys(selenium_webdriver_1.Key.ESCAPE);
79
+ }
80
+ /**
81
+ * Clear the inpur field
82
+ * @returns Promise resolving when the field is cleared
83
+ */
84
+ async clear() {
85
+ const input = await this.findElement(Input.locators.Input.inputBox)
86
+ .findElement(Input.locators.Input.input);
87
+ // VS Code 1.40 breaks the default clear method, use select all + back space instead
88
+ await input.sendKeys(selenium_webdriver_1.Key.END, selenium_webdriver_1.Key.chord(selenium_webdriver_1.Key.SHIFT, selenium_webdriver_1.Key.HOME), selenium_webdriver_1.Key.BACK_SPACE);
89
+ if ((await input.getAttribute('value')).length > 0) {
90
+ await input.sendKeys(selenium_webdriver_1.Key.END, selenium_webdriver_1.Key.chord(selenium_webdriver_1.Key.SHIFT, selenium_webdriver_1.Key.HOME), selenium_webdriver_1.Key.BACK_SPACE);
91
+ }
92
+ }
93
+ /**
94
+ * Select (click) a quick pick option. Will scroll through the quick picks to find the item.
95
+ * Search for the item can be done by its text, or index in the quick pick menu.
96
+ * Note that scrolling does not affect the item's index, but it will
97
+ * replace some items in the DOM (thus they become unreachable)
98
+ *
99
+ * @param indexOrText index (number) or text (string) of the item to search by
100
+ * @returns Promise resolving when the given quick pick is selected
101
+ */
102
+ async selectQuickPick(indexOrText) {
103
+ const pick = await this.findQuickPick(indexOrText);
104
+ if (pick) {
105
+ await pick.select();
106
+ }
107
+ else {
108
+ await this.resetPosition();
109
+ }
110
+ }
111
+ /**
112
+ * Select/Deselect all quick picks using the 'select all' checkbox
113
+ * If multiple selection is disabled on the input box, no action is performed
114
+ *
115
+ * @param state true to select all, false to deselect all
116
+ * @returns Promise resolving when all quick picks have been toggled to desired state
117
+ */
118
+ async toggleAllQuickPicks(state) {
119
+ const checkboxes = await this.findElements(Input.locators.Input.quickPickSelectAll);
120
+ if (!checkboxes) {
121
+ return;
122
+ }
123
+ if (!await checkboxes[0].isSelected()) {
124
+ await checkboxes[0].click();
125
+ }
126
+ if (state === false) {
127
+ await checkboxes[0].click();
128
+ }
129
+ }
130
+ /**
131
+ * Scroll through the quick picks to find an item by the name or index
132
+ * @param indexOrText index (number) or text (string) of the item to search by
133
+ * @returns Promise resolvnig to QuickPickItem if found, to undefined otherwise
134
+ */
135
+ async findQuickPick(indexOrText) {
136
+ const input = await this.findElement(Input.locators.Input.inputBox)
137
+ .findElement(Input.locators.Input.input);
138
+ const first = await this.findElements(Input.locators.Input.quickPickPosition(1));
139
+ if (first.length < 1) {
140
+ await this.resetPosition();
141
+ }
142
+ let endReached = false;
143
+ while (!endReached) {
144
+ const picks = await this.getQuickPicks();
145
+ for (const pick of picks) {
146
+ const lastRow = await this.findElements(Input.locators.DefaultTreeSection.lastRow);
147
+ if (lastRow.length > 0) {
148
+ endReached = true;
149
+ }
150
+ else if (await pick.getAttribute('aria-posinset') === await pick.getAttribute('aria-setsize')) {
151
+ endReached = true;
152
+ }
153
+ if (typeof indexOrText === 'string') {
154
+ const text = await pick.getLabel();
155
+ if (text.indexOf(indexOrText) > -1) {
156
+ return pick;
157
+ }
158
+ }
159
+ else if (indexOrText === pick.getIndex()) {
160
+ return pick;
161
+ }
162
+ }
163
+ if (!endReached) {
164
+ await input.sendKeys(selenium_webdriver_1.Key.PAGE_DOWN);
165
+ }
166
+ }
167
+ return undefined;
168
+ }
169
+ /**
170
+ * Retrieve the title of an input box if it has one
171
+ * @returns Promise resolving to title if it exists, to undefined otherwise
172
+ */
173
+ async getTitle() {
174
+ const titleBar = await this.findElements(Input.locators.Input.titleBar);
175
+ if (titleBar.length > 0 && await titleBar[0].isDisplayed()) {
176
+ return (await titleBar[0].findElement(Input.locators.Input.title)).getText();
177
+ }
178
+ }
179
+ /**
180
+ * Click on the back button if it exists
181
+ * @returns Promise resolving to true if a button was clicked, to false otherwise
182
+ */
183
+ async back() {
184
+ const titleBar = await this.findElements(Input.locators.Input.titleBar);
185
+ if (titleBar.length > 0 && await titleBar[0].isDisplayed()) {
186
+ const backBtn = await titleBar[0].findElements(Input.locators.Input.backButton);
187
+ if (backBtn.length > 0 && await backBtn[0].isEnabled()) {
188
+ await backBtn[0].click();
189
+ return true;
190
+ }
191
+ }
192
+ return false;
193
+ }
194
+ async resetPosition() {
195
+ const text = await this.getText();
196
+ await this.clear();
197
+ await this.setText(text);
198
+ }
199
+ }
200
+ exports.Input = Input;
201
+ /**
202
+ * Page object representing a quick pick option in the input box
203
+ */
204
+ class QuickPickItem extends AbstractElement_1.AbstractElement {
205
+ index;
206
+ constructor(index, input, isMultiSelect = false) {
207
+ let locator = Input.locators.Input.quickPickIndex(index);
208
+ if (input instanceof __1.QuickOpenBox) {
209
+ locator = Input.locators.Input.quickPickPosition(index);
210
+ }
211
+ if (isMultiSelect) {
212
+ locator = Input.locators.Input.multiSelectIndex(index);
213
+ }
214
+ super(locator, input);
215
+ this.index = index;
216
+ }
217
+ /**
218
+ * Get the label of the quick pick item
219
+ */
220
+ async getLabel() {
221
+ return await this.findElement(Input.locators.Input.quickPickLabel).getText();
222
+ }
223
+ /**
224
+ * Get the description of the quick pick item
225
+ */
226
+ async getDescription() {
227
+ try {
228
+ return await this.findElement(Input.locators.Input.quickPickDescription).getText();
229
+ }
230
+ catch (err) {
231
+ return undefined;
232
+ }
233
+ }
234
+ /**
235
+ * Get the index of the quick pick item
236
+ */
237
+ getIndex() {
238
+ return this.index;
239
+ }
240
+ /**
241
+ * Select (click) the quick pick item
242
+ * @returns Promise resolving when the item has been clicked
243
+ */
244
+ async select() {
245
+ await this.click();
246
+ }
247
+ }
248
+ exports.QuickPickItem = QuickPickItem;
249
+ //# sourceMappingURL=Input.js.map
@@ -0,0 +1,30 @@
1
+ import { Input, QuickPickItem } from "../../..";
2
+ /**
3
+ * Plain input box variation of the input page object
4
+ */
5
+ export declare class InputBox extends Input {
6
+ constructor();
7
+ /**
8
+ * Construct a new InputBox instance after waiting for its underlying element to exist
9
+ * Use when an input box is scheduled to appear.
10
+ * @param timeout max time to wait in milliseconds, default 5000
11
+ */
12
+ static create(timeout?: number): Promise<InputBox>;
13
+ /**
14
+ * Get the message below the input field
15
+ */
16
+ getMessage(): Promise<string>;
17
+ hasProgress(): Promise<boolean>;
18
+ getQuickPicks(): Promise<QuickPickItem[]>;
19
+ getCheckboxes(): Promise<QuickPickItem[]>;
20
+ /**
21
+ * Find whether the input is showing an error
22
+ * @returns Promise resolving to notification message
23
+ */
24
+ hasError(): Promise<boolean>;
25
+ /**
26
+ * Check if the input field is masked (input type password)
27
+ * @returns Promise resolving to notification message
28
+ */
29
+ isPassword(): Promise<boolean>;
30
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputBox = void 0;
4
+ const __1 = require("../../..");
5
+ const selenium_webdriver_1 = require("selenium-webdriver");
6
+ /**
7
+ * Plain input box variation of the input page object
8
+ */
9
+ class InputBox extends __1.Input {
10
+ constructor() {
11
+ super(InputBox.locators.InputBox.constructor, InputBox.locators.Workbench.constructor);
12
+ }
13
+ /**
14
+ * Construct a new InputBox instance after waiting for its underlying element to exist
15
+ * Use when an input box is scheduled to appear.
16
+ * @param timeout max time to wait in milliseconds, default 5000
17
+ */
18
+ static async create(timeout = 5000) {
19
+ await InputBox.driver.wait(selenium_webdriver_1.until.elementLocated(InputBox.locators.InputBox.constructor), timeout);
20
+ return new InputBox().wait();
21
+ }
22
+ /**
23
+ * Get the message below the input field
24
+ */
25
+ async getMessage() {
26
+ return await this.findElement(InputBox.locators.InputBox.message).getText();
27
+ }
28
+ async hasProgress() {
29
+ const klass = await this.findElement(InputBox.locators.InputBox.progress)
30
+ .getAttribute('class');
31
+ return klass.indexOf('done') < 0;
32
+ }
33
+ async getQuickPicks() {
34
+ const picks = [];
35
+ const elements = await this.findElement(InputBox.locators.InputBox.quickList)
36
+ .findElement(InputBox.locators.InputBox.rows)
37
+ .findElements(InputBox.locators.InputBox.row);
38
+ for (const element of elements) {
39
+ if (await element.isDisplayed()) {
40
+ picks.push(await new __1.QuickPickItem(+await element.getAttribute('data-index'), this).wait());
41
+ }
42
+ }
43
+ return picks;
44
+ }
45
+ async getCheckboxes() {
46
+ const picks = [];
47
+ const elements = await this.findElement(InputBox.locators.InputBox.quickList)
48
+ .findElement(InputBox.locators.InputBox.rows)
49
+ .findElements(InputBox.locators.InputBox.row);
50
+ for (const element of elements) {
51
+ if (await element.isDisplayed()) {
52
+ picks.push(await new __1.QuickPickItem(+await element.getAttribute('data-index'), this, true).wait());
53
+ }
54
+ }
55
+ return picks;
56
+ }
57
+ /**
58
+ * Find whether the input is showing an error
59
+ * @returns Promise resolving to notification message
60
+ */
61
+ async hasError() {
62
+ const klass = await this.findElement(InputBox.locators.Input.inputBox).getAttribute('class');
63
+ return klass.indexOf('error') > -1;
64
+ }
65
+ /**
66
+ * Check if the input field is masked (input type password)
67
+ * @returns Promise resolving to notification message
68
+ */
69
+ async isPassword() {
70
+ const input = await this.findElement(InputBox.locators.Input.input);
71
+ return await input.getAttribute('type') === 'password';
72
+ }
73
+ }
74
+ exports.InputBox = InputBox;
75
+ //# sourceMappingURL=InputBox.js.map
@@ -0,0 +1,15 @@
1
+ import { Input, QuickPickItem } from "../../..";
2
+ /**
3
+ * @deprecated as of VS Code 1.44.0, quick open box has been replaced with input box
4
+ * The quick open box variation of the input
5
+ */
6
+ export declare class QuickOpenBox extends Input {
7
+ constructor();
8
+ /**
9
+ * Construct a new QuickOpenBox instance after waiting for its underlying element to exist
10
+ * Use when a quick open box is scheduled to appear.
11
+ */
12
+ static create(): Promise<QuickOpenBox>;
13
+ hasProgress(): Promise<boolean>;
14
+ getQuickPicks(): Promise<QuickPickItem[]>;
15
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuickOpenBox = void 0;
4
+ const __1 = require("../../..");
5
+ const selenium_webdriver_1 = require("selenium-webdriver");
6
+ /**
7
+ * @deprecated as of VS Code 1.44.0, quick open box has been replaced with input box
8
+ * The quick open box variation of the input
9
+ */
10
+ class QuickOpenBox extends __1.Input {
11
+ constructor() {
12
+ super(QuickOpenBox.locators.QuickOpenBox.constructor, QuickOpenBox.locators.Workbench.constructor);
13
+ }
14
+ /**
15
+ * Construct a new QuickOpenBox instance after waiting for its underlying element to exist
16
+ * Use when a quick open box is scheduled to appear.
17
+ */
18
+ static async create() {
19
+ await QuickOpenBox.driver.wait(selenium_webdriver_1.until.elementLocated(QuickOpenBox.locators.QuickOpenBox.constructor));
20
+ return new QuickOpenBox().wait();
21
+ }
22
+ async hasProgress() {
23
+ const klass = await this.findElement(QuickOpenBox.locators.QuickOpenBox.progress)
24
+ .getAttribute('class');
25
+ return klass.indexOf('done') < 0;
26
+ }
27
+ async getQuickPicks() {
28
+ const picks = [];
29
+ const tree = await this.getDriver().wait(selenium_webdriver_1.until.elementLocated(QuickOpenBox.locators.QuickOpenBox.quickList), 1000);
30
+ const elements = await tree.findElements(QuickOpenBox.locators.QuickOpenBox.row);
31
+ for (const element of elements) {
32
+ const index = +await element.getAttribute('aria-posinset');
33
+ if (await element.isDisplayed()) {
34
+ picks.push(await new __1.QuickPickItem(index, this).wait());
35
+ }
36
+ }
37
+ return picks;
38
+ }
39
+ }
40
+ exports.QuickOpenBox = QuickOpenBox;
41
+ //# sourceMappingURL=QuickOpenBox.js.map
@@ -0,0 +1,8 @@
1
+ import { WebElement } from "selenium-webdriver";
2
+ /**
3
+ * Condition to wait until an element's attribute has a specified value
4
+ * @param element webelement to check
5
+ * @param attribute attribute to check
6
+ * @param value value to wait for the attribute to have
7
+ */
8
+ export declare function waitForAttributeValue(element: WebElement, attribute: string, value: string): () => Promise<boolean>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitForAttributeValue = void 0;
4
+ /**
5
+ * Condition to wait until an element's attribute has a specified value
6
+ * @param element webelement to check
7
+ * @param attribute attribute to check
8
+ * @param value value to wait for the attribute to have
9
+ */
10
+ function waitForAttributeValue(element, attribute, value) {
11
+ return async () => {
12
+ const result = await element.getAttribute(attribute);
13
+ return result === value;
14
+ };
15
+ }
16
+ exports.waitForAttributeValue = waitForAttributeValue;
17
+ //# sourceMappingURL=WaitForAttribute.js.map
@@ -0,0 +1,3 @@
1
+ export declare class NullAttributeError extends Error {
2
+ constructor(message?: string);
3
+ }