Class BrowserTypeImpl
- java.lang.Object
-
- com.microsoft.playwright.impl.LoggingSupport
-
- com.microsoft.playwright.impl.ChannelOwner
-
- com.microsoft.playwright.impl.BrowserTypeImpl
-
- All Implemented Interfaces:
BrowserType
class BrowserTypeImpl extends ChannelOwner implements BrowserType
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.microsoft.playwright.BrowserType
BrowserType.ConnectOptions, BrowserType.ConnectOverCDPOptions, BrowserType.LaunchOptions, BrowserType.LaunchPersistentContextOptions
-
-
Field Summary
-
Fields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type
-
-
Constructor Summary
Constructors Constructor Description BrowserTypeImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Browserconnect(java.lang.String wsEndpoint, BrowserType.ConnectOptions options)This method attaches Playwright to an existing browser instance.private BrowserconnectImpl(java.lang.String wsEndpoint, BrowserType.ConnectOptions options)BrowserconnectOverCDP(java.lang.String endpointURL, BrowserType.ConnectOverCDPOptions options)This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.private BrowserconnectOverCDPImpl(java.lang.String endpointURL, BrowserType.ConnectOverCDPOptions options)java.lang.StringexecutablePath()A path where Playwright expects to find a bundled browser executable.BrowserImpllaunch(BrowserType.LaunchOptions options)Returns the browser instance.private BrowserImpllaunchImpl(BrowserType.LaunchOptions options)BrowserContextImpllaunchPersistentContext(java.nio.file.Path userDataDir, BrowserType.LaunchPersistentContextOptions options)Returns the persistent browser context instance.private BrowserContextImpllaunchPersistentContextImpl(java.nio.file.Path userDataDir, BrowserType.LaunchPersistentContextOptions options)java.lang.Stringname()Returns browser name.-
Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, handleEvent, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLogging
-
Methods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLogging
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.microsoft.playwright.BrowserType
connect, connectOverCDP, launch, launchPersistentContext
-
-
-
-
Constructor Detail
-
BrowserTypeImpl
BrowserTypeImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
-
Method Detail
-
launch
public BrowserImpl launch(BrowserType.LaunchOptions options)
Description copied from interface:BrowserTypeReturns the browser instance.**Usage**
You can use
ignoreDefaultArgsto filter out--mute-audiofrom default arguments:// Or "firefox" or "webkit". Browser browser = chromium.launch(new BrowserType.LaunchOptions() .setIgnoreDefaultArgs(Arrays.asList("--mute-audio")));> **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use
executablePathoption with extreme caution.>
> If Google Chrome (rather than Chromium) is preferred, a Chrome Canary or Dev Channel build is suggested.
>
> Stock browsers like Google Chrome and Microsoft Edge are suitable for tests that require proprietary media codecs for video playback. See this article for other differences between Chromium and Chrome. This article describes some differences for Linux users.
- Specified by:
launchin interfaceBrowserType
-
launchImpl
private BrowserImpl launchImpl(BrowserType.LaunchOptions options)
-
connect
public Browser connect(java.lang.String wsEndpoint, BrowserType.ConnectOptions options)
Description copied from interface:BrowserTypeThis method attaches Playwright to an existing browser instance. When connecting to another browser launched viaBrowserType.launchServerin Node.js, the major and minor version needs to match the client version (1.2.3 → is compatible with 1.2.x).- Specified by:
connectin interfaceBrowserType- Parameters:
wsEndpoint- A browser websocket endpoint to connect to.
-
connectImpl
private Browser connectImpl(java.lang.String wsEndpoint, BrowserType.ConnectOptions options)
-
connectOverCDP
public Browser connectOverCDP(java.lang.String endpointURL, BrowserType.ConnectOverCDPOptions options)
Description copied from interface:BrowserTypeThis method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.The default browser context is accessible via
Browser.contexts().NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
**Usage**
Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222"); BrowserContext defaultContext = browser.contexts().get(0); Page page = defaultContext.pages().get(0);- Specified by:
connectOverCDPin interfaceBrowserType- Parameters:
endpointURL- A CDP websocket endpoint or http url to connect to. For examplehttp://localhost:9222/orws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4.
-
connectOverCDPImpl
private Browser connectOverCDPImpl(java.lang.String endpointURL, BrowserType.ConnectOverCDPOptions options)
-
executablePath
public java.lang.String executablePath()
Description copied from interface:BrowserTypeA path where Playwright expects to find a bundled browser executable.- Specified by:
executablePathin interfaceBrowserType
-
launchPersistentContext
public BrowserContextImpl launchPersistentContext(java.nio.file.Path userDataDir, BrowserType.LaunchPersistentContextOptions options)
Description copied from interface:BrowserTypeReturns the persistent browser context instance.Launches browser that uses persistent storage located at
userDataDirand returns the only context. Closing this context will automatically close the browser.- Specified by:
launchPersistentContextin interfaceBrowserType- Parameters:
userDataDir- Path to a User Data Directory, which stores browser session data like cookies and local storage. More details for Chromium and Firefox. Note that Chromium's user data directory is the **parent** directory of the "Profile Path" seen atchrome://version. Pass an empty string to use a temporary directory instead.
-
launchPersistentContextImpl
private BrowserContextImpl launchPersistentContextImpl(java.nio.file.Path userDataDir, BrowserType.LaunchPersistentContextOptions options)
-
name
public java.lang.String name()
Description copied from interface:BrowserTypeReturns browser name. For example:"chromium","webkit"or"firefox".- Specified by:
namein interfaceBrowserType
-
-