pub struct BrowserType {
inner: Weak<BrowserType>,
}Fields§
§inner: Weak<BrowserType>Implementations§
Source§impl BrowserType
impl BrowserType
pub(crate) fn new(inner: Weak<Impl>) -> Self
Sourcepub fn name(&self) -> Result<String, Error>
pub fn name(&self) -> Result<String, Error>
Returns browser name. For example: 'chromium', 'webkit' or 'firefox'.
§Errors
Returns error only if this function is called after object is disposed.
Sourcepub fn executable(&self) -> Result<PathBuf, Error>
pub fn executable(&self) -> Result<PathBuf, Error>
A path where Playwright expects to find a bundled browser executable.
§Errors
Returns error only if this function is called after object is disposed.
Sourcepub fn launcher(&self) -> Launcher<'_, '_, '_>
pub fn launcher(&self) -> Launcher<'_, '_, '_>
launch Browser
Returns the browser instance.
You can use ignoreDefaultArgs to filter out --mute-audio from default arguments:
const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
ignoreDefaultArgs: ['--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.
Sourcepub fn persistent_context_launcher<'a>(
&self,
user_data_dir: &'a Path,
) -> PersistentContextLauncher<'a, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_>
pub fn persistent_context_launcher<'a>( &self, user_data_dir: &'a Path, ) -> PersistentContextLauncher<'a, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_>
launch_persistent_context BrowserContext
Returns the persistent browser context instance.
Launches browser that uses persistent storage located at userDataDir and returns the only context. Closing this
context will automatically close the browser.
user_data_dir: 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 at chrome://version.
Sourcepub fn connect_over_cdp_builder<'a>(
&self,
endpoint_url: &'a str,
) -> ConnectOverCdpBuilder<'a>
pub fn connect_over_cdp_builder<'a>( &self, endpoint_url: &'a str, ) -> ConnectOverCdpBuilder<'a>
This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
The default browser context is accessible via [method: Browser.contexts].
NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. A CDP websocket endpoint or http url to connect to. For example
http://localhost:9222/orws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4.
Trait Implementations§
Source§impl Clone for BrowserType
impl Clone for BrowserType
Source§fn clone(&self) -> BrowserType
fn clone(&self) -> BrowserType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more