playwright/test/browsercontext-device.spec.ts

57 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-08-03 23:41:48 +03:00
/**
* 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.
*/
import { options } from './playwright.fixtures';
2020-08-03 23:41:48 +03:00
2020-08-20 22:51:05 +03:00
it.skip(options.FIREFOX)('should work', async({playwright, browser, server}) => {
2020-08-03 23:41:48 +03:00
const iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone });
const page = await context.newPage();
await page.goto(server.PREFIX + '/mobile.html');
expect(await page.evaluate(() => window.innerWidth)).toBe(375);
expect(await page.evaluate(() => navigator.userAgent)).toContain('iPhone');
await context.close();
});
2020-08-20 22:51:05 +03:00
it.skip(options.FIREFOX)('should support clicking', async({playwright, browser, server}) => {
2020-08-03 23:41:48 +03:00
const iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone });
const page = await context.newPage();
await page.goto(server.PREFIX + '/input/button.html');
const button = await page.$('button');
await page.evaluate(button => button.style.marginTop = '200px', button);
await button.click();
expect(await page.evaluate('result')).toBe('Clicked');
2020-08-03 23:41:48 +03:00
await context.close();
});
2020-08-20 22:51:05 +03:00
it.skip(options.FIREFOX)('should scroll to click', async({browser, server}) => {
2020-08-03 23:41:48 +03:00
const context = await browser.newContext({
viewport: {
width: 400,
height: 400,
},
deviceScaleFactor: 1,
isMobile: true
});
const page = await context.newPage();
await page.goto(server.PREFIX + '/input/scrollable.html');
const element = await page.$('#button-91');
await element.click();
expect(await element.textContent()).toBe('clicked');
await context.close();
});