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:
- Navigate to https://subject7inc.gitlab.io/Test-pages/ and click Unit Test Page (first option)
- Under the Clipboard Test section, you can see Hello World text that can be added to the clipboard
- 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
- Pressing and holding CTRL key on the keyboard
- Pressing v to paste
- Depressing CTRL key
- Your step will look like this:
- The following video shows the execution of a sample test case:
- 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"}}]}}
Comments
Please sign in to leave a comment.