Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek committed Apr 10, 2024
1 parent df2d32d commit cb556ab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
5 changes: 5 additions & 0 deletions packages/locators/lib/1.88.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export const diff: LocatorDiff = {
FindWidget: {
toggleReplace: By.xpath(`.//div[@aria-label="Toggle Replace"]`),
button: (title: string) => By.xpath(`.//div[@role='button' and starts-with(@aria-label, "${title}")]`)
},
SettingsEditor: {
comboSetting: By.css('select'),
comboOption: By.css(`option`),
comboValue: 'value'
}
}
}
47 changes: 26 additions & 21 deletions packages/page-objects/src/components/editor/SettingsEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class ComboSetting extends Setting {
const rows = await this.getOptions();
for (let row of rows) {
if ((await row.getAttribute('class')).indexOf('disabled') < 0) {
const text = await (await row.findElement(SettingsEditor.locators.SettingsEditor.comboOption)).getText();
const text = await row.getAttribute(SettingsEditor.locators.SettingsEditor.comboValue);
if (value === text) {
return await row.click();
}
Expand All @@ -219,34 +219,39 @@ export class ComboSetting extends Setting {
const rows = await this.getOptions();

for (const row of rows) {
values.push(await (await row.findElement(SettingsEditor.locators.SettingsEditor.comboOption)).getText())
// values.push(await (await row.findElement(SettingsEditor.locators.SettingsEditor.comboOption)).getText())
values.push(await row.getAttribute(SettingsEditor.locators.SettingsEditor.comboValue));
}
return values;
}

private async getOptions(): Promise<WebElement[]> {
const menu = await this.openCombo();
return await menu.findElements(SettingsEditor.locators.SettingsEditor.itemRow);
}
// const menu = await this.openCombo();
// return await menu.findElements(SettingsEditor.locators.SettingsEditor.itemRow);

private async openCombo(): Promise<WebElement> {
const combo = await this.findElement(SettingsEditor.locators.SettingsEditor.comboSetting);
const workbench = await this.getDriver().findElement(SettingsEditor.locators.Workbench.constructor);
const menus = await workbench.findElements(SettingsEditor.locators.ContextMenu.contextView);
let menu!: WebElement;

if (menus.length < 1) {
await combo.click();
menu = await workbench.findElement(SettingsEditor.locators.ContextMenu.contextView);
return menu;
} else if (await menus[0].isDisplayed()) {
await combo.click();
await this.getDriver().sleep(200);
}
await combo.click();
menu = await workbench.findElement(SettingsEditor.locators.ContextMenu.contextView);
return menu;

return await combo.findElements(SettingsEditor.locators.SettingsEditor.comboOption);
}

// private async openCombo(): Promise<WebElement> {
// const combo = await this.findElement(SettingsEditor.locators.SettingsEditor.comboSetting);
// const workbench = await this.getDriver().findElement(SettingsEditor.locators.Workbench.constructor);
// const menus = await workbench.findElements(SettingsEditor.locators.ContextMenu.contextView);
// let menu!: WebElement;

// if (menus.length < 1) {
// await combo.click();
// menu = await workbench.findElement(SettingsEditor.locators.ContextMenu.contextView);
// return menu;
// } else if (await menus[0].isDisplayed()) {
// await combo.click();
// await this.getDriver().sleep(200);
// }
// await combo.click();
// menu = await workbench.findElement(SettingsEditor.locators.ContextMenu.contextView);
// return menu;
// }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/test-project/src/test/editor/settingsEditor.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { SettingsEditor, Workbench, EditorView, ComboSetting, TextSetting, CheckboxSetting } from 'vscode-extension-tester';

describe('Settings Editor', function () {
describe.only('Settings Editor', function () {
let editor: SettingsEditor;

before(async function () {
Expand Down

0 comments on commit cb556ab

Please sign in to comment.