@redhat-developer/page-objects 1.4.1 → 1.5.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.
@@ -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;
@@ -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.5.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": "1e2ae6db75e1f18fbc65cae5f4945200a9d93d8d"
50
51
  }