Automated copying of HTML nodes (esp. images) for test use |
|||||||
Issue description
document.execCommand() currently has capability to copy and paste, but can only copy items from a document. The ability to copy generalized nodes (ex. images) would facilitate writing of tests for such a purpose. An example usage could be something like below:
// retrieve <image id='img' src=<file>> node. For now, we can only test image copying
// in an automated manner via <iframe src=<file>>, which has different behavior.
node = document.getElementById('img');
node.execCommand('copy');
Blink>Editing>Command is linked for the sake of execCommand(), but this could be just as helpful if implemented via eventSender or testing APIs.
,
Nov 16
,
Nov 16
,
Nov 26
It seems you can done this by
function putElementOnClipboard(element) {
const selection = window.getSelection();
select.removeAllRanges();
select.addRange((new Range).selectNode(element));
node.execCommand('copy');
}
Does this work for you?
,
Nov 28
@4, Thank you, this should work. I'll try it and report back/close the bug.
,
Dec 6
,
Dec 6
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 6
Oops sorry for triggering the bot. I haven't had a chance to take a look at this yet. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by huangdarwin@google.com
, Nov 16