File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ Emitted when Browser gets disconnected from the browser application. This might
79
79
* Browser application is closed or crashed.
80
80
* The [ ` method: Browser.close ` ] method was called.
81
81
82
+ ## method: Browser.browserType
83
+ - returns: <[ BrowserType] >
84
+
85
+ Get the browser type (chromium, firefox or webkit) that the browser belongs to.
86
+
82
87
## async method: Browser.close
83
88
84
89
In case this browser is obtained using [ ` method: BrowserType.launch ` ] , closes the browser and all of its pages (if any
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ export class Browser extends ChannelOwner<channels.BrowserChannel> implements ap
56
56
context . _setBrowserType ( browserType ) ;
57
57
}
58
58
59
+ browserType ( ) : BrowserType {
60
+ return this . _browserType ;
61
+ }
62
+
59
63
async newContext ( options : BrowserContextOptions = { } ) : Promise < BrowserContext > {
60
64
options = { ...this . _browserType . _defaultContextOptions , ...options } ;
61
65
const contextOptions = await prepareBrowserContextParams ( options ) ;
Original file line number Diff line number Diff line change @@ -12746,6 +12746,11 @@ export interface Browser extends EventEmitter {
12746
12746
*/
12747
12747
off(event: 'disconnected', listener: (browser: Browser) => void): this;
12748
12748
12749
+ /**
12750
+ * Get the browser type (chromium, firefox or webkit) that the browser belongs to.
12751
+ */
12752
+ browserType(): BrowserType;
12753
+
12749
12754
/**
12750
12755
* In case this browser is obtained using
12751
12756
* [browserType.launch([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch), closes the
Original file line number Diff line number Diff line change 16
16
17
17
import { browserTest as test , expect } from '../config/browserTest' ;
18
18
19
+ test ( 'should return browserType' , function ( { browser, browserType } ) {
20
+ expect ( browser . browserType ( ) ) . toBe ( browserType ) ;
21
+ } ) ;
22
+
19
23
test ( 'should create new page @smoke' , async function ( { browser } ) {
20
24
const page1 = await browser . newPage ( ) ;
21
25
expect ( browser . contexts ( ) . length ) . toBe ( 1 ) ;
You can’t perform that action at this time.
0 commit comments