Extract & edit `waitForDebuggerToConnect` according to Ihor's review.

Signed-off-by: Radim Hopp <rhopp@redhat.com>
7.20.x
Radim Hopp 2020-01-14 10:48:33 +01:00
parent 520be8907c
commit 78e60e6ced
2 changed files with 12 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import { DriverHelper } from '../../utils/DriverHelper';
import { By, Key, WebElement } from 'selenium-webdriver';
import { Ide } from './Ide';
import { Logger } from '../../utils/Logger';
import { TestConstants } from '../../TestConstants';
@injectable()
@ -41,16 +42,22 @@ export class DebugView {
const runDebugButtonLocator: By = By.xpath('//span[@title=\'Start Debugging\']');
await this.driverHelper.waitAndClick(runDebugButtonLocator);
}
/**
* Waits for number of threads in "Threads" view to be more than 1 - this should mean that the debugger is connected.
*
* @param timeout
*/
async waitForDebuggerToConnect(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
await this.driverHelper.getDriver().wait(async () => {
Logger.debug(`Waiting for debugger to connect (threads to appear in "Threads" view)`);
const threadElements: WebElement[] = await this.driverHelper.getDriver().findElements(By.xpath(`//div[contains(@class, 'theia-debug-thread')]`));
if (threadElements.length < 2) {
return false;
} else {
if (threadElements.length > 1) {
return true;
}
});
return false;
}, timeout);
}
}

View File

@ -261,6 +261,7 @@ suite('Validation of debug functionality', async () => {
await debugView.clickOnDebugConfigurationDropDown();
await debugView.clickOnDebugConfigurationItem('Debug (Attach) - Remote');
await debugView.clickOnRunDebugButton();
await debugView.waitForDebuggerToConnect();
await previewWidget.refreshPage();
try {
await editor.waitStoppedDebugBreakpoint(weclomeControllerJavaFileName, 27);