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).
This commit is contained in:
Yury Semikhatsky 2019-07-30 13:19:56 -07:00 committed by Andrey Lushnikov
parent 7406b185d2
commit 1b4a0302fc

View File

@ -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}) => {