mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 05:37:20 +03:00
fix (#58)
This commit is contained in:
parent
ac01262c88
commit
37a9c17d3e
@ -72,6 +72,19 @@ export class Browser extends EventEmitter {
|
||||
this._screenshotTaskQueue = new TaskQueue();
|
||||
}
|
||||
|
||||
async userAgent(): Promise<string> {
|
||||
const context = await this.createIncognitoBrowserContext();
|
||||
const page = await context.newPage();
|
||||
const userAgent = await page.evaluate('navigator.userAgent');
|
||||
context.close();
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
async version(): Promise<string> {
|
||||
const userAgent = await this.userAgent();
|
||||
return userAgent.split(' ').pop();
|
||||
}
|
||||
|
||||
process(): childProcess.ChildProcess | null {
|
||||
return this._process;
|
||||
}
|
||||
|
@ -19,18 +19,20 @@ module.exports.addTests = function({testRunner, expect, headless, playwright, FF
|
||||
const {it, fit, xit} = testRunner;
|
||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||
|
||||
describe.skip(WEBKIT)('Browser.version', function() {
|
||||
describe('Browser.version', function() {
|
||||
it('should return whether we are in headless', async({browser}) => {
|
||||
const version = await browser.version();
|
||||
expect(version.length).toBeGreaterThan(0);
|
||||
if (CHROME || WEBKIT)
|
||||
if (CHROME)
|
||||
expect(version.startsWith('Headless')).toBe(headless);
|
||||
else if (WEBKIT)
|
||||
expect(version.startsWith('Safari/')).toBe(true);
|
||||
else
|
||||
expect(version.startsWith('Firefox/')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip(WEBKIT)('Browser.userAgent', function() {
|
||||
describe('Browser.userAgent', function() {
|
||||
it('should include WebKit', async({browser}) => {
|
||||
const userAgent = await browser.userAgent();
|
||||
expect(userAgent.length).toBeGreaterThan(0);
|
||||
|
@ -18,7 +18,6 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
|
||||
let {describe, xdescribe, fdescribe} = testRunner;
|
||||
const {it, fit, xit} = testRunner;
|
||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||
describe = fdescribe;
|
||||
const iPhone = playwright.devices['iPhone 6'];
|
||||
const iPhoneLandscape = playwright.devices['iPhone 6 landscape'];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user