diff --git a/locators/lib/1.37.0.ts b/locators/lib/1.37.0.ts index af10640cd..a71673827 100644 --- a/locators/lib/1.37.0.ts +++ b/locators/lib/1.37.0.ts @@ -422,7 +422,8 @@ const input = { quickPickSelectAll: By.className('quick-input-check-all'), titleBar: By.className('quick-input-titlebar'), title: By.className('quick-input-title'), - backButton: By.className('codicon-quick-input-back') + backButton: By.className('codicon-quick-input-back'), + multiSelectIndex: (index: number) => By.xpath(`.//div[@role='treeitem' and @data-index='${index}']`) }, InputBox: { constructor: By.className('quick-input-widget'), diff --git a/locators/lib/1.43.0.ts b/locators/lib/1.43.0.ts index f32fdc0ec..36a1f0d4e 100644 --- a/locators/lib/1.43.0.ts +++ b/locators/lib/1.43.0.ts @@ -4,7 +4,9 @@ import { By } from "selenium-webdriver"; export const diff: LocatorDiff = { locators: { Input: { - quickPickIndex: (index: number) => By.xpath(`.//div[@role='listitem' and @data-index='${index}']`) + quickPickIndex: (index: number) => By.xpath(`.//div[@role='listitem' and @data-index='${index}']`), + multiSelectIndex: (index: number) => By.xpath(`.//div[@role='listitem' and @data-index='${index}']`) + }, NotificationsCenter: { close: By.className('codicon-chevron-down') diff --git a/locators/lib/1.44.0.ts b/locators/lib/1.44.0.ts index 664b2e9fd..3ffa3a6d5 100644 --- a/locators/lib/1.44.0.ts +++ b/locators/lib/1.44.0.ts @@ -4,7 +4,8 @@ import { By } from "selenium-webdriver"; export const diff: LocatorDiff = { locators: { Input: { - quickPickIndex: (index: number) => By.xpath(`.//div[@role='option' and @data-index='${index}']`) + quickPickIndex: (index: number) => By.xpath(`.//div[@role='option' and @data-index='${index}']`), + multiSelectIndex: (index: number) => By.xpath(`.//div[@role='option' and @data-index='${index}']`) } } } \ No newline at end of file diff --git a/locators/lib/1.76.0.ts b/locators/lib/1.76.0.ts index 6e5dcfc41..6f317383f 100644 --- a/locators/lib/1.76.0.ts +++ b/locators/lib/1.76.0.ts @@ -1,4 +1,6 @@ import { LocatorDiff } from "monaco-page-objects"; +import { By } from "selenium-webdriver"; + export const diff: LocatorDiff = { locators: { EditorView: { @@ -6,6 +8,9 @@ export const diff: LocatorDiff = { }, TreeItem: { actionTitle: 'aria-label' + }, + Input: { + multiSelectIndex: (index: number) => By.xpath(`.//div[@role='checkbox' and @data-index='${index}']`) } } } diff --git a/page-objects/src/components/workbench/input/Input.ts b/page-objects/src/components/workbench/input/Input.ts index 1109db5a8..75f3c51c4 100644 --- a/page-objects/src/components/workbench/input/Input.ts +++ b/page-objects/src/components/workbench/input/Input.ts @@ -225,11 +225,16 @@ export abstract class Input extends AbstractElement { export class QuickPickItem extends AbstractElement { private index: number; - constructor(index: number, input: Input) { + constructor(index: number, input: Input, isMultiSelect = false) { let locator = Input.locators.Input.quickPickIndex(index); if (input instanceof QuickOpenBox) { locator = Input.locators.Input.quickPickPosition(index); } + + if (isMultiSelect) { + locator = Input.locators.Input.multiSelectIndex(index); + } + super(locator, input); this.index = index; } diff --git a/page-objects/src/components/workbench/input/InputBox.ts b/page-objects/src/components/workbench/input/InputBox.ts index 491d9df93..8e2f78a05 100644 --- a/page-objects/src/components/workbench/input/InputBox.ts +++ b/page-objects/src/components/workbench/input/InputBox.ts @@ -46,6 +46,21 @@ export class InputBox extends Input { return picks; } + async getCheckboxes(): Promise { + const picks: QuickPickItem[] = []; + const elements = await this.findElement(InputBox.locators.InputBox.quickList) + .findElement(InputBox.locators.InputBox.rows) + .findElements(InputBox.locators.InputBox.row); + + for (const element of elements) { + if (await element.isDisplayed()) { + picks.push(await new QuickPickItem(+await element.getAttribute('data-index'), this, true).wait()); + } + } + + return picks; + } + /** * Find whether the input is showing an error * @returns Promise resolving to notification message diff --git a/page-objects/src/locators/locators.ts b/page-objects/src/locators/locators.ts index 2ded5ad9c..26c1ef9be 100644 --- a/page-objects/src/locators/locators.ts +++ b/page-objects/src/locators/locators.ts @@ -422,7 +422,8 @@ export interface Locators { quickPickSelectAll: By, titleBar: By, title: By, - backButton: By + backButton: By, + multiSelectIndex: (index: number) => By } InputBox: { constructor: By diff --git a/test/test-project/src/test/workbench/input-test.ts b/test/test-project/src/test/workbench/input-test.ts index d3e73c187..bf4c5cf46 100644 --- a/test/test-project/src/test/workbench/input-test.ts +++ b/test/test-project/src/test/workbench/input-test.ts @@ -108,7 +108,7 @@ describe('QuickPickItem', () => { }); }); -describe('InputBox', () => { +describe.only('InputBox', () => { let input: InputBox; before(async function () { @@ -186,4 +186,12 @@ describe('Multiple selection input', () => { const checkbox = await input.findElement(By.css('input')); expect(await checkbox.isSelected()).is.false; }); + + it('allows retrieving quickpicks', async () => { + const [first] = await input.getCheckboxes(); + expect(await first.getText()).equals('test1'); + await first.select(); + const checkbox = await first.findElement(By.css('input')); + expect(await checkbox.isSelected()).is.true; + }); }); \ No newline at end of file