提交 ee9d0246 编写于 作者: S Sandeep Somavarapu

Smoke tests: Fix in Windows

上级 1d9ecf07
......@@ -18,15 +18,15 @@ export class Extensions extends Viewlet {
}
public async waitForExtensionsViewlet(): Promise<any> {
await this.spectron.client.waitForElement('div.extensions-viewlet[id="workbench.view.extensions"] .search-box.synthetic-focus[placeholder="Search Extensions in Marketplace"]');
await this.spectron.client.waitForElement('div.extensions-viewlet[id="workbench.view.extensions"] .search-box.synthetic-focus');
}
public async searchForExtension(name: string): Promise<any> {
const searchBoxSelector = 'div.extensions-viewlet[id="workbench.view.extensions"] .search-box[placeholder="Search Extensions in Marketplace"]';
const searchBoxSelector = 'div.extensions-viewlet[id="workbench.view.extensions"] .search-box';
await this.spectron.client.clearElement(searchBoxSelector);
await this.spectron.client.click(searchBoxSelector);
await this.spectron.client.waitForElement('div.extensions-viewlet[id="workbench.view.extensions"] .search-box.synthetic-focus[placeholder="Search Extensions in Marketplace"]');
await this.spectron.client.waitForElement('div.extensions-viewlet[id="workbench.view.extensions"] .search-box.synthetic-focus');
await this.spectron.client.keys(name);
}
......
......@@ -17,21 +17,21 @@ export class Search extends Viewlet {
public async openSearchViewlet(): Promise<any> {
if (!await this.isSearchViewletFocused()) {
await this.spectron.command('workbench.view.search');
await this.spectron.client.waitForElement(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .monaco-inputbox.synthetic-focus input[placeholder="Search"]`);
await this.spectron.client.waitForElement(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox.synthetic-focus input`);
}
}
public async isSearchViewletFocused(): Promise<boolean> {
const element = await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .monaco-inputbox.synthetic-focus input[placeholder="Search"]`);
const element = await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox.synthetic-focus input`);
return !!element;
}
public async searchFor(text: string): Promise<void> {
const searchBoxSelector = `${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox input[placeholder="Search"]`;
const searchBoxSelector = `${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox input`;
await this.spectron.client.clearElement(searchBoxSelector);
await this.spectron.client.click(searchBoxSelector);
await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox.synthetic-focus input[placeholder="Search"]`);
await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox.synthetic-focus input`);
await this.spectron.client.keys(text);
......@@ -39,8 +39,8 @@ export class Search extends Viewlet {
}
public async submitSearch(): Promise<void> {
await this.spectron.client.click(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox input[placeholder="Search"]`);
await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox.synthetic-focus input[placeholder="Search"]`);
await this.spectron.client.click(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox input`);
await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .search-widget .search-container .monaco-inputbox.synthetic-focus input`);
await this.spectron.client.keys(['NULL', 'Enter', 'NULL'], false);
await this.spectron.client.element(`${Search.SEARCH_VIEWLET_XPATH} .messages[aria-hidden="false"]`);
}
......
......@@ -19,7 +19,7 @@ describe('Terminal', () => {
const currentLine = await app.workbench.terminal.getCurrentLineNumber();
await app.workbench.terminal.runCommand(`echo ${expected}`);
const actual = await app.workbench.terminal.waitForText(currentLine + 1, text => !!text.trim());
const actual = await app.workbench.terminal.waitForTextInLine(currentLine + 1, text => !!text.trim());
app.screenshot.capture('Terminal text');
assert.equal(actual.trim(), expected);
});
......
......@@ -17,7 +17,7 @@ export class Terminal {
if (!await this.isVisible()) {
await this.spectron.workbench.commandPallette.runCommand('Toggle Integrated Terminal');
await this.spectron.client.waitForElement(Terminal.TERMINAL_SELECTOR);
await this.waitForText(1, text => text.trim().indexOf('vscode-smoketest-express git:(master)') !== -1);
await this.waitForText(text => !!text[text.length - 1] && text[text.length - 1].trim().indexOf('vscode-smoketest-express') !== -1);
}
}
......@@ -31,11 +31,16 @@ export class Terminal {
await this.spectron.client.keys(['Enter', 'NULL']);
}
public async waitForText(line: number, fn: (text: string) => boolean): Promise<string> {
public async waitForTextInLine(line: number, fn: (text: string) => boolean): Promise<string> {
const text = await this.waitForText(text => !!text[line]);
return text[line];
}
public async waitForText(fn: (text: string[]) => boolean): Promise<string[]> {
return this.spectron.client.waitFor(async () => {
const terminalText = await this.getTerminalText();
if (fn(terminalText[line - 1])) {
return terminalText[line - 1];
if (fn(terminalText)) {
return terminalText;
}
return undefined;
});
......
......@@ -17,7 +17,7 @@ describe('Localization', () => {
beforeEach(function () { app.createScreenshotCapturer(this.currentTest); });
it(`starts with 'DE' locale and verifies title and viewlets text is in German`, async function () {
await app.start();
await app.start('--locale=DE');
let text = await app.workbench.explorer.getOpenEditorsViewTitle();
app.screenshot.capture('Open editors title');
......@@ -31,16 +31,16 @@ describe('Localization', () => {
await app.workbench.scm.openSCMViewlet();
text = await app.workbench.scm.getTitle();
app.screenshot.capture('Scm title');
assert.equal(text.toLowerCase(), 'quellcodeverwaltung: git');
assert.equal(text.toLowerCase(), 'quellcodeverwaltung: vscode-smoketest-express (git)');
await app.workbench.debug.openDebugViewlet();
text = await app.workbench.debug.getTitle();
app.screenshot.capture('Debug title');
assert.equal(text.toLowerCase(), 'quellcodeverwaltung: git');
assert.equal(text.toLowerCase(), 'debuggen');
await app.workbench.extensions.openExtensionsViewlet();
text = await app.workbench.extensions.getTitle();
app.screenshot.capture('Extensions title');
assert.equal(text.toLowerCase(), 'nach erweiterungen im marketplace suchen');
assert.equal(text.toLowerCase(), 'erweiterungen: marketplace');
});
});
\ No newline at end of file
......@@ -12,7 +12,7 @@ export abstract class Viewlet {
}
public async getTitle(): Promise<string> {
return this.spectron.client.waitForText('.monaco-workbench-container .part.sidebar > .title > .title-label > .title');
return this.spectron.client.waitForText('.monaco-workbench-container .part.sidebar > .title > .title-label > span');
}
}
\ No newline at end of file
......@@ -75,18 +75,18 @@ export class SpectronApplication {
return this._screenshot;
}
public async start(): Promise<any> {
public async start(...args: string[]): Promise<any> {
await this.retrieveKeybindings();
await this.startApplication();
await this.client.windowByIndex(1); // focuses on main renderer window
await this.startApplication(args);
await this.checkWindowReady();
await this.waitForWelcome();
}
public async reload(): Promise<any> {
await this.workbench.commandPallette.runCommand('Reload Window');
// TODO @sandy: Find a proper condition to wait for reload
await this.wait(.5);
await this.client.waitForHTML('[id="workbench.main.container"]');
await this.checkWindowReady();
}
public async stop(): Promise<any> {
......@@ -99,7 +99,7 @@ export class SpectronApplication {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
private async startApplication(): Promise<any> {
private async startApplication(moreArgs: string[] = []): Promise<any> {
let args: string[] = [];
let chromeDriverArgs: string[] = [];
......@@ -114,6 +114,8 @@ export class SpectronApplication {
// Ensure that running over custom extensions directory, rather than picking up the one that was used by a tester previously
args.push(`--extensions-dir=${path.join(EXTENSIONS_DIR, new Date().getTime().toString())}`);
args.push(...moreArgs);
chromeDriverArgs.push(`--user-data-dir=${path.join(this._userDir, new Date().getTime().toString())}`);
this.spectron = new Application({
......@@ -131,7 +133,15 @@ export class SpectronApplication {
}
private async checkWindowReady(): Promise<any> {
await this.webclient.waitUntilWindowLoaded();
// Spectron opens multiple terminals in Windows platform
// Workaround to focus the right window - https://github.com/electron/spectron/issues/60
await this.client.windowByIndex(1);
await this.app.browserWindow.focus();
await this.client.waitForHTML('[id="workbench.main.container"]');
}
private async waitForWelcome(): Promise<any> {
await this.client.waitForElement('.explorer-folders-view');
await this.client.waitForElement(`.editor-container[id="workbench.editor.walkThroughPart"] .welcomePage`);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册