@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,57 @@
1
+ import { SideBarView, ViewSection, ViewSectionConstructor } from "../..";
2
+ import { AbstractElement } from "../AbstractElement";
3
+ /**
4
+ * Page object representing the view container of a side bar view
5
+ */
6
+ export declare class ViewContent extends AbstractElement {
7
+ constructor(view?: SideBarView);
8
+ /**
9
+ * Finds whether a progress bar is active at the top of the view
10
+ * @returns Promise resolving to true/false
11
+ */
12
+ hasProgress(): Promise<boolean>;
13
+ /**
14
+ * Retrieves a collapsible view content section by its title.
15
+ * Generic parameter allows caller to cast returned section to
16
+ * desired type, however it is caller's responsibility to check
17
+ * whether type is compatible with desired type.
18
+ * @param title Title of the section
19
+ * @returns Promise resolving to ViewSection object
20
+ */
21
+ getSection<T extends ViewSection>(title: string): Promise<T>;
22
+ /**
23
+ * Retrieves a collapsible view content section by its title.
24
+ * Type parameter allows caller to use custom section implementation,
25
+ * however it is caller's responsibility to check
26
+ * whether type is compatible with desired type.
27
+ * @param title Title of the section
28
+ * @param type ViewSection constructor to be used
29
+ * @returns Promise resolving to object specified by type
30
+ */
31
+ getSection<T extends ViewSection>(title: string, type: ViewSectionConstructor<T>): Promise<T>;
32
+ /**
33
+ * Retrieves a collapsible view content section by predicate.
34
+ * Generic parameter allows caller to cast returned section to
35
+ * desired type, however it is caller's responsibility to check
36
+ * whether type is compatible with desired type.
37
+ * @param predicate Predicate to be used when searching
38
+ * @returns Promise resolving to ViewSection object
39
+ */
40
+ getSection<T extends ViewSection>(predicate: ((section: ViewSection) => boolean | PromiseLike<boolean>)): Promise<T>;
41
+ /**
42
+ * Retrieves a collapsible view content section by predicate.
43
+ * Type parameter allows caller to use custom section implementation,
44
+ * however it is caller's responsibility to check
45
+ * whether type is compatible with desired type.
46
+ * @param predicate Predicate to be used when searching
47
+ * @param type ViewSection constructor to be used
48
+ * @returns Promise resolving to object specified by type
49
+ */
50
+ getSection<T extends ViewSection>(predicate: ((section: ViewSection) => boolean | PromiseLike<boolean>), type: ViewSectionConstructor<T>): Promise<T>;
51
+ /**
52
+ * Retrieves all the collapsible view content sections
53
+ * @returns Promise resolving to array of ViewSection objects
54
+ */
55
+ getSections(): Promise<ViewSection[]>;
56
+ private createSection;
57
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewContent = void 0;
4
+ const __1 = require("../..");
5
+ const selenium_webdriver_1 = require("selenium-webdriver");
6
+ const AbstractElement_1 = require("../AbstractElement");
7
+ /**
8
+ * Page object representing the view container of a side bar view
9
+ */
10
+ class ViewContent extends AbstractElement_1.AbstractElement {
11
+ constructor(view = new __1.SideBarView()) {
12
+ super(ViewContent.locators.ViewContent.constructor, view);
13
+ }
14
+ /**
15
+ * Finds whether a progress bar is active at the top of the view
16
+ * @returns Promise resolving to true/false
17
+ */
18
+ async hasProgress() {
19
+ const progress = await this.findElement(ViewContent.locators.ViewContent.progress);
20
+ const hidden = await progress.getAttribute('aria-hidden');
21
+ if (hidden === 'true') {
22
+ return false;
23
+ }
24
+ return true;
25
+ }
26
+ async getSection(titleOrPredicate, type) {
27
+ const sections = await this.getSections();
28
+ const predicate = typeof titleOrPredicate === 'string' ?
29
+ (async (section) => await section.getTitle() === titleOrPredicate) : titleOrPredicate;
30
+ for (const section of sections) {
31
+ if (await predicate(section)) {
32
+ if (type !== undefined && !(section instanceof type)) {
33
+ return new type(section, this);
34
+ }
35
+ return section;
36
+ }
37
+ }
38
+ if (typeof titleOrPredicate === 'string') {
39
+ throw new selenium_webdriver_1.error.NoSuchElementError(`No section with title '${titleOrPredicate}' found`);
40
+ }
41
+ else {
42
+ throw new selenium_webdriver_1.error.NoSuchElementError(`No section satisfying predicate found`);
43
+ }
44
+ }
45
+ /**
46
+ * Retrieves all the collapsible view content sections
47
+ * @returns Promise resolving to array of ViewSection objects
48
+ */
49
+ async getSections() {
50
+ const sections = [];
51
+ const elements = await this.findElements(ViewContent.locators.ViewContent.section);
52
+ for (const element of elements) {
53
+ sections.push(await this.createSection(element));
54
+ }
55
+ return sections;
56
+ }
57
+ async createSection(panel, type) {
58
+ if (type !== undefined) {
59
+ return new type(panel, this);
60
+ }
61
+ let section = new __1.DefaultTreeSection(panel, this);
62
+ const types = ViewContent.locators.DefaultTreeSection.type;
63
+ const locators = ViewContent.locators;
64
+ if (await types.default(section, locators)) {
65
+ return section;
66
+ }
67
+ else if (await types.marketplace.extension(section, locators)) {
68
+ return new __1.ExtensionsViewSection(panel, this);
69
+ }
70
+ else {
71
+ return new __1.CustomTreeSection(panel, this);
72
+ }
73
+ }
74
+ }
75
+ exports.ViewContent = ViewContent;
76
+ //# sourceMappingURL=ViewContent.js.map
@@ -0,0 +1,97 @@
1
+ import { ElementWithContexMenu } from "../ElementWithContextMenu";
2
+ import { AbstractElement } from "../AbstractElement";
3
+ import { WebElement, By } from "selenium-webdriver";
4
+ /**
5
+ * Arbitrary item in the side bar view
6
+ */
7
+ export declare abstract class ViewItem extends ElementWithContexMenu {
8
+ /**
9
+ * Select the item in the view.
10
+ * Note that selecting the item will toggle its expand state when applicable.
11
+ * @returns Promise resolving when the item has been clicked
12
+ */
13
+ select(): Promise<void>;
14
+ }
15
+ /**
16
+ * Abstract representation of a row in the tree inside a view content section
17
+ */
18
+ export declare abstract class TreeItem extends ViewItem {
19
+ /**
20
+ * Retrieves the label of this view item
21
+ */
22
+ abstract getLabel(): Promise<string>;
23
+ /**
24
+ * Retrieves the tooltip of this TreeItem.
25
+ * @returns A promise resolving to the tooltip or undefined if the TreeItem has no tooltip.
26
+ */
27
+ getTooltip(): Promise<string | undefined>;
28
+ /**
29
+ * Retrieves the description of this TreeItem.
30
+ * @returns A promise resolving to the tooltip or undefined if the TreeItem has no description.
31
+ */
32
+ getDescription(): Promise<string | undefined>;
33
+ /**
34
+ * Finds if the item has children by actually counting the child items
35
+ * Note that this will expand the item if it was collapsed
36
+ * @returns Promise resolving to true/false
37
+ */
38
+ hasChildren(): Promise<boolean>;
39
+ /**
40
+ * Finds whether the item is expanded. Always returns false if item has no children.
41
+ * @returns Promise resolving to true/false
42
+ */
43
+ abstract isExpanded(): Promise<boolean>;
44
+ /**
45
+ * Find children of an item, will try to expand the item in the process
46
+ * @returns Promise resolving to array of TreeItem objects, empty array if item has no children
47
+ */
48
+ abstract getChildren(): Promise<TreeItem[]>;
49
+ /**
50
+ * Finds if the item is expandable/collapsible
51
+ * @returns Promise resolving to true/false
52
+ */
53
+ abstract isExpandable(): Promise<boolean>;
54
+ /**
55
+ * Expands the current item, if it can be expanded and is collapsed.
56
+ */
57
+ expand(): Promise<void>;
58
+ /**
59
+ * Find a child item with the given name
60
+ * @returns Promise resolving to TreeItem object if the child item exists, undefined otherwise
61
+ */
62
+ findChildItem(name: string): Promise<TreeItem | undefined>;
63
+ /**
64
+ * Collapse the item if expanded
65
+ */
66
+ collapse(): Promise<void>;
67
+ /**
68
+ * Find all action buttons bound to the view item
69
+ *
70
+ * @returns array of ViewItemAction objects, empty array if item has no
71
+ * actions associated
72
+ */
73
+ getActionButtons(): Promise<ViewItemAction[]>;
74
+ /**
75
+ * Find action button for view item by label
76
+ * @param label label of the button to search by
77
+ *
78
+ * @returns ViewItemAction object if such button exists, undefined otherwise
79
+ */
80
+ getActionButton(label: string): Promise<ViewItemAction | undefined>;
81
+ /**
82
+ * Find all child elements of a tree item
83
+ * @param locator locator of a given type of tree item
84
+ */
85
+ protected getChildItems(locator: By): Promise<WebElement[]>;
86
+ protected findTwistie(): Promise<WebElement>;
87
+ }
88
+ /**
89
+ * Action button bound to a view item
90
+ */
91
+ export declare class ViewItemAction extends AbstractElement {
92
+ constructor(actionConstructor: By, viewItem: TreeItem);
93
+ /**
94
+ * Get label of the action button
95
+ */
96
+ getLabel(): Promise<string>;
97
+ }
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewItemAction = exports.TreeItem = exports.ViewItem = void 0;
4
+ const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
5
+ const AbstractElement_1 = require("../AbstractElement");
6
+ const selenium_webdriver_1 = require("selenium-webdriver");
7
+ const NullAttributeError_1 = require("../../errors/NullAttributeError");
8
+ /**
9
+ * Arbitrary item in the side bar view
10
+ */
11
+ class ViewItem extends ElementWithContextMenu_1.ElementWithContexMenu {
12
+ /**
13
+ * Select the item in the view.
14
+ * Note that selecting the item will toggle its expand state when applicable.
15
+ * @returns Promise resolving when the item has been clicked
16
+ */
17
+ async select() {
18
+ await this.click();
19
+ }
20
+ }
21
+ exports.ViewItem = ViewItem;
22
+ /**
23
+ * Abstract representation of a row in the tree inside a view content section
24
+ */
25
+ class TreeItem extends ViewItem {
26
+ /**
27
+ * Retrieves the tooltip of this TreeItem.
28
+ * @returns A promise resolving to the tooltip or undefined if the TreeItem has no tooltip.
29
+ */
30
+ async getTooltip() {
31
+ return undefined;
32
+ }
33
+ /**
34
+ * Retrieves the description of this TreeItem.
35
+ * @returns A promise resolving to the tooltip or undefined if the TreeItem has no description.
36
+ */
37
+ async getDescription() {
38
+ return undefined;
39
+ }
40
+ /**
41
+ * Finds if the item has children by actually counting the child items
42
+ * Note that this will expand the item if it was collapsed
43
+ * @returns Promise resolving to true/false
44
+ */
45
+ async hasChildren() {
46
+ const children = await this.getChildren();
47
+ return children && children.length > 0;
48
+ }
49
+ /**
50
+ * Expands the current item, if it can be expanded and is collapsed.
51
+ */
52
+ async expand() {
53
+ if (await this.isExpandable() && !await this.isExpanded()) {
54
+ await (await this.findTwistie()).click();
55
+ }
56
+ }
57
+ /**
58
+ * Find a child item with the given name
59
+ * @returns Promise resolving to TreeItem object if the child item exists, undefined otherwise
60
+ */
61
+ async findChildItem(name) {
62
+ const children = await this.getChildren();
63
+ for (const item of children) {
64
+ if (await item.getLabel() === name) {
65
+ return item;
66
+ }
67
+ }
68
+ }
69
+ /**
70
+ * Collapse the item if expanded
71
+ */
72
+ async collapse() {
73
+ if (await this.isExpandable() && await this.isExpanded()) {
74
+ await (await this.findTwistie()).click();
75
+ }
76
+ }
77
+ /**
78
+ * Find all action buttons bound to the view item
79
+ *
80
+ * @returns array of ViewItemAction objects, empty array if item has no
81
+ * actions associated
82
+ */
83
+ async getActionButtons() {
84
+ await this.getDriver().actions().move({ origin: this }).perform();
85
+ let container;
86
+ try {
87
+ container = await this.findElement(TreeItem.locators.TreeItem.actions);
88
+ }
89
+ catch (e) {
90
+ if (e instanceof selenium_webdriver_1.error.NoSuchElementError) {
91
+ return [];
92
+ }
93
+ throw e;
94
+ }
95
+ const actions = [];
96
+ const items = await container.findElements(TreeItem.locators.TreeItem.actionLabel);
97
+ for (const item of items) {
98
+ const label = await item.getAttribute(TreeItem.locators.TreeItem.actionTitle);
99
+ if (label === '' || label === null) {
100
+ // unknown, skip the item
101
+ continue;
102
+ }
103
+ try {
104
+ actions.push(new ViewItemAction(ViewItemAction.locators.ViewSection.actionConstructor(label), this));
105
+ }
106
+ catch (e) {
107
+ // the item was destroyed in meantime
108
+ if (e instanceof selenium_webdriver_1.error.NoSuchElementError) {
109
+ continue;
110
+ }
111
+ if (e instanceof selenium_webdriver_1.error.StaleElementReferenceError) {
112
+ console.warn('ViewItem has become stale');
113
+ }
114
+ throw e;
115
+ }
116
+ }
117
+ return actions;
118
+ }
119
+ /**
120
+ * Find action button for view item by label
121
+ * @param label label of the button to search by
122
+ *
123
+ * @returns ViewItemAction object if such button exists, undefined otherwise
124
+ */
125
+ async getActionButton(label) {
126
+ const actions = await this.getActionButtons();
127
+ for (const action of actions) {
128
+ try {
129
+ if ((await action.getLabel()).includes(label)) {
130
+ return action;
131
+ }
132
+ }
133
+ catch (e) {
134
+ if (e instanceof NullAttributeError_1.NullAttributeError || e instanceof selenium_webdriver_1.error.StaleElementReferenceError) {
135
+ continue;
136
+ }
137
+ throw e;
138
+ }
139
+ }
140
+ return undefined;
141
+ }
142
+ /**
143
+ * Find all child elements of a tree item
144
+ * @param locator locator of a given type of tree item
145
+ */
146
+ async getChildItems(locator) {
147
+ const items = [];
148
+ await this.expand();
149
+ const rows = await this.enclosingItem.findElements(locator);
150
+ const baseIndex = +await this.getAttribute(TreeItem.locators.ViewSection.index);
151
+ const baseLevel = +await this.getAttribute(TreeItem.locators.ViewSection.level);
152
+ for (const row of rows) {
153
+ const level = +await row.getAttribute(TreeItem.locators.ViewSection.level);
154
+ const index = +await row.getAttribute(TreeItem.locators.ViewSection.index);
155
+ if (index <= baseIndex) {
156
+ continue;
157
+ }
158
+ if (level > baseLevel + 1) {
159
+ continue;
160
+ }
161
+ if (level <= baseLevel) {
162
+ break;
163
+ }
164
+ items.push(row);
165
+ }
166
+ return items;
167
+ }
168
+ async findTwistie() {
169
+ return await this.findElement(TreeItem.locators.TreeItem.twistie);
170
+ }
171
+ }
172
+ exports.TreeItem = TreeItem;
173
+ /**
174
+ * Action button bound to a view item
175
+ */
176
+ class ViewItemAction extends AbstractElement_1.AbstractElement {
177
+ constructor(actionConstructor, viewItem) {
178
+ super(actionConstructor, viewItem);
179
+ }
180
+ /**
181
+ * Get label of the action button
182
+ */
183
+ async getLabel() {
184
+ const value = await this.getAttribute(ViewItemAction.locators.ViewSection.buttonLabel);
185
+ if (value === null) {
186
+ throw new NullAttributeError_1.NullAttributeError(`${this.constructor.name}.getLabel returned null`);
187
+ }
188
+ return value;
189
+ }
190
+ }
191
+ exports.ViewItemAction = ViewItemAction;
192
+ //# sourceMappingURL=ViewItem.js.map
@@ -0,0 +1,98 @@
1
+ import { WebElement } from "selenium-webdriver";
2
+ import { ContextMenu, ViewContent, ViewItem, WelcomeContentSection } from "../..";
3
+ import { AbstractElement } from "../AbstractElement";
4
+ export type ViewSectionConstructor<T extends ViewSection> = {
5
+ new (rootElement: WebElement, tree: ViewContent): T;
6
+ };
7
+ /**
8
+ * Page object representing a collapsible content section of the side bar view
9
+ */
10
+ export declare abstract class ViewSection extends AbstractElement {
11
+ constructor(panel: WebElement, content: ViewContent);
12
+ /**
13
+ * Get the title of the section as string
14
+ * @returns Promise resolving to section title
15
+ */
16
+ getTitle(): Promise<string>;
17
+ /**
18
+ * Expand the section if collapsed
19
+ * @returns Promise resolving when the section is expanded
20
+ */
21
+ expand(): Promise<void>;
22
+ /**
23
+ * Collapse the section if expanded
24
+ * @returns Promise resolving when the section is collapsed
25
+ */
26
+ collapse(): Promise<void>;
27
+ /**
28
+ * Finds whether the section is expanded
29
+ * @returns Promise resolving to true/false
30
+ */
31
+ isExpanded(): Promise<boolean>;
32
+ /**
33
+ * Finds [Welcome Content](https://code.visualstudio.com/api/extension-guides/tree-view#welcome-content)
34
+ * present in this ViewSection and returns it. If none is found, then `undefined` is returned
35
+ *
36
+ */
37
+ findWelcomeContent(): Promise<WelcomeContentSection | undefined>;
38
+ /**
39
+ * Retrieve all items currently visible in the view section.
40
+ * Note that any item currently beyond the visible list, i.e. not scrolled to, will not be retrieved.
41
+ * @returns Promise resolving to array of ViewItem objects
42
+ */
43
+ abstract getVisibleItems(): Promise<ViewItem[]>;
44
+ /**
45
+ * Find an item in this view section by label. Does not perform recursive search through the whole tree.
46
+ * Does however scroll through all the expanded content. Will find items beyond the current scroll range.
47
+ * @param label Label of the item to search for.
48
+ * @param maxLevel Limit how deep the algorithm should look into any expanded items, default unlimited (0)
49
+ * @returns Promise resolving to ViewItem object is such item exists, undefined otherwise
50
+ */
51
+ abstract findItem(label: string, maxLevel?: number): Promise<ViewItem | undefined>;
52
+ /**
53
+ * Open an item with a given path represented by a sequence of labels
54
+ *
55
+ * e.g to open 'file' inside 'folder', call
56
+ * openItem('folder', 'file')
57
+ *
58
+ * The first item is only searched for directly within the root element (depth 1).
59
+ * The label sequence is handled in order. If a leaf item (a file for example) is found in the middle
60
+ * of the sequence, the rest is ignored.
61
+ *
62
+ * If the item structure is flat, use the item's title to search by.
63
+ *
64
+ * @param path Sequence of labels that make up the path to a given item.
65
+ * @returns Promise resolving to array of ViewItem objects representing the last item's children.
66
+ * If the last item is a leaf, empty array is returned.
67
+ */
68
+ abstract openItem(...path: string[]): Promise<ViewItem[]>;
69
+ /**
70
+ * Retrieve the action buttons on the section's header
71
+ * @returns Promise resolving to array of ViewPanelAction objects
72
+ */
73
+ getActions(): Promise<ViewPanelAction[]>;
74
+ /**
75
+ * Retrieve an action button on the sections's header by its label
76
+ * @param label label/title of the button
77
+ * @returns ViewPanelAction object if found, undefined otherwise
78
+ */
79
+ getAction(label: string): Promise<ViewPanelAction | undefined>;
80
+ /**
81
+ * Click on the More Actions... item if it exists
82
+ *
83
+ * @returns ContextMenu page object if the action succeeds, undefined otherwise
84
+ */
85
+ moreActions(): Promise<ContextMenu | undefined>;
86
+ private isHeaderHidden;
87
+ }
88
+ /**
89
+ * Action button on the header of a view section
90
+ */
91
+ export declare class ViewPanelAction extends AbstractElement {
92
+ constructor(element: WebElement, viewPart: ViewSection);
93
+ /**
94
+ * Get label of the action button
95
+ */
96
+ getLabel(): Promise<string>;
97
+ wait(timeout?: number): Promise<this>;
98
+ }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewPanelAction = exports.ViewSection = void 0;
4
+ const selenium_webdriver_1 = require("selenium-webdriver");
5
+ const __1 = require("../..");
6
+ const AbstractElement_1 = require("../AbstractElement");
7
+ const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
8
+ /**
9
+ * Page object representing a collapsible content section of the side bar view
10
+ */
11
+ class ViewSection extends AbstractElement_1.AbstractElement {
12
+ constructor(panel, content) {
13
+ super(panel, content);
14
+ }
15
+ /**
16
+ * Get the title of the section as string
17
+ * @returns Promise resolving to section title
18
+ */
19
+ async getTitle() {
20
+ const title = await this.findElement(ViewSection.locators.ViewSection.title);
21
+ return await title.getAttribute(ViewSection.locators.ViewSection.titleText);
22
+ }
23
+ /**
24
+ * Expand the section if collapsed
25
+ * @returns Promise resolving when the section is expanded
26
+ */
27
+ async expand() {
28
+ if (await this.isHeaderHidden()) {
29
+ return;
30
+ }
31
+ if (!await this.isExpanded()) {
32
+ const panel = await this.findElement(ViewSection.locators.ViewSection.header);
33
+ await panel.click();
34
+ await this.getDriver().wait((0, __1.waitForAttributeValue)(panel, ViewSection.locators.ViewSection.headerExpanded, 'true'), 1000);
35
+ }
36
+ }
37
+ /**
38
+ * Collapse the section if expanded
39
+ * @returns Promise resolving when the section is collapsed
40
+ */
41
+ async collapse() {
42
+ if (await this.isHeaderHidden()) {
43
+ return;
44
+ }
45
+ if (await this.isExpanded()) {
46
+ const panel = await this.findElement(ViewSection.locators.ViewSection.header);
47
+ await panel.click();
48
+ await this.getDriver().wait((0, __1.waitForAttributeValue)(panel, ViewSection.locators.ViewSection.headerExpanded, 'false'), 1000);
49
+ }
50
+ }
51
+ /**
52
+ * Finds whether the section is expanded
53
+ * @returns Promise resolving to true/false
54
+ */
55
+ async isExpanded() {
56
+ const header = await this.findElement(ViewSection.locators.ViewSection.header);
57
+ const expanded = await header.getAttribute(ViewSection.locators.ViewSection.headerExpanded);
58
+ return expanded === 'true';
59
+ }
60
+ /**
61
+ * Finds [Welcome Content](https://code.visualstudio.com/api/extension-guides/tree-view#welcome-content)
62
+ * present in this ViewSection and returns it. If none is found, then `undefined` is returned
63
+ *
64
+ */
65
+ async findWelcomeContent() {
66
+ try {
67
+ const res = await this.findElement(ViewSection.locators.ViewSection.welcomeContent);
68
+ if (!await res.isDisplayed()) {
69
+ return undefined;
70
+ }
71
+ return new __1.WelcomeContentSection(res, this);
72
+ }
73
+ catch (_err) {
74
+ return undefined;
75
+ }
76
+ }
77
+ /**
78
+ * Retrieve the action buttons on the section's header
79
+ * @returns Promise resolving to array of ViewPanelAction objects
80
+ */
81
+ async getActions() {
82
+ const actions = [];
83
+ if (!await this.isHeaderHidden()) {
84
+ const header = await this.findElement(ViewSection.locators.ViewSection.header);
85
+ const act = await header.findElement(ViewSection.locators.ViewSection.actions);
86
+ const elements = await act.findElements(ViewSection.locators.ViewSection.button);
87
+ for (const element of elements) {
88
+ actions.push(await new ViewPanelAction(element, this).wait());
89
+ }
90
+ }
91
+ return actions;
92
+ }
93
+ /**
94
+ * Retrieve an action button on the sections's header by its label
95
+ * @param label label/title of the button
96
+ * @returns ViewPanelAction object if found, undefined otherwise
97
+ */
98
+ async getAction(label) {
99
+ const actions = await this.getActions();
100
+ for (const action of actions) {
101
+ if (await action.getLabel() === label) {
102
+ return action;
103
+ }
104
+ }
105
+ }
106
+ /**
107
+ * Click on the More Actions... item if it exists
108
+ *
109
+ * @returns ContextMenu page object if the action succeeds, undefined otherwise
110
+ */
111
+ async moreActions() {
112
+ let more = await this.getAction('More Actions...');
113
+ if (!more) {
114
+ return undefined;
115
+ }
116
+ const section = this;
117
+ const btn = new class extends ElementWithContextMenu_1.ElementWithContexMenu {
118
+ async openContextMenu() {
119
+ await this.click();
120
+ const shadowRootHost = await section.findElements(selenium_webdriver_1.By.className('shadow-root-host'));
121
+ if (shadowRootHost.length > 0) {
122
+ let shadowRoot;
123
+ const webdriverCapabilities = await this.getDriver().getCapabilities();
124
+ const chromiumVersion = webdriverCapabilities.getBrowserVersion();
125
+ if (chromiumVersion && parseInt(chromiumVersion.split('.')[0]) >= 96) {
126
+ shadowRoot = await shadowRootHost[0].getShadowRoot();
127
+ return new __1.ContextMenu(await shadowRoot.findElement(selenium_webdriver_1.By.className('monaco-menu-container'))).wait();
128
+ }
129
+ else {
130
+ shadowRoot = await this.getDriver().executeScript('return arguments[0].shadowRoot', shadowRootHost[0]);
131
+ return new __1.ContextMenu(shadowRoot).wait();
132
+ }
133
+ }
134
+ return await super.openContextMenu();
135
+ }
136
+ }(more, this);
137
+ return await btn.openContextMenu();
138
+ }
139
+ async isHeaderHidden() {
140
+ const header = await this.findElement(ViewSection.locators.ViewSection.header);
141
+ return (await header.getAttribute('class')).indexOf('hidden') > -1;
142
+ }
143
+ }
144
+ exports.ViewSection = ViewSection;
145
+ /**
146
+ * Action button on the header of a view section
147
+ */
148
+ class ViewPanelAction extends AbstractElement_1.AbstractElement {
149
+ constructor(element, viewPart) {
150
+ super(element, viewPart);
151
+ }
152
+ /**
153
+ * Get label of the action button
154
+ */
155
+ async getLabel() {
156
+ return await this.getAttribute(ViewSection.locators.ViewSection.buttonLabel);
157
+ }
158
+ async wait(timeout = 1000) {
159
+ await this.getDriver().wait(selenium_webdriver_1.until.elementIsEnabled(this), timeout);
160
+ return this;
161
+ }
162
+ }
163
+ exports.ViewPanelAction = ViewPanelAction;
164
+ //# sourceMappingURL=ViewSection.js.map