mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
35 lines
1.7 KiB
JavaScript
35 lines
1.7 KiB
JavaScript
|
/**
|
||
|
* Copyright 2018 Google Inc. All rights reserved.
|
||
|
* Modifications copyright (c) Microsoft Corporation.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
const {USES_HOOKS} = testOptions;
|
||
|
|
||
|
it.skip(USES_HOOKS)('should avoid side effects after timeout', async({page, server}) => {
|
||
|
await page.goto(server.PREFIX + '/input/button.html');
|
||
|
const error = await page.click('button', { timeout: 2000, __testHookBeforePointerAction: () => new Promise(f => setTimeout(f, 2500))}).catch(e => e);
|
||
|
await page.waitForTimeout(5000); // Give it some time to click after the test hook is done waiting.
|
||
|
expect(await page.evaluate(() => result)).toBe('Was not clicked');
|
||
|
expect(error.message).toContain('page.click: Timeout 2000ms exceeded.');
|
||
|
});
|
||
|
|
||
|
it('should timeout waiting for button to be enabled', async({page, server}) => {
|
||
|
await page.setContent('<button onclick="javascript:window.__CLICKED=true;" disabled><span>Click target</span></button>');
|
||
|
const error = await page.click('text=Click target', { timeout: 3000 }).catch(e => e);
|
||
|
expect(await page.evaluate(() => window.__CLICKED)).toBe(undefined);
|
||
|
expect(error.message).toContain('page.click: Timeout 3000ms exceeded.');
|
||
|
expect(error.message).toContain('element is disabled - waiting');
|
||
|
});
|