wdio-vscode-service
wdio-vscode-service copied to clipboard
`getText` only returns text that is visible in the output view
It appears that the output view only displays log lines that fit into the window, they are not complete. It basically returns the last n log lines. This number differs based on the available space. There are two options I could think of:
- expand the output view to the maximum possible size, e.g.:

- capture these logs using VSCode extension APIs, maybe there is a way to monkey patch them and capture that data from there
One workaround I did was to bypass getText() and to get the text the brute force way: set focus to the area, select all, then copy, then use clipboardy to get the text form the clipboard.
async function getOutputPanelText(outputChannelName: string): Promise<string> {
const workbench = await (await browser.getWorkbench()).wait();
const bottomBar = await workbench.getBottomBar(); // selector is 'div[id="workbench.parts.panel"]'
const outputView = await bottomBar.openOutputView(); // selector is 'div[id="workbench.panel.output"]'
await utilities.pause(2);
selectChannel(outputView, outputChannelName);
await utilities.pause(1);
// Set focus to the contents in the Output panel.
await (await outputView.elem).click();
await utilities.pause(1);
// Select all of the text within the panel.
await browser.keys([CMD_KEY, 'a', 'c']);
// Should be able to use Keys.Ctrl, but Keys is not exported from webdriverio
// See https://webdriver.io/docs/api/browser/keys/
const outputPanelText = await clipboard.read();
return outputPanelText;
}
@jeffb-sfdc interesting! If this turns out to be a reliable approach I wouldn't mind to replace the current implementation with that.