mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
parent
7f10fe935a
commit
62b6af3a7f
@ -274,8 +274,10 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel> i
|
|||||||
|
|
||||||
async launchBrowser(options: types.BrowserContextOptions & { pkg?: string } = {}): Promise<BrowserContext> {
|
async launchBrowser(options: types.BrowserContextOptions & { pkg?: string } = {}): Promise<BrowserContext> {
|
||||||
const contextOptions = await prepareBrowserContextParams(options);
|
const contextOptions = await prepareBrowserContextParams(options);
|
||||||
const { context } = await this._channel.launchBrowser(contextOptions);
|
const result = await this._channel.launchBrowser(contextOptions);
|
||||||
return BrowserContext.from(context) as BrowserContext;
|
const context = BrowserContext.from(result.context) as BrowserContext;
|
||||||
|
context._setOptions(contextOptions, {});
|
||||||
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitForEvent(event: string, optionsOrPredicate: types.WaitForEventOptions = {}): Promise<any> {
|
async waitForEvent(event: string, optionsOrPredicate: types.WaitForEventOptions = {}): Promise<any> {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
import { androidTest as test, expect } from './androidTest';
|
import { androidTest as test, expect } from './androidTest';
|
||||||
|
|
||||||
test.afterAll(async ({ androidDevice }) => {
|
test.afterAll(async ({ androidDevice }) => {
|
||||||
@ -155,3 +156,19 @@ test('should be able to pass context options', async ({ androidDevice, httpsServ
|
|||||||
expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(false);
|
expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(false);
|
||||||
await context.close();
|
await context.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should record har', async ({ androidDevice }) => {
|
||||||
|
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28015' });
|
||||||
|
const harPath = test.info().outputPath('test.har');
|
||||||
|
|
||||||
|
const context = await androidDevice.launchBrowser({
|
||||||
|
recordHar: { path: harPath }
|
||||||
|
});
|
||||||
|
const [page] = context.pages();
|
||||||
|
await page.goto('data:text/html,<title>Hello</title>');
|
||||||
|
await page.waitForLoadState('domcontentloaded');
|
||||||
|
await context.close();
|
||||||
|
|
||||||
|
const log = JSON.parse(fs.readFileSync(harPath).toString())['log'];
|
||||||
|
expect(log.pages[0].title).toBe('Hello');
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user