feat(browser): add Browser.BrowserType() method (#14468)
This commit is contained in:
parent
7e130d0c3b
commit
4c2fc6b6eb
|
|
@ -79,6 +79,11 @@ Emitted when Browser gets disconnected from the browser application. This might
|
|||
* Browser application is closed or crashed.
|
||||
* The [`method: Browser.close`] method was called.
|
||||
|
||||
## method: Browser.browserType
|
||||
- returns: <[BrowserType]>
|
||||
|
||||
Get the browser type (chromium, firefox or webkit) that the browser belongs to.
|
||||
|
||||
## async method: Browser.close
|
||||
|
||||
In case this browser is obtained using [`method: BrowserType.launch`], closes the browser and all of its pages (if any
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ export class Browser extends ChannelOwner<channels.BrowserChannel> implements ap
|
|||
context._setBrowserType(browserType);
|
||||
}
|
||||
|
||||
browserType(): BrowserType {
|
||||
return this._browserType;
|
||||
}
|
||||
|
||||
async newContext(options: BrowserContextOptions = {}): Promise<BrowserContext> {
|
||||
options = { ...this._browserType._defaultContextOptions, ...options };
|
||||
const contextOptions = await prepareBrowserContextParams(options);
|
||||
|
|
|
|||
5
packages/playwright-core/types/types.d.ts
vendored
5
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -12746,6 +12746,11 @@ export interface Browser extends EventEmitter {
|
|||
*/
|
||||
off(event: 'disconnected', listener: (browser: Browser) => void): this;
|
||||
|
||||
/**
|
||||
* Get the browser type (chromium, firefox or webkit) that the browser belongs to.
|
||||
*/
|
||||
browserType(): BrowserType;
|
||||
|
||||
/**
|
||||
* In case this browser is obtained using
|
||||
* [browserType.launch([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch), closes the
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
import { browserTest as test, expect } from '../config/browserTest';
|
||||
|
||||
test('should return browserType', function({ browser, browserType }) {
|
||||
expect(browser.browserType()).toBe(browserType);
|
||||
});
|
||||
|
||||
test('should create new page @smoke', async function({ browser }) {
|
||||
const page1 = await browser.newPage();
|
||||
expect(browser.contexts().length).toBe(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue