-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🚀 Request] Provide a method to check whether an extension is activated #854
Comments
If I understand your test case, you wait for the Kaoto editor to show up. If it is the case, then I would check periodically for current CustomEditor title or some other feature which identifies your Kaoto WebView. Regarding the linked issue, I would recommend adding openResource call for each driver.wait attempt. After applying changes, it might look like the following code snippet, however I have not tested it: export async function openAndSwitchToKaotoFrame(workspaceFolder: string, fileNameToOpen: string, driver: WebDriver, checkNotDirty: boolean) {
// try to open editor, I believe wait interval should be set as well
await await VSBrowser.instance.driver.wait(async () => {
await VSBrowser.instance.openResources(path.join(workspaceFolder, fileNameToOpen));
return await switchToKaotoFrame(driver, checkNotDirty);
}, ...);
}
export async function switchToKaotoFrame(driver: WebDriver, checkNotDirty: boolean) {
let kaotoEditor = new CustomEditor(); // handle error.NoSuchElementError just in case
if (await kaotoEditor.getTitle() !== "your_title") { return undefined }; // or any other feature/flag identifier, depending on your application
if (checkNotDirty) {
assert.isFalse(await kaotoEditor.isDirty(), 'The Kaoto editor should not be dirty when opening it.');
}
let kaotoWebview :WebView = await kaotoEditor.getWebView();
await driver.wait(async () => {
try {
kaotoEditor = new CustomEditor();
kaotoWebview = await kaotoEditor.getWebView();
await kaotoWebview.switchToFrame();
return true;
} catch (exception) {
console.log('failed to switch to frame ' + exception);
return false;
}
}, 20000, 'Failed to switch to frame', 1000);
return { kaotoWebview, kaotoEditor };
} I know it does not exactly answer your question, but hopefully it will help you to find workaround for now. |
Cool, thanks for sharing @mlorinc, I'll give it a try and see what happens. |
Context
Currently, it seems that there's no clear indicator from VSCode that a given extension is fully activated on the workbench.
What is the feature you are missing?
vscode-extension-tester
to provide a method that will be executed to determine whether the extension is activated. As an example, forvscode-kaoto
we're using a timeout of 5 seconds as a workaround to ensure that the underlying backend is loaded and the UI had the chance to communicate with it (related issue).Could you provide some example of usage?
The idea would be to have a method like the existing
waitForWorkbench
that allows passing a custom function to test against the extension.In addition to that, we could also provide some context to the
activationFn
, for instance, the underlyingWebDriver
or thestdout
andstderr
if available to have a better way to ensure that the extension is ready. Another possibility could be to give access to theOutput
pane of VSCode.The text was updated successfully, but these errors were encountered: