Skip to content
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

getText only returns text that is visible in the output view #6

Open
christian-bromann opened this issue Mar 24, 2022 · 2 comments
Open
Labels
help wanted Extra attention is needed

Comments

@christian-bromann
Copy link
Contributor

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
@jeffb-sfdc
Copy link
Contributor

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;
}

@christian-bromann
Copy link
Contributor Author

@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 christian-bromann added the help wanted Extra attention is needed label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants