From 1b4a0302fcd93394255945e9c44dbffa9160a604 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 30 Jul 2019 13:19:56 -0700 Subject: [PATCH] fix(test): make sure selection is not empty before running copy command (#4772) If current selection is empty document.execCommand('copy') may return false in some browsers (e.g. WebKit based ones). --- test/evaluation.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/evaluation.spec.js b/test/evaluation.spec.js index ee3988dcc0b2d..896745ce7b3cd 100644 --- a/test/evaluation.spec.js +++ b/test/evaluation.spec.js @@ -226,7 +226,11 @@ module.exports.addTests = function({testRunner, expect}) { expect(error.message).toContain('JSHandles can be evaluated only in the context they were created'); }); it('should simulate a user gesture', async({page, server}) => { - const result = await page.evaluate(() => document.execCommand('copy')); + const result = await page.evaluate(() => { + document.body.appendChild(document.createTextNode('test')); + document.execCommand('selectAll'); + return document.execCommand('copy'); + }); expect(result).toBe(true); }); it('should throw a nice error after a navigation', async({page, server}) => {