@redhat-developer/page-objects 1.10.0 → 1.11.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.
- package/out/components/ActionButtonElementDropdown.d.ts +21 -0
- package/out/components/ActionButtonElementDropdown.js +46 -0
- package/out/components/editor/EditorAction.d.ts +9 -7
- package/out/components/editor/EditorAction.js +9 -39
- package/out/components/sidebar/ViewSection.d.ts +13 -2
- package/out/components/sidebar/ViewSection.js +28 -15
- package/package.json +3 -3
|
@@ -0,0 +1,21 @@
|
|
|
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 { ContextMenu } from './menu/ContextMenu';
|
|
18
|
+
import { AbstractElement } from './AbstractElement';
|
|
19
|
+
export declare abstract class ActionButtonElementDropdown extends AbstractElement {
|
|
20
|
+
open(): Promise<ContextMenu>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.ActionButtonElementDropdown = void 0;
|
|
20
|
+
const ElementWithContextMenu_1 = require("./ElementWithContextMenu");
|
|
21
|
+
const ContextMenu_1 = require("./menu/ContextMenu");
|
|
22
|
+
const selenium_webdriver_1 = require("selenium-webdriver");
|
|
23
|
+
const AbstractElement_1 = require("./AbstractElement");
|
|
24
|
+
class ActionButtonElementDropdown extends AbstractElement_1.AbstractElement {
|
|
25
|
+
async open() {
|
|
26
|
+
await this.click();
|
|
27
|
+
const shadowRootHost = await this.enclosingItem.findElements(selenium_webdriver_1.By.className('shadow-root-host'));
|
|
28
|
+
const actions = this.getDriver().actions();
|
|
29
|
+
await actions.clear();
|
|
30
|
+
await actions.sendKeys(selenium_webdriver_1.Key.ESCAPE).perform();
|
|
31
|
+
if (shadowRootHost.length > 0) {
|
|
32
|
+
if ((await this.getAttribute('aria-expanded')) !== 'true') {
|
|
33
|
+
await this.click();
|
|
34
|
+
}
|
|
35
|
+
const shadowRoot = await shadowRootHost[0].getShadowRoot();
|
|
36
|
+
return new ContextMenu_1.ContextMenu(await shadowRoot.findElement(selenium_webdriver_1.By.className('monaco-menu-container'))).wait();
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await this.click();
|
|
40
|
+
const workbench = await this.getDriver().findElement(ElementWithContextMenu_1.ElementWithContextMenu.locators.Workbench.constructor);
|
|
41
|
+
return new ContextMenu_1.ContextMenu(workbench).wait();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ActionButtonElementDropdown = ActionButtonElementDropdown;
|
|
46
|
+
//# sourceMappingURL=ActionButtonElementDropdown.js.map
|
|
@@ -14,16 +14,18 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
import { ActionButtonElementDropdown } from '../ActionButtonElementDropdown';
|
|
18
|
+
/**
|
|
19
|
+
* Base class for editor actions that provides a common method to get the title.
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class BaseEditorAction extends ActionButtonElementDropdown {
|
|
22
22
|
/**
|
|
23
23
|
* Get text description of the action.
|
|
24
24
|
*/
|
|
25
25
|
getTitle(): Promise<string>;
|
|
26
26
|
}
|
|
27
|
-
export declare class
|
|
28
|
-
|
|
27
|
+
export declare class EditorAction extends BaseEditorAction {
|
|
28
|
+
}
|
|
29
|
+
export declare class EditorActionDropdown extends BaseEditorAction {
|
|
29
30
|
}
|
|
31
|
+
export {};
|
|
@@ -17,52 +17,22 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.EditorActionDropdown = exports.EditorAction = void 0;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
class
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
20
|
+
const ActionButtonElementDropdown_1 = require("../ActionButtonElementDropdown");
|
|
21
|
+
/**
|
|
22
|
+
* Base class for editor actions that provides a common method to get the title.
|
|
23
|
+
*/
|
|
24
|
+
class BaseEditorAction extends ActionButtonElementDropdown_1.ActionButtonElementDropdown {
|
|
26
25
|
/**
|
|
27
26
|
* Get text description of the action.
|
|
28
27
|
*/
|
|
29
28
|
async getTitle() {
|
|
30
|
-
return await this.getAttribute(
|
|
29
|
+
return await this.getAttribute(BaseEditorAction.locators.EditorView.attribute);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
32
|
+
class EditorAction extends BaseEditorAction {
|
|
33
|
+
}
|
|
33
34
|
exports.EditorAction = EditorAction;
|
|
34
|
-
class EditorActionDropdown extends
|
|
35
|
-
async open() {
|
|
36
|
-
await this.click();
|
|
37
|
-
const shadowRootHost = await this.enclosingItem.findElements(EditorAction.locators.EditorAction.shadowRootHost);
|
|
38
|
-
const actions = this.getDriver().actions();
|
|
39
|
-
await actions.clear();
|
|
40
|
-
await actions.sendKeys(__1.Key.ESCAPE).perform();
|
|
41
|
-
const webdriverCapabilities = await this.getDriver().getCapabilities();
|
|
42
|
-
const chromiumVersion = webdriverCapabilities.getBrowserVersion();
|
|
43
|
-
if (shadowRootHost.length > 0) {
|
|
44
|
-
if ((await this.getAttribute('aria-expanded')) !== 'true') {
|
|
45
|
-
await this.click();
|
|
46
|
-
}
|
|
47
|
-
let shadowRoot;
|
|
48
|
-
const webdriverCapabilities = await this.getDriver().getCapabilities();
|
|
49
|
-
const chromiumVersion = webdriverCapabilities.getBrowserVersion();
|
|
50
|
-
if (chromiumVersion && parseInt(chromiumVersion.split('.')[0]) >= 96) {
|
|
51
|
-
shadowRoot = await shadowRootHost[0].getShadowRoot();
|
|
52
|
-
return new __1.ContextMenu(await shadowRoot.findElement(EditorAction.locators.EditorAction.monacoMenuContainer)).wait();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
shadowRoot = (await this.getDriver().executeScript('return arguments[0].shadowRoot', shadowRootHost[0]));
|
|
56
|
-
return new __1.ContextMenu(shadowRoot).wait();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else if (chromiumVersion && parseInt(chromiumVersion.split('.')[0]) >= 100) {
|
|
60
|
-
await this.click();
|
|
61
|
-
const workbench = await this.getDriver().findElement(ElementWithContextMenu_1.ElementWithContextMenu.locators.Workbench.constructor);
|
|
62
|
-
return new __1.ContextMenu(workbench).wait();
|
|
63
|
-
}
|
|
64
|
-
return await super.openContextMenu();
|
|
65
|
-
}
|
|
35
|
+
class EditorActionDropdown extends BaseEditorAction {
|
|
66
36
|
}
|
|
67
37
|
exports.EditorActionDropdown = EditorActionDropdown;
|
|
68
38
|
//# sourceMappingURL=EditorAction.js.map
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { WebElement } from 'selenium-webdriver';
|
|
18
18
|
import { ContextMenu, ViewContent, ViewItem, WelcomeContentSection } from '../..';
|
|
19
19
|
import { AbstractElement } from '../AbstractElement';
|
|
20
|
+
import { ActionButtonElementDropdown } from '../ActionButtonElementDropdown';
|
|
20
21
|
export type ViewSectionConstructor<T extends ViewSection> = {
|
|
21
22
|
new (rootElement: WebElement, tree: ViewContent): T;
|
|
22
23
|
};
|
|
@@ -102,13 +103,23 @@ export declare abstract class ViewSection extends AbstractElement {
|
|
|
102
103
|
private isHeaderHidden;
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
|
-
*
|
|
106
|
+
* Base class for action buttons on view sections.
|
|
107
|
+
* Provides shared functionality for both standard and dropdown actions.
|
|
106
108
|
*/
|
|
107
|
-
|
|
109
|
+
declare abstract class BaseViewPanelAction extends ActionButtonElementDropdown {
|
|
108
110
|
constructor(element: WebElement, viewPart: ViewSection);
|
|
109
111
|
/**
|
|
110
112
|
* Get label of the action button
|
|
111
113
|
*/
|
|
112
114
|
getLabel(): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Wait for the action button to be located within a given timeout.
|
|
117
|
+
* @param timeout Time in milliseconds (default: 1000ms)
|
|
118
|
+
*/
|
|
113
119
|
wait(timeout?: number): Promise<this>;
|
|
114
120
|
}
|
|
121
|
+
export declare class ViewPanelAction extends BaseViewPanelAction {
|
|
122
|
+
}
|
|
123
|
+
export declare class ViewPanelActionDropdown extends BaseViewPanelAction {
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.ViewPanelAction = exports.ViewSection = void 0;
|
|
19
|
+
exports.ViewPanelActionDropdown = exports.ViewPanelAction = exports.ViewSection = void 0;
|
|
20
20
|
const selenium_webdriver_1 = require("selenium-webdriver");
|
|
21
21
|
const __1 = require("../..");
|
|
22
22
|
const AbstractElement_1 = require("../AbstractElement");
|
|
23
23
|
const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
|
|
24
|
+
const ActionButtonElementDropdown_1 = require("../ActionButtonElementDropdown");
|
|
24
25
|
/**
|
|
25
26
|
* Page object representing a collapsible content section of the side bar view
|
|
26
27
|
*/
|
|
@@ -49,6 +50,7 @@ class ViewSection extends AbstractElement_1.AbstractElement {
|
|
|
49
50
|
const collapseExpandButton = await header.findElement(ViewSection.locators.ViewSection.headerCollapseExpandButton);
|
|
50
51
|
await collapseExpandButton.click();
|
|
51
52
|
await this.getDriver().wait((0, __1.waitForAttributeValue)(header, ViewSection.locators.ViewSection.headerExpanded, 'true'), timeout);
|
|
53
|
+
await this.getDriver().sleep(500);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
@@ -64,6 +66,7 @@ class ViewSection extends AbstractElement_1.AbstractElement {
|
|
|
64
66
|
const collapseExpandButton = await header.findElement(ViewSection.locators.ViewSection.headerCollapseExpandButton);
|
|
65
67
|
await collapseExpandButton.click();
|
|
66
68
|
await this.getDriver().wait((0, __1.waitForAttributeValue)(header, ViewSection.locators.ViewSection.headerExpanded, 'false'), timeout);
|
|
69
|
+
await this.getDriver().sleep(500);
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
/**
|
|
@@ -97,16 +100,16 @@ class ViewSection extends AbstractElement_1.AbstractElement {
|
|
|
97
100
|
* @returns Promise resolving to array of ViewPanelAction objects
|
|
98
101
|
*/
|
|
99
102
|
async getActions() {
|
|
100
|
-
const actions =
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for (const element of elements) {
|
|
106
|
-
actions.push(await new ViewPanelAction(element, this).wait());
|
|
103
|
+
const actions = await this.findElement(ViewSection.locators.ViewSection.actions).findElements(ViewSection.locators.ViewSection.button);
|
|
104
|
+
return Promise.all(actions.map(async (action) => {
|
|
105
|
+
const dropdown = await action.getAttribute('aria-haspopup');
|
|
106
|
+
if (dropdown) {
|
|
107
|
+
return new ViewPanelActionDropdown(action, this);
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
else {
|
|
110
|
+
return new ViewPanelAction(action, this);
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
112
115
|
* Retrieve an action button on the sections's header by its label
|
|
@@ -161,9 +164,10 @@ class ViewSection extends AbstractElement_1.AbstractElement {
|
|
|
161
164
|
}
|
|
162
165
|
exports.ViewSection = ViewSection;
|
|
163
166
|
/**
|
|
164
|
-
*
|
|
167
|
+
* Base class for action buttons on view sections.
|
|
168
|
+
* Provides shared functionality for both standard and dropdown actions.
|
|
165
169
|
*/
|
|
166
|
-
class
|
|
170
|
+
class BaseViewPanelAction extends ActionButtonElementDropdown_1.ActionButtonElementDropdown {
|
|
167
171
|
constructor(element, viewPart) {
|
|
168
172
|
super(element, viewPart);
|
|
169
173
|
}
|
|
@@ -171,12 +175,21 @@ class ViewPanelAction extends AbstractElement_1.AbstractElement {
|
|
|
171
175
|
* Get label of the action button
|
|
172
176
|
*/
|
|
173
177
|
async getLabel() {
|
|
174
|
-
return await this.getAttribute(
|
|
178
|
+
return await this.getAttribute(BaseViewPanelAction.locators.ViewSection.buttonLabel);
|
|
175
179
|
}
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Wait for the action button to be located within a given timeout.
|
|
182
|
+
* @param timeout Time in milliseconds (default: 1000ms)
|
|
183
|
+
*/
|
|
184
|
+
async wait(timeout = 1_000) {
|
|
185
|
+
await this.getDriver().wait(selenium_webdriver_1.until.elementLocated(BaseViewPanelAction.locators.ViewSection.actions), timeout);
|
|
178
186
|
return this;
|
|
179
187
|
}
|
|
180
188
|
}
|
|
189
|
+
class ViewPanelAction extends BaseViewPanelAction {
|
|
190
|
+
}
|
|
181
191
|
exports.ViewPanelAction = ViewPanelAction;
|
|
192
|
+
class ViewPanelActionDropdown extends BaseViewPanelAction {
|
|
193
|
+
}
|
|
194
|
+
exports.ViewPanelActionDropdown = ViewPanelActionDropdown;
|
|
182
195
|
//# sourceMappingURL=ViewSection.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-developer/page-objects",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.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",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"clone-deep": "^4.0.1",
|
|
42
42
|
"compare-versions": "^6.1.1",
|
|
43
43
|
"fs-extra": "^11.3.0",
|
|
44
|
-
"type-fest": "^4.
|
|
44
|
+
"type-fest": "^4.35.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"selenium-webdriver": ">=4.6.1",
|
|
48
48
|
"typescript": ">=4.6.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "bf17db769fb699fe9a47325ff6e0c94dc821ae0f"
|
|
51
51
|
}
|