@redhat-developer/page-objects 1.18.1 → 1.19.1
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.
|
@@ -85,6 +85,17 @@ class TextView extends ChannelView {
|
|
|
85
85
|
const textarea = await self.findElement(ChannelView.locators.BottomBarViews.textArea);
|
|
86
86
|
await textarea.sendKeys(selenium_webdriver_1.Key.chord(TextView.ctlKey, 'a'));
|
|
87
87
|
await textarea.sendKeys(selenium_webdriver_1.Key.chord(TextView.ctlKey, 'c'));
|
|
88
|
+
// Wait for clipboard operation to complete
|
|
89
|
+
// Fixes issue https://github.com/redhat-developer/vscode-extension-tester/issues/2214
|
|
90
|
+
await self.getWaitHelper().forCondition(async () => {
|
|
91
|
+
try {
|
|
92
|
+
const currentClip = clipboard.readSync();
|
|
93
|
+
return currentClip !== originalClipboard || currentClip.length > 0;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}, { timeout: 2000, pollInterval: 50, message: 'Clipboard copy operation did not complete' });
|
|
88
99
|
const text = clipboard.readSync();
|
|
89
100
|
// workaround as we are getting "element click intercepted" during the send keys actions.
|
|
90
101
|
// await textarea.click();
|
|
@@ -199,6 +199,13 @@ export declare class TextEditor extends Editor {
|
|
|
199
199
|
* @param timeout
|
|
200
200
|
*/
|
|
201
201
|
private waitForCursorPositionAtColumn;
|
|
202
|
+
/**
|
|
203
|
+
* (private) Find the position of text in the editor.
|
|
204
|
+
* @param text text to search for
|
|
205
|
+
* @param occurrence select which occurrence of the search text to look for in case there are multiple in the document
|
|
206
|
+
* @returns The (line, column) numbers in case the occurrence is found
|
|
207
|
+
*/
|
|
208
|
+
private findTextOccurrence;
|
|
202
209
|
/**
|
|
203
210
|
* Get number of lines in the editor
|
|
204
211
|
* @returns Promise resolving to number of lines
|
|
@@ -223,19 +223,7 @@ class TextEditor extends Editor_1.Editor {
|
|
|
223
223
|
* Returns the line number that holds the last occurrence found this way.
|
|
224
224
|
*/
|
|
225
225
|
async getLineOfText(text, occurrence = 1) {
|
|
226
|
-
|
|
227
|
-
let found = 0;
|
|
228
|
-
const lines = (await this.getText()).split('\n');
|
|
229
|
-
for (let i = 0; i < lines.length; i++) {
|
|
230
|
-
if (lines[i].includes(text)) {
|
|
231
|
-
found++;
|
|
232
|
-
lineNum = i + 1;
|
|
233
|
-
if (found >= occurrence) {
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return lineNum;
|
|
226
|
+
return (await this.findTextOccurrence(text, occurrence))[0];
|
|
239
227
|
}
|
|
240
228
|
/**
|
|
241
229
|
* Find and select a given text. Not usable for multi line selection.
|
|
@@ -244,12 +232,10 @@ class TextEditor extends Editor_1.Editor {
|
|
|
244
232
|
* @param occurrence specify which occurrence of text to select if multiple are present in the document
|
|
245
233
|
*/
|
|
246
234
|
async selectText(text, occurrence = 1) {
|
|
247
|
-
const lineNum = await this.
|
|
235
|
+
const [lineNum, column] = await this.findTextOccurrence(text, occurrence);
|
|
248
236
|
if (lineNum < 1) {
|
|
249
237
|
throw new Error(`Text '${text}' not found`);
|
|
250
238
|
}
|
|
251
|
-
const line = await this.getTextAtLine(lineNum);
|
|
252
|
-
const column = line.indexOf(text) + 1;
|
|
253
239
|
await this.moveCursor(lineNum, column);
|
|
254
240
|
let actions = this.getDriver().actions();
|
|
255
241
|
await actions.clear();
|
|
@@ -492,6 +478,31 @@ class TextEditor extends Editor_1.Editor {
|
|
|
492
478
|
return await this.isColumn(column);
|
|
493
479
|
}, timeout, `Unable to set cursor at column ${column}`, 500);
|
|
494
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* (private) Find the position of text in the editor.
|
|
483
|
+
* @param text text to search for
|
|
484
|
+
* @param occurrence select which occurrence of the search text to look for in case there are multiple in the document
|
|
485
|
+
* @returns The (line, column) numbers in case the occurrence is found
|
|
486
|
+
*/
|
|
487
|
+
async findTextOccurrence(text, occurrence) {
|
|
488
|
+
let line = -1;
|
|
489
|
+
let column = -1;
|
|
490
|
+
let found = 0;
|
|
491
|
+
const lines = (await this.getText()).split('\n');
|
|
492
|
+
for (let i = 0; i < lines.length; i++) {
|
|
493
|
+
let searchIndex = -1; // start at the beginning of the line
|
|
494
|
+
while ((searchIndex = lines[i].indexOf(text, searchIndex)) > -1) {
|
|
495
|
+
found++;
|
|
496
|
+
column = searchIndex + 1;
|
|
497
|
+
line = i + 1;
|
|
498
|
+
if (found >= occurrence) {
|
|
499
|
+
return [line, column];
|
|
500
|
+
}
|
|
501
|
+
searchIndex += text.length;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return [line, column];
|
|
505
|
+
}
|
|
495
506
|
/**
|
|
496
507
|
* Get number of lines in the editor
|
|
497
508
|
* @returns Promise resolving to number of lines
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-developer/page-objects",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.1",
|
|
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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"ui-test"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"clipboardy": "^5.
|
|
40
|
+
"clipboardy": "^5.3.1",
|
|
41
41
|
"clone-deep": "^4.0.1",
|
|
42
42
|
"compare-versions": "^6.1.1",
|
|
43
43
|
"fs-extra": "^11.3.3",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"selenium-webdriver": ">=4.6.1",
|
|
48
48
|
"typescript": ">=4.6.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2348dcd72380e2b62591c3c589f81cd26ed7b76a"
|
|
51
51
|
}
|