0

We are using Angular 9, webdriver-manager 12.1.7, and protractor 5.4.3. We are trying to verify in our end-to-end test that a copy button is working. When the user clicks the button, certain text is copied to the clipboard so that the user can paste it later (using Ctrl +V or Cmd+V, depending on your OS). We have

import { ExpectedConditions as EC, browser, by, element } from 'protractor';
...

  async getTextFromClipboard() {
    ...
    await browser.wait(EC.visibilityOf(element(by.css('.btn-copy'))), waitTimeout);
    await element(by.css('.btn-copy')).click();

What I am not sure is how, in protractor, do we then programmatically get the text that has been copied to the clipboard?

Dave
  • 15,639
  • 133
  • 442
  • 830
  • The clipboard's *outside* the browser, you either need to paste into an input or other element or use e.g. https://www.npmjs.com/package/copy-paste – jonrsharpe Dec 18 '20 at 21:46
  • We did something like that before I remembered: https://stackoverflow.com/a/34877948. So, indeed, this was an extra temporary input to which keys are sent. – alecxe Dec 18 '20 at 21:59

0 Answers0