@redhat-developer/page-objects 1.4.1 → 1.6.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.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License", destination); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * https://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
+ import { ExtensionEditorView, WebView } from '../..';
18
+ export declare class ExtensionEditorDetailsSection extends ExtensionEditorView {
19
+ /**
20
+ * Get all categories of extension.
21
+ * @returns Promise resolving categories of extension.
22
+ */
23
+ getCategories(): Promise<string[]>;
24
+ /**
25
+ * Get all resources of extension.
26
+ * @returns Promise resolving resources of extension.
27
+ */
28
+ getResources(): Promise<string[]>;
29
+ /**
30
+ * Get content of More Info section.
31
+ * @returns Promise resolving content of 'More Info' section.
32
+ */
33
+ getMoreInfo(): Promise<{
34
+ [key: string]: string;
35
+ }>;
36
+ /**
37
+ * Get value of specific attribute from 'More Info' section.
38
+ * @param key Name of attribute.
39
+ * @returns Promise resolving value for specified attribute.
40
+ */
41
+ getMoreInfoItem(key: string): Promise<string>;
42
+ /**
43
+ * Blocked by https://github.com/redhat-developer/vscode-extension-tester/issues/1492
44
+ */
45
+ getReadme(): Promise<WebView>;
46
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License", destination); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ExtensionEditorDetailsSection = void 0;
20
+ const __1 = require("../..");
21
+ class ExtensionEditorDetailsSection extends __1.ExtensionEditorView {
22
+ /**
23
+ * Get all categories of extension.
24
+ * @returns Promise resolving categories of extension.
25
+ */
26
+ async getCategories() {
27
+ const categories = [];
28
+ const container = await this.findElement(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.categoriesContainer);
29
+ const categoriesInContainer = await container.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.category);
30
+ for (const cat of categoriesInContainer) {
31
+ categories.push(await cat.getText());
32
+ }
33
+ return categories;
34
+ }
35
+ /**
36
+ * Get all resources of extension.
37
+ * @returns Promise resolving resources of extension.
38
+ */
39
+ async getResources() {
40
+ const resources = [];
41
+ const container = await this.findElement(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.resourcesContainer);
42
+ const resourcesInContainer = await container.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.resource);
43
+ for (const res of resourcesInContainer) {
44
+ resources.push(await res.getText());
45
+ }
46
+ return resources;
47
+ }
48
+ /**
49
+ * Get content of More Info section.
50
+ * @returns Promise resolving content of 'More Info' section.
51
+ */
52
+ async getMoreInfo() {
53
+ const moreInfo = {};
54
+ const container = await this.findElement(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.moreInfoContainer);
55
+ const moreInfoInContainer = await container.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.moreInfo);
56
+ for (const entry of moreInfoInContainer) {
57
+ const elmnts = await entry.findElements(ExtensionEditorDetailsSection.locators.ExtensionEditorDetailsSection.moreInfoElements);
58
+ const name = await (await elmnts.at(0))?.getText();
59
+ const value = await (await elmnts.at(1))?.getText();
60
+ if (name !== undefined && value !== undefined) {
61
+ moreInfo[name] = value;
62
+ }
63
+ }
64
+ return moreInfo;
65
+ }
66
+ /**
67
+ * Get value of specific attribute from 'More Info' section.
68
+ * @param key Name of attribute.
69
+ * @returns Promise resolving value for specified attribute.
70
+ */
71
+ async getMoreInfoItem(key) {
72
+ const moreInfo = await this.getMoreInfo();
73
+ return moreInfo[key];
74
+ }
75
+ /**
76
+ * Blocked by https://github.com/redhat-developer/vscode-extension-tester/issues/1492
77
+ */
78
+ async getReadme() {
79
+ throw Error('Not implemented yet.');
80
+ }
81
+ }
82
+ exports.ExtensionEditorDetailsSection = ExtensionEditorDetailsSection;
83
+ //# sourceMappingURL=ExtensionEditorDetailsSection.js.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License", destination); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * https://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
+ import { Editor, EditorGroup, EditorView } from '../..';
18
+ export declare class ExtensionEditorView extends Editor {
19
+ constructor(view?: EditorView | EditorGroup);
20
+ /**
21
+ * Get name of extension.
22
+ * @returns Promise resolving name of extension.
23
+ */
24
+ getName(): Promise<string>;
25
+ /**
26
+ * Get version of extension.
27
+ * @returns Promise resolving version of extension.
28
+ */
29
+ getVersion(): Promise<string>;
30
+ /**
31
+ * Get publisher of extension.
32
+ * @returns Promise resolving publisher of extension.
33
+ */
34
+ getPublisher(): Promise<string>;
35
+ /**
36
+ * Get description of extension.
37
+ * @returns Promise description name of opened extension.
38
+ */
39
+ getDescription(): Promise<string>;
40
+ /**
41
+ * Get count of extension.
42
+ * @returns Promise resolving count of opened extension.
43
+ */
44
+ getCount(): Promise<string>;
45
+ /**
46
+ * Get available tabs.
47
+ * @returns Promise resolving tabs of opened extension.
48
+ */
49
+ getTabs(): Promise<string[]>;
50
+ /**
51
+ * Switch to different tab.
52
+ * @param tabName Name of required tab to be switched on.
53
+ * @returns Promise resolving to true if tabs were switched successfully, false otherwise.
54
+ */
55
+ switchToTab(tabName: string): Promise<boolean>;
56
+ /**
57
+ * Get name of opened tab.
58
+ * @returns Promise resolving name of opened tab.
59
+ */
60
+ getActiveTab(): Promise<string>;
61
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License", destination); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ExtensionEditorView = void 0;
20
+ const __1 = require("../..");
21
+ class ExtensionEditorView extends __1.Editor {
22
+ constructor(view = new __1.EditorView()) {
23
+ super(view, ExtensionEditorView.locators.ExtensionEditorView.constructor);
24
+ }
25
+ /**
26
+ * Get name of extension.
27
+ * @returns Promise resolving name of extension.
28
+ */
29
+ async getName() {
30
+ const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.name);
31
+ return await name?.getText();
32
+ }
33
+ /**
34
+ * Get version of extension.
35
+ * @returns Promise resolving version of extension.
36
+ */
37
+ async getVersion() {
38
+ const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.version);
39
+ return await name?.getText();
40
+ }
41
+ /**
42
+ * Get publisher of extension.
43
+ * @returns Promise resolving publisher of extension.
44
+ */
45
+ async getPublisher() {
46
+ const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.publisher);
47
+ return await name?.getText();
48
+ }
49
+ /**
50
+ * Get description of extension.
51
+ * @returns Promise description name of opened extension.
52
+ */
53
+ async getDescription() {
54
+ const name = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.description);
55
+ return await name?.getText();
56
+ }
57
+ /**
58
+ * Get count of extension.
59
+ * @returns Promise resolving count of opened extension.
60
+ */
61
+ async getCount() {
62
+ const count = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.count);
63
+ return await count?.getText();
64
+ }
65
+ /**
66
+ * Get available tabs.
67
+ * @returns Promise resolving tabs of opened extension.
68
+ */
69
+ async getTabs() {
70
+ const tabs = [];
71
+ const navbar = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.navbar);
72
+ const els = await navbar.findElements(ExtensionEditorView.locators.ExtensionEditorView.tab);
73
+ for (const element of els) {
74
+ tabs.push(await element.getText());
75
+ }
76
+ return tabs;
77
+ }
78
+ /**
79
+ * Switch to different tab.
80
+ * @param tabName Name of required tab to be switched on.
81
+ * @returns Promise resolving to true if tabs were switched successfully, false otherwise.
82
+ */
83
+ async switchToTab(tabName) {
84
+ const navbar = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.navbar);
85
+ const requiredTab = await navbar.findElement(ExtensionEditorView.locators.ExtensionEditorView.specificTab(tabName));
86
+ await requiredTab.click();
87
+ return (await this.getActiveTab()).toLowerCase() === tabName.toLowerCase();
88
+ }
89
+ /**
90
+ * Get name of opened tab.
91
+ * @returns Promise resolving name of opened tab.
92
+ */
93
+ async getActiveTab() {
94
+ const navbar = await this.findElement(ExtensionEditorView.locators.ExtensionEditorView.navbar);
95
+ const features = await navbar.findElement(ExtensionEditorView.locators.ExtensionEditorView.activeTab);
96
+ return await features.getText();
97
+ }
98
+ }
99
+ exports.ExtensionEditorView = ExtensionEditorView;
100
+ //# sourceMappingURL=ExtensionEditorView.js.map
@@ -228,6 +228,12 @@ export declare class TextEditor extends Editor {
228
228
  * @returns promise which resolves to either Breakpoint page object or undefined
229
229
  */
230
230
  getPausedBreakpoint(): Promise<Breakpoint | undefined>;
231
+ /**
232
+ * Get paused breakpoint on line if available. Otherwise, return undefined.
233
+ * @param line number of the line to retrieve
234
+ * @returns promise which resolves to either Breakpoint page object or undefined
235
+ */
236
+ getBreakpoint(line: number): Promise<Breakpoint | undefined>;
231
237
  /**
232
238
  * Get all breakpoints.
233
239
  * @returns List of Breakpoints.
@@ -568,6 +568,20 @@ class TextEditor extends Editor_1.Editor {
568
568
  }
569
569
  return new Breakpoint_1.Breakpoint(breakpoints[0], lineElement);
570
570
  }
571
+ /**
572
+ * Get paused breakpoint on line if available. Otherwise, return undefined.
573
+ * @param line number of the line to retrieve
574
+ * @returns promise which resolves to either Breakpoint page object or undefined
575
+ */
576
+ async getBreakpoint(line) {
577
+ const breakpoints = await this.getBreakpoints();
578
+ for (const breakpoint of breakpoints) {
579
+ if ((await breakpoint.getLineNumber()) === line) {
580
+ return breakpoint;
581
+ }
582
+ }
583
+ return undefined;
584
+ }
571
585
  /**
572
586
  * Get all breakpoints.
573
587
  * @returns List of Breakpoints.
@@ -58,17 +58,31 @@ class SingleScmProvider extends ScmView_1.ScmProvider {
58
58
  }
59
59
  async takeAction(title) {
60
60
  const view = this.enclosingItem;
61
- const titlePart = view.getTitlePart();
62
- const elements = await titlePart.findElements(ScmView_1.ScmView.locators.ScmView.action);
61
+ let actions = [];
62
+ let names = [];
63
63
  const buttons = [];
64
- for (const element of elements) {
65
- const title = await element.getAttribute(ScmView_1.ScmView.locators.ScmView.actionLabel);
66
- buttons.push(await new ViewTitlePart_1.TitleActionButton(ScmView_1.ScmView.locators.ScmView.actionConstructor(title), titlePart).wait());
64
+ if (ScmView_1.ScmProvider.versionInfo.version >= '1.93.0') {
65
+ const header = await view.findElement(selenium_webdriver_1.By.xpath(`.//div[@aria-label='Source Control Section']`));
66
+ actions = await header.findElements(ScmView_1.ScmProvider.locators.ScmView.action);
67
+ names = await Promise.all(actions.map(async (action) => await action.getAttribute(ScmView_1.ScmProvider.locators.ScmView.actionLabel)));
67
68
  }
68
- const names = await Promise.all(buttons.map(async (button) => button.getTitle()));
69
- const index = names.findIndex((name) => name === title);
69
+ else {
70
+ const titlePart = view.getTitlePart();
71
+ const elements = await titlePart.findElements(ScmView_1.ScmView.locators.ScmView.action);
72
+ for (const element of elements) {
73
+ const title = await element.getAttribute(ScmView_1.ScmView.locators.ScmView.actionLabel);
74
+ buttons.push(await new ViewTitlePart_1.TitleActionButton(ScmView_1.ScmView.locators.ScmView.actionConstructor(title), titlePart).wait());
75
+ }
76
+ names = await Promise.all(buttons.map(async (button) => button.getTitle()));
77
+ }
78
+ const index = names.findIndex((item) => item === title);
70
79
  if (index > -1) {
71
- await buttons[index].click();
80
+ if (ScmView_1.ScmProvider.versionInfo.version >= '1.93.0') {
81
+ await actions[index].click();
82
+ }
83
+ else {
84
+ await buttons[index].click();
85
+ }
72
86
  return true;
73
87
  }
74
88
  return false;
@@ -31,7 +31,7 @@ export declare class DebugToolbar extends AbstractElement {
31
31
  /**
32
32
  * Wait for the execution to pause at the next breakpoint
33
33
  */
34
- waitForBreakPoint(timeout?: undefined): Promise<void>;
34
+ waitForBreakPoint(timeout?: number): Promise<void>;
35
35
  /**
36
36
  * Click Continue
37
37
  */
@@ -41,7 +41,7 @@ class DebugToolbar extends AbstractElement_1.AbstractElement {
41
41
  /**
42
42
  * Wait for the execution to pause at the next breakpoint
43
43
  */
44
- async waitForBreakPoint(timeout = undefined) {
44
+ async waitForBreakPoint(timeout = 10_000) {
45
45
  let btn = await this.getDriver().wait(selenium_webdriver_1.until.elementLocated(DebugToolbar.locators.DebugToolbar.button('continue')));
46
46
  await this.getDriver().wait(async () => {
47
47
  try {
package/out/index.d.ts CHANGED
@@ -64,6 +64,8 @@ export * from './components/editor/DiffEditor';
64
64
  export * from './components/editor/WebView';
65
65
  export * from './components/editor/ContentAssist';
66
66
  export * from './components/editor/CustomEditor';
67
+ export * from './components/editor/ExtensionEditorView';
68
+ export * from './components/editor/ExtensionEditorDetailsSection';
67
69
  export { Notification, NotificationType } from './components/workbench/Notification';
68
70
  export * from './components/workbench/NotificationsCenter';
69
71
  export * from './components/workbench/input/Input';
package/out/index.js CHANGED
@@ -86,6 +86,8 @@ __exportStar(require("./components/editor/DiffEditor"), exports);
86
86
  __exportStar(require("./components/editor/WebView"), exports);
87
87
  __exportStar(require("./components/editor/ContentAssist"), exports);
88
88
  __exportStar(require("./components/editor/CustomEditor"), exports);
89
+ __exportStar(require("./components/editor/ExtensionEditorView"), exports);
90
+ __exportStar(require("./components/editor/ExtensionEditorDetailsSection"), exports);
89
91
  var Notification_1 = require("./components/workbench/Notification");
90
92
  Object.defineProperty(exports, "Notification", { enumerable: true, get: function () { return Notification_1.Notification; } });
91
93
  Object.defineProperty(exports, "NotificationType", { enumerable: true, get: function () { return Notification_1.NotificationType; } });
@@ -205,6 +205,27 @@ export interface Locators {
205
205
  container: (id: string) => By;
206
206
  attribute: string;
207
207
  };
208
+ ExtensionEditorView: {
209
+ constructor: By;
210
+ name: By;
211
+ version: By;
212
+ publisher: By;
213
+ description: By;
214
+ count: By;
215
+ navbar: By;
216
+ tab: By;
217
+ activeTab: By;
218
+ specificTab: (tabname: string) => By;
219
+ };
220
+ ExtensionEditorDetailsSection: {
221
+ categoriesContainer: By;
222
+ category: By;
223
+ resourcesContainer: By;
224
+ resource: By;
225
+ moreInfoContainer: By;
226
+ moreInfo: By;
227
+ moreInfoElements: By;
228
+ };
208
229
  ContextMenu: {
209
230
  contextView: By;
210
231
  constructor: By;
@@ -24,7 +24,7 @@ exports.fromAttribute = fromAttribute;
24
24
  exports.fromText = fromText;
25
25
  function hasAttribute(attr, value, locator) {
26
26
  return async (el) => {
27
- el = locator ? el.findElement(locator) : el;
27
+ el = locator ? await el.findElement(locator) : el;
28
28
  const attrValue = await el.getAttribute(attr);
29
29
  if (value === undefined) {
30
30
  return attrValue !== null;
@@ -34,7 +34,7 @@ function hasAttribute(attr, value, locator) {
34
34
  }
35
35
  function hasClass(classOrPredicate, locator) {
36
36
  return async (el) => {
37
- el = locator ? el.findElement(locator) : el;
37
+ el = locator ? await el.findElement(locator) : el;
38
38
  const klasses = await el.getAttribute('class');
39
39
  const segments = klasses?.split(/\s+/g);
40
40
  const predicate = typeof classOrPredicate === 'string' ? (klass) => klass === classOrPredicate : classOrPredicate;
@@ -43,7 +43,7 @@ function hasClass(classOrPredicate, locator) {
43
43
  }
44
44
  function hasNotClass(klass, locator) {
45
45
  return async (el) => {
46
- el = locator ? el.findElement(locator) : el;
46
+ el = locator ? await el.findElement(locator) : el;
47
47
  return !(await hasClass(klass).call(undefined, el));
48
48
  };
49
49
  }
@@ -54,14 +54,14 @@ function hasElement(locatorSelector) {
54
54
  }
55
55
  function fromAttribute(attribute, locator) {
56
56
  return async (el) => {
57
- el = locator ? el.findElement(locator) : el;
58
- return el.getAttribute(attribute);
57
+ el = locator ? await el.findElement(locator) : el;
58
+ return await el.getAttribute(attribute);
59
59
  };
60
60
  }
61
61
  function fromText(locator) {
62
62
  return async (el) => {
63
- el = locator ? el.findElement(locator) : el;
64
- return el.getText();
63
+ el = locator ? await el.findElement(locator) : el;
64
+ return await el.getText();
65
65
  };
66
66
  }
67
67
  //# sourceMappingURL=locators.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-developer/page-objects",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "description": "Page Object API implementation for a VS Code editor used by ExTester framework.",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -40,11 +40,12 @@
40
40
  "clipboardy": "^4.0.0",
41
41
  "clone-deep": "^4.0.1",
42
42
  "compare-versions": "^6.1.1",
43
- "fs-extra": "^11.2.0"
43
+ "fs-extra": "^11.2.0",
44
+ "type-fest": "^4.26.1"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "selenium-webdriver": ">=4.6.1",
47
48
  "typescript": ">=4.6.2"
48
49
  },
49
- "gitHead": "977eb7a2de57ba26d6bc4af67b6b0d7d92dc333d"
50
+ "gitHead": "0cc4673eeebfed276b29e6a16ccda8738bca3102"
50
51
  }