How to paste copied content from the clipboard

If you have a scenario where an element is clicked to copy content to a clipboard, you can use Multi_Action command to paste the clipboard content in your test case.

 

The following scenario shows how this can be prepared:

  1. Navigate to https://subject7inc.gitlab.io/Test-pages/ and click Unit Test Page (first option)
  2. Under the Clipboard Test section, you can see Hello World text that can be added to the clipboard
  3. Once the button Copy Text is clicked, the text is added to the clipboard. In order to paste this text somewhere, you can use Multi_Action command with 3 actions
    1. Pressing and holding CTRL key on the keyboard
    2. Pressing v to paste
    3. Depressing CTRL key

  4. Your step will look like this:

  5. The following video shows the execution of a sample test case:



  6. To use the snippet below, follow these steps:
  • Ensure that the Advanced View Type is set to Compact under User Preferences > Application
  • Navigate to More inside a test case
  • Select Advanced View > JSON Editor
  • Then, copy and paste the snippet:
{"command":"GOTO_URL","args":{"url":"https://subject7inc.gitlab.io/Test-pages/"}}
{"command":"CLICK","args":{"overridden":false,"function":"<NOT SELECTED>","functionArguments":{},"locator":"<NOT SELECTED>","element":{"elementType":"XPATH","webElement":{"xpath":"//a[text()='Unit Test Page']","page":"subject7inc_gitlab_io","elementType":"link","alias":"unit_test_page","xpathTemplate":{"id":0,"name":"test","patterns":[{"id":16,"xpath":"//a[text()='$LABEL']"}]}}}}}
{"command":"CLICK","args":{"overridden":false,"function":"<NOT SELECTED>","functionArguments":{},"locator":"<NOT SELECTED>","element":{"elementType":"XPATH","webElement":{"xpath":"//button[contains(text(),'Copy Text')]","page":"subject7inc_gitlab_io","elementType":"button","alias":"copy_text"}}}}
{"command":"ALERT","args":{"action":"Ok"}}
{"command":"CLICK","args":{"overridden":false,"function":"<NOT SELECTED>","functionArguments":{},"locator":"<NOT SELECTED>","element":{"elementType":"XPATH","webElement":{"xpath":"(//textarea[contains(@placeholder, 'Textarea')])[1]","page":"subject7inc_gitlab_io","elementType":"textarea","alias":"textarea"}}}}
{"command":"MULTI_ACTION","args":{"actions":[{"type":"KEY_DOWN","usedLocator":false,"key":"CONTROL","element":{"elementType":"LOCATOR"}},{"type":"SEND_KEYS","usedLocator":false,"value":"v","element":{"elementType":"LOCATOR"}},{"type":"KEY_UP","usedLocator":false,"key":"CONTROL","element":{"elementType":"LOCATOR"}}]}}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.