wdio-vscode-service icon indicating copy to clipboard operation
wdio-vscode-service copied to clipboard

`getText` only returns text that is visible in the output view

Open christian-bromann opened this issue 3 years ago • 2 comments

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:

  1. expand the output view to the maximum possible size, e.g.: Screenshot 2022-03-24 at 18 47 10
  2. capture these logs using VSCode extension APIs, maybe there is a way to monkey patch them and capture that data from there

christian-bromann avatar Mar 24 '22 17:03 christian-bromann

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 avatar Jan 23 '23 17:01 jeffb-sfdc

@jeffb-sfdc interesting! If this turns out to be a reliable approach I wouldn't mind to replace the current implementation with that.

christian-bromann avatar Jan 23 '23 17:01 christian-bromann