BrowserType

Struct BrowserType 

Source
pub struct BrowserType {
    inner: Weak<BrowserType>,
}

Fields§

§inner: Weak<BrowserType>

Implementations§

Source§

impl BrowserType

Source

pub(crate) fn new(inner: Weak<Impl>) -> Self

Source

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.

Source

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.

Source

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 executablePath option 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.

Source

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.

Source

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/ or ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4.

Trait Implementations§

Source§

impl Clone for BrowserType

Source§

fn clone(&self) -> BrowserType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BrowserType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.