@redhat-developer/page-objects 1.9.0 → 1.10.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.
@@ -20,6 +20,7 @@ exports.ViewControl = void 0;
20
20
  const __1 = require("../..");
21
21
  const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
22
22
  const NewScmView_1 = require("../sidebar/scm/NewScmView");
23
+ const compare_versions_1 = require("compare-versions");
23
24
  /**
24
25
  * Page object representing a view container item in the activity bar
25
26
  */
@@ -40,7 +41,7 @@ class ViewControl extends ElementWithContextMenu_1.ElementWithContextMenu {
40
41
  }
41
42
  const view = await new __1.SideBarView().wait();
42
43
  if ((await view.findElements(ViewControl.locators.ViewControl.scmId)).length > 0) {
43
- if (ViewControl.versionInfo.browser === 'vscode' && ViewControl.versionInfo.version >= '1.47.0') {
44
+ if (ViewControl.versionInfo.browser === 'vscode' && (0, compare_versions_1.satisfies)(ViewControl.versionInfo.version, '>=1.47.0')) {
44
45
  return new NewScmView_1.NewScmView().wait();
45
46
  }
46
47
  return new __1.ScmView().wait();
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.TextView = exports.ChannelView = void 0;
20
20
  const selenium_webdriver_1 = require("selenium-webdriver");
21
21
  const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
22
+ const compare_versions_1 = require("compare-versions");
22
23
  /**
23
24
  * View with channel selector
24
25
  */
@@ -45,7 +46,7 @@ class ChannelView extends ElementWithContextMenu_1.ElementWithContextMenu {
45
46
  * @deprecated For VS Code 1.88+ this method won't be working any more
46
47
  */
47
48
  async getCurrentChannel() {
48
- if (ChannelView.versionInfo.version >= '1.87.0' && process.platform !== 'darwin') {
49
+ if ((0, compare_versions_1.compareVersions)(ChannelView.versionInfo.version, '1.87.0') >= 0 && process.platform !== 'darwin') {
49
50
  throw Error(`DEPRECATED METHOD! The 'ChannelView.getCurrentChannel' method is broken! Read more information in 'Known Issues > Limitations in testing with VS Code 1.87+' - https://github.com/microsoft/vscode/issues/206897.`);
50
51
  }
51
52
  const combo = await this.enclosingItem.findElement(ChannelView.locators.BottomBarViews.channelCombo);
@@ -57,7 +57,13 @@ export declare class BottomBarPanel extends AbstractElement {
57
57
  * @returns Promise resolving when the restore button is pressed
58
58
  */
59
59
  restore(): Promise<void>;
60
- private openTab;
60
+ /**
61
+ * Opens (or focuses) a tab in the bottom bar panel by its title.
62
+ *
63
+ * @param title The exact name of the tab to be opened or focused.
64
+ * @returns A promise that resolves when the tab is opened or focused.
65
+ */
66
+ openTab(title: string): Promise<void>;
61
67
  private resize;
62
68
  closePanel(): Promise<void>;
63
69
  }
@@ -99,6 +99,12 @@ class BottomBarPanel extends AbstractElement_1.AbstractElement {
99
99
  async restore() {
100
100
  await this.resize(BottomBarPanel.locators.BottomBarPanel.restore);
101
101
  }
102
+ /**
103
+ * Opens (or focuses) a tab in the bottom bar panel by its title.
104
+ *
105
+ * @param title The exact name of the tab to be opened or focused.
106
+ * @returns A promise that resolves when the tab is opened or focused.
107
+ */
102
108
  async openTab(title) {
103
109
  await this.toggle(true);
104
110
  const tabContainer = await this.findElement(BottomBarPanel.locators.BottomBarPanel.tabContainer);
@@ -21,11 +21,12 @@ const Editor_1 = require("./Editor");
21
21
  const selenium_webdriver_1 = require("selenium-webdriver");
22
22
  const AbstractElement_1 = require("../AbstractElement");
23
23
  const __1 = require("../..");
24
+ const compare_versions_1 = require("compare-versions");
24
25
  /**
25
26
  * Page object representing the internal VS Code settings editor
26
27
  */
27
28
  class SettingsEditor extends Editor_1.Editor {
28
- divider = SettingsEditor.versionInfo.version >= '1.83.0' ? '›' : ' › ';
29
+ divider = (0, compare_versions_1.satisfies)(SettingsEditor.versionInfo.version, '>=1.83.0') ? '›' : ' › ';
29
30
  constructor(view = new __1.EditorView()) {
30
31
  super(view);
31
32
  }
@@ -25,6 +25,7 @@ const Editor_1 = require("./Editor");
25
25
  const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
26
26
  const AbstractElement_1 = require("../AbstractElement");
27
27
  const Breakpoint_1 = require("./Breakpoint");
28
+ const compare_versions_1 = require("compare-versions");
28
29
  class BreakpointError extends Error {
29
30
  }
30
31
  exports.BreakpointError = BreakpointError;
@@ -524,7 +525,9 @@ class TextEditor extends Editor_1.Editor {
524
525
  const lineNum = await margin.findElement(TextEditor.locators.TextEditor.lineNumber(line));
525
526
  await this.getDriver().actions().move({ origin: lineNum }).perform();
526
527
  const lineOverlay = await margin.findElement(TextEditor.locators.TextEditor.lineOverlay(line));
527
- const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(TextEditor.locators.TextEditor.glyphMarginWidget) : lineOverlay;
528
+ const breakpointContainer = (0, compare_versions_1.satisfies)(TextEditor.versionInfo.version, '>=1.80.0')
529
+ ? await this.findElement(TextEditor.locators.TextEditor.glyphMarginWidget)
530
+ : lineOverlay;
528
531
  const breakPoint = await breakpointContainer.findElements(TextEditor.locators.TextEditor.breakpoint.generalSelector);
529
532
  if (breakPoint.length > 0) {
530
533
  if (this.breakPoints.indexOf(line) !== -1) {
@@ -549,7 +552,9 @@ class TextEditor extends Editor_1.Editor {
549
552
  */
550
553
  async getPausedBreakpoint() {
551
554
  const breakpointLocators = Breakpoint_1.Breakpoint.locators.TextEditor.breakpoint;
552
- const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(TextEditor.locators.TextEditor.glyphMarginWidget) : this;
555
+ const breakpointContainer = (0, compare_versions_1.satisfies)(TextEditor.versionInfo.version, '>=1.80.0')
556
+ ? await this.findElement(TextEditor.locators.TextEditor.glyphMarginWidget)
557
+ : this;
553
558
  const breakpoints = await breakpointContainer.findElements(breakpointLocators.pauseSelector);
554
559
  if (breakpoints.length === 0) {
555
560
  return undefined;
@@ -559,7 +564,7 @@ class TextEditor extends Editor_1.Editor {
559
564
  }
560
565
  // get parent
561
566
  let lineElement;
562
- if (TextEditor.versionInfo.version >= '1.80.0') {
567
+ if ((0, compare_versions_1.satisfies)(TextEditor.versionInfo.version, '>=1.80.0')) {
563
568
  const styleTopAttr = await breakpoints[0].getCssValue('top');
564
569
  lineElement = await this.findElement(TextEditor.locators.TextEditor.marginArea).findElement(TextEditor.locators.TextEditor.lineElement(styleTopAttr));
565
570
  }
@@ -589,11 +594,13 @@ class TextEditor extends Editor_1.Editor {
589
594
  async getBreakpoints() {
590
595
  const breakpoints = [];
591
596
  const breakpointLocators = Breakpoint_1.Breakpoint.locators.TextEditor.breakpoint;
592
- const breakpointContainer = TextEditor.versionInfo.version >= '1.80.0' ? await this.findElement(TextEditor.locators.TextEditor.glyphMarginWidget) : this;
597
+ const breakpointContainer = (0, compare_versions_1.satisfies)(TextEditor.versionInfo.version, '>=1.80.0')
598
+ ? await this.findElement(TextEditor.locators.TextEditor.glyphMarginWidget)
599
+ : this;
593
600
  const breakpointsSelectors = await breakpointContainer.findElements(breakpointLocators.generalSelector);
594
601
  for (const breakpointSelector of breakpointsSelectors) {
595
602
  let lineElement;
596
- if (TextEditor.versionInfo.version >= '1.80.0') {
603
+ if ((0, compare_versions_1.satisfies)(TextEditor.versionInfo.version, '>=1.80.0')) {
597
604
  const styleTopAttr = await breakpointSelector.getCssValue('top');
598
605
  lineElement = await this.findElement(TextEditor.locators.TextEditor.marginArea).findElement(TextEditor.locators.TextEditor.lineElement(styleTopAttr));
599
606
  }
@@ -767,7 +774,7 @@ class FindWidget extends AbstractElement_1.AbstractElement {
767
774
  * Close the widget.
768
775
  */
769
776
  async close() {
770
- const part = TextEditor.versionInfo.version >= '1.80.0' ? 'close' : 'find';
777
+ const part = (0, compare_versions_1.satisfies)(TextEditor.versionInfo.version, '>=1.80.0') ? 'close' : 'find';
771
778
  await this.clickButton('Close', part);
772
779
  }
773
780
  /**
@@ -34,12 +34,12 @@ export declare abstract class ViewSection extends AbstractElement {
34
34
  * Expand the section if collapsed
35
35
  * @returns Promise resolving when the section is expanded
36
36
  */
37
- expand(): Promise<void>;
37
+ expand(timeout?: number): Promise<void>;
38
38
  /**
39
39
  * Collapse the section if expanded
40
40
  * @returns Promise resolving when the section is collapsed
41
41
  */
42
- collapse(): Promise<void>;
42
+ collapse(timeout?: number): Promise<void>;
43
43
  /**
44
44
  * Finds whether the section is expanded
45
45
  * @returns Promise resolving to true/false
@@ -40,28 +40,30 @@ class ViewSection extends AbstractElement_1.AbstractElement {
40
40
  * Expand the section if collapsed
41
41
  * @returns Promise resolving when the section is expanded
42
42
  */
43
- async expand() {
43
+ async expand(timeout = 1_000) {
44
44
  if (await this.isHeaderHidden()) {
45
45
  return;
46
46
  }
47
47
  if (!(await this.isExpanded())) {
48
- const panel = await this.findElement(ViewSection.locators.ViewSection.header);
49
- await panel.click();
50
- await this.getDriver().wait((0, __1.waitForAttributeValue)(panel, ViewSection.locators.ViewSection.headerExpanded, 'true'), 1000);
48
+ const header = await this.findElement(ViewSection.locators.ViewSection.header);
49
+ const collapseExpandButton = await header.findElement(ViewSection.locators.ViewSection.headerCollapseExpandButton);
50
+ await collapseExpandButton.click();
51
+ await this.getDriver().wait((0, __1.waitForAttributeValue)(header, ViewSection.locators.ViewSection.headerExpanded, 'true'), timeout);
51
52
  }
52
53
  }
53
54
  /**
54
55
  * Collapse the section if expanded
55
56
  * @returns Promise resolving when the section is collapsed
56
57
  */
57
- async collapse() {
58
+ async collapse(timeout = 1_000) {
58
59
  if (await this.isHeaderHidden()) {
59
60
  return;
60
61
  }
61
62
  if (await this.isExpanded()) {
62
- const panel = await this.findElement(ViewSection.locators.ViewSection.header);
63
- await panel.click();
64
- await this.getDriver().wait((0, __1.waitForAttributeValue)(panel, ViewSection.locators.ViewSection.headerExpanded, 'false'), 1000);
63
+ const header = await this.findElement(ViewSection.locators.ViewSection.header);
64
+ const collapseExpandButton = await header.findElement(ViewSection.locators.ViewSection.headerCollapseExpandButton);
65
+ await collapseExpandButton.click();
66
+ await this.getDriver().wait((0, __1.waitForAttributeValue)(header, ViewSection.locators.ViewSection.headerExpanded, 'false'), timeout);
65
67
  }
66
68
  }
67
69
  /**
@@ -46,13 +46,19 @@ export declare class WelcomeContentButton extends AbstractElement {
46
46
  export declare class WelcomeContentSection extends AbstractElement {
47
47
  /**
48
48
  * @param panel The panel containing the welcome content.
49
- * @param parent The webelement in which the welcome content is embedded.
49
+ * @param parent The webElement in which the welcome content is embedded.
50
50
  */
51
51
  constructor(panel: WebElement, parent: ViewSection);
52
52
  /**
53
53
  * Combination of [[getButtons]] and [[getTextSections]]: returns all entries in the welcome view in the order that they appear.
54
54
  */
55
55
  getContents(): Promise<(WelcomeContentButton | string)[]>;
56
+ /**
57
+ * Returns a specific button from the welcome view that matches the given title.
58
+ * @param title The title of the button to search for.
59
+ * @returns A `WelcomeContentButton` if found, otherwise `undefined`.
60
+ */
61
+ getButton(title: string): Promise<WelcomeContentButton | undefined>;
56
62
  /** Finds all buttons in the welcome content */
57
63
  getButtons(): Promise<WelcomeContentButton[]>;
58
64
  /**
@@ -52,7 +52,7 @@ exports.WelcomeContentButton = WelcomeContentButton;
52
52
  class WelcomeContentSection extends AbstractElement_1.AbstractElement {
53
53
  /**
54
54
  * @param panel The panel containing the welcome content.
55
- * @param parent The webelement in which the welcome content is embedded.
55
+ * @param parent The webElement in which the welcome content is embedded.
56
56
  */
57
57
  constructor(panel, parent) {
58
58
  super(panel, parent);
@@ -72,6 +72,20 @@ class WelcomeContentSection extends AbstractElement_1.AbstractElement {
72
72
  }
73
73
  }));
74
74
  }
75
+ /**
76
+ * Returns a specific button from the welcome view that matches the given title.
77
+ * @param title The title of the button to search for.
78
+ * @returns A `WelcomeContentButton` if found, otherwise `undefined`.
79
+ */
80
+ async getButton(title) {
81
+ const buttons = await this.getButtons();
82
+ for (const btn of buttons) {
83
+ if ((await btn.getTitle()) === title) {
84
+ return btn;
85
+ }
86
+ }
87
+ return undefined;
88
+ }
75
89
  /** Finds all buttons in the welcome content */
76
90
  async getButtons() {
77
91
  return (await this.findElements(WelcomeContentSection.locators.WelcomeContent.button)).map((elem) => new WelcomeContentButton(elem, this));
@@ -17,6 +17,7 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.DebugView = void 0;
20
+ const compare_versions_1 = require("compare-versions");
20
21
  const SideBarView_1 = require("../SideBarView");
21
22
  const DebugBreakpointSection_1 = require("../tree/debug/DebugBreakpointSection");
22
23
  const DebugCallStackSection_1 = require("../tree/debug/DebugCallStackSection");
@@ -32,7 +33,7 @@ class DebugView extends SideBarView_1.SideBarView {
32
33
  * @deprecated For VS Code 1.88+ this method won't be working any more
33
34
  */
34
35
  async getLaunchConfiguration() {
35
- if (DebugView.versionInfo.version >= '1.87.0' && process.platform !== 'darwin') {
36
+ if ((0, compare_versions_1.satisfies)(DebugView.versionInfo.version, '>=1.87.0') && process.platform !== 'darwin') {
36
37
  throw Error(`DEPRECATED METHOD! The 'DebugView.getLaunchConfiguration' method is broken! Read more information in 'Known Issues > Limitations in testing with VS Code 1.87+' - https://github.com/microsoft/vscode/issues/206897.`);
37
38
  }
38
39
  const action = await this.getTitlePart().findElement(DebugView.locators.DebugView.launchCombo);
@@ -21,6 +21,7 @@ const ScmView_1 = require("./ScmView");
21
21
  const selenium_webdriver_1 = require("selenium-webdriver");
22
22
  const ElementWithContextMenu_1 = require("../../ElementWithContextMenu");
23
23
  const ViewTitlePart_1 = require("../ViewTitlePart");
24
+ const compare_versions_1 = require("compare-versions");
24
25
  /**
25
26
  * New SCM view for code 1.47 onwards
26
27
  */
@@ -61,7 +62,7 @@ class SingleScmProvider extends ScmView_1.ScmProvider {
61
62
  let actions = [];
62
63
  let names = [];
63
64
  const buttons = [];
64
- if (ScmView_1.ScmProvider.versionInfo.version >= '1.93.0') {
65
+ if ((0, compare_versions_1.satisfies)(ScmView_1.ScmProvider.versionInfo.version, '>=1.93.0')) {
65
66
  const header = await view.findElement(ScmView_1.ScmView.locators.ScmView.sourceControlSection);
66
67
  actions = await header.findElements(ScmView_1.ScmProvider.locators.ScmView.action);
67
68
  names = await Promise.all(actions.map(async (action) => await action.getAttribute(ScmView_1.ScmProvider.locators.ScmView.actionLabel)));
@@ -77,7 +78,7 @@ class SingleScmProvider extends ScmView_1.ScmProvider {
77
78
  }
78
79
  const index = names.findIndex((item) => item === title);
79
80
  if (index > -1) {
80
- if (ScmView_1.ScmProvider.versionInfo.version >= '1.93.0') {
81
+ if ((0, compare_versions_1.satisfies)(ScmView_1.ScmProvider.versionInfo.version, '>=1.93.0')) {
81
82
  await actions[index].click();
82
83
  }
83
84
  else {
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.VariableSectionItem = void 0;
20
20
  const selenium_webdriver_1 = require("selenium-webdriver");
21
21
  const CustomTreeItem_1 = require("../custom/CustomTreeItem");
22
+ const compare_versions_1 = require("compare-versions");
22
23
  class VariableSectionItem extends CustomTreeItem_1.CustomTreeItem {
23
24
  constructor(element, viewPart) {
24
25
  super(element, viewPart);
@@ -45,7 +46,7 @@ class VariableSectionItem extends CustomTreeItem_1.CustomTreeItem {
45
46
  * @deprecated For VS Code 1.88+ this method won't be working any more
46
47
  */
47
48
  async getVariableNameTooltip() {
48
- if (VariableSectionItem.versionInfo.version >= '1.88.0') {
49
+ if ((0, compare_versions_1.satisfies)(VariableSectionItem.versionInfo.version, '>=1.88.0')) {
49
50
  throw Error(`DEPRECATED METHOD! For VS Code 1.88+ this method won't be working any more.`);
50
51
  }
51
52
  const name = await this.findElement(VariableSectionItem.locators.VariableSectionItem.name.constructor);
@@ -57,7 +58,7 @@ class VariableSectionItem extends CustomTreeItem_1.CustomTreeItem {
57
58
  * @deprecated For VS Code 1.89+ this method won't be working any more
58
59
  */
59
60
  async getVariableValueTooltip() {
60
- if (VariableSectionItem.versionInfo.version >= '1.89.0') {
61
+ if ((0, compare_versions_1.satisfies)(VariableSectionItem.versionInfo.version, '>=1.89.0')) {
61
62
  throw Error(`DEPRECATED METHOD! For VS Code 1.89+ this method won't be working any more.`);
62
63
  }
63
64
  const value = await this.findElement(VariableSectionItem.locators.VariableSectionItem.value.constructor);
@@ -20,6 +20,7 @@ exports.CenterNotification = exports.StandaloneNotification = exports.Notificati
20
20
  const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
21
21
  const AbstractElement_1 = require("../AbstractElement");
22
22
  const selenium_webdriver_1 = require("selenium-webdriver");
23
+ const compare_versions_1 = require("compare-versions");
23
24
  /**
24
25
  * Available types of notifications
25
26
  */
@@ -63,7 +64,7 @@ class Notification extends ElementWithContextMenu_1.ElementWithContextMenu {
63
64
  * @deprecated For VS Code 1.88+ this method won't be working any more
64
65
  */
65
66
  async getSource() {
66
- if (Notification.versionInfo.version >= '1.88.0') {
67
+ if ((0, compare_versions_1.satisfies)(Notification.versionInfo.version, '>=1.88.0')) {
67
68
  throw Error(`DEPRECATED METHOD! For VS Code 1.88+ this method won't be working any more.`);
68
69
  }
69
70
  await this.expand();
@@ -29,6 +29,7 @@ const Notification_1 = require("./Notification");
29
29
  const QuickOpenBox_1 = require("./input/QuickOpenBox");
30
30
  const SettingsEditor_1 = require("../editor/SettingsEditor");
31
31
  const InputBox_1 = require("./input/InputBox");
32
+ const compare_versions_1 = require("compare-versions");
32
33
  /**
33
34
  * Handler for general workbench related actions
34
35
  */
@@ -125,7 +126,7 @@ class Workbench extends AbstractElement_1.AbstractElement {
125
126
  }
126
127
  const driver = this.getDriver();
127
128
  await driver.actions().keyDown(Workbench.ctlKey).keyDown(selenium_webdriver_1.Key.SHIFT).sendKeys('p').perform();
128
- if (Workbench.versionInfo.version >= '1.44.0') {
129
+ if ((0, compare_versions_1.satisfies)(Workbench.versionInfo.version, '>=1.44.0')) {
129
130
  return await InputBox_1.InputBox.create();
130
131
  }
131
132
  return await QuickOpenBox_1.QuickOpenBox.create();
@@ -288,6 +288,7 @@ export interface Locators {
288
288
  titleText: string;
289
289
  header: By;
290
290
  headerExpanded: string;
291
+ headerCollapseExpandButton: By;
291
292
  actions: By;
292
293
  actionConstructor: (label: string) => By;
293
294
  button: By;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-developer/page-objects",
3
- "version": "1.9.0",
3
+ "version": "1.10.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,12 +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",
44
- "type-fest": "^4.31.0"
43
+ "fs-extra": "^11.3.0",
44
+ "type-fest": "^4.34.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "selenium-webdriver": ">=4.6.1",
48
48
  "typescript": ">=4.6.2"
49
49
  },
50
- "gitHead": "ee887332c09744c7446d3182f6ae3946c2b5a050"
50
+ "gitHead": "eaf266f43e1dca66cb0d660ecbf8f59e56af4808"
51
51
  }