[−][src]Struct fantoccini::Client
A WebDriver client tied to a single browser session.
Methods
impl Client
[src]
pub fn new(webdriver: &str) -> impl Future<Item = Self, Error = NewSessionError>
[src]
Create a new Client
associated with a new WebDriver session on the server at the given
URL.
Calls with_capabilities
with an empty capabilities list.
pub fn with_capabilities(
webdriver: &str,
cap: Capabilities
) -> impl Future<Item = Self, Error = NewSessionError>
[src]
webdriver: &str,
cap: Capabilities
) -> impl Future<Item = Self, Error = NewSessionError>
Create a new Client
associated with a new WebDriver session on the server at the given
URL.
The given capabilities will be requested in alwaysMatch
or desiredCapabilities
depending on the protocol version supported by the server.
Returns a future that resolves to a handle for issuing additional WebDriver tasks.
Note that most callers should explicitly call Client::close
, and wait for the returned
future before exiting. Not doing so may result in the WebDriver session not being cleanly
closed, which is particularly important for some drivers, such as geckodriver, where
multiple simulatenous sessions are not supported. If close
is not explicitly called, a
session close request will be spawned on the given handle
when the last instance of this
Client
is dropped.
pub fn session_id(
&mut self
) -> impl Future<Item = Option<String>, Error = CmdError>
[src]
&mut self
) -> impl Future<Item = Option<String>, Error = CmdError>
Get the session ID assigned by the WebDriver server to this client.
pub fn set_ua<S: Into<String>>(
&mut self,
ua: S
) -> impl Future<Item = (), Error = CmdError>
[src]
&mut self,
ua: S
) -> impl Future<Item = (), Error = CmdError>
Set the User Agent string to use for all subsequent requests.
pub fn get_ua(&mut self) -> impl Future<Item = Option<String>, Error = CmdError>
[src]
Get the current User Agent string.
pub fn close(&mut self) -> impl Future<Item = (), Error = CmdError>
[src]
Terminate the connection to the webservice.
Normally, a shutdown of the WebDriver connection will be initiated when the last clone of a
Client
is dropped. Specifically, the shutdown request will be issued using the tokio
Handle
given when creating this Client
. This in turn means that any errors will be
dropped.
This function is safe to call multiple times, but once it has been called on one instance
of a Client
, all requests to other instances of that Client
will fail.
This function may be useful in conjunction with raw_client_for
, as it allows you to close
the automated browser window while doing e.g., a large download.
pub fn set_window_rect(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32
) -> impl Future<Item = (), Error = CmdError>
[src]
&mut self,
x: i32,
y: i32,
width: i32,
height: i32
) -> impl Future<Item = (), Error = CmdError>
Sets the x, y, width, and height properties of the current window.
All values must be >= 0
or you will get a CmdError::InvalidArgument
.
pub fn get_window_rect(
&mut self
) -> impl Future<Item = (u64, u64, u64, u64), Error = CmdError>
[src]
&mut self
) -> impl Future<Item = (u64, u64, u64, u64), Error = CmdError>
Gets the x, y, width, and height properties of the current window.
pub fn set_window_size(
&mut self,
width: i32,
height: i32
) -> impl Future<Item = (), Error = CmdError>
[src]
&mut self,
width: i32,
height: i32
) -> impl Future<Item = (), Error = CmdError>
Sets the x, y, width, and height properties of the current window.
All values must be >= 0
or you will get a CmdError::InvalidArgument
.
pub fn get_window_size(
&mut self
) -> impl Future<Item = (u64, u64), Error = CmdError>
[src]
&mut self
) -> impl Future<Item = (u64, u64), Error = CmdError>
Gets the width and height of the current window.
pub fn set_window_position(
&mut self,
x: i32,
y: i32
) -> impl Future<Item = (), Error = CmdError>
[src]
&mut self,
x: i32,
y: i32
) -> impl Future<Item = (), Error = CmdError>
Sets the x, y, width, and height properties of the current window.
All values must be >= 0
or you will get a CmdError::InvalidArgument
.
pub fn get_window_position(
&mut self
) -> impl Future<Item = (u64, u64), Error = CmdError>
[src]
&mut self
) -> impl Future<Item = (u64, u64), Error = CmdError>
Gets the x and y top-left coordinate of the current window.
pub fn goto(self, url: &str) -> impl Future<Item = Self, Error = CmdError>
[src]
Navigate directly to the given URL.
pub fn current_url(&mut self) -> impl Future<Item = Url, Error = CmdError>
[src]
Retrieve the currently active URL for this session.
pub fn screenshot(&mut self) -> impl Future<Item = Vec<u8>, Error = CmdError>
[src]
Get a PNG-encoded screenshot of the current page.
pub fn source(&mut self) -> impl Future<Item = String, Error = CmdError>
[src]
Get the HTML source for the current page.
pub fn back(&mut self) -> impl Future<Item = (), Error = CmdError>
[src]
Go back to the previous page.
pub fn refresh(&mut self) -> impl Future<Item = (), Error = CmdError>
[src]
Refresh the current previous page.
pub fn execute(
&mut self,
script: &str,
args: Vec<Json>
) -> impl Future<Item = Json, Error = CmdError>
[src]
&mut self,
script: &str,
args: Vec<Json>
) -> impl Future<Item = Json, Error = CmdError>
Execute the given JavaScript script
in the current browser session.
args
is available to the script inside the arguments
array. Since Element
implements
ToJson
, you can also provide serialized Element
s as arguments, and they will correctly
serialize to DOM elements on the other side.
To retrieve the value of a variable, return
has to be used in the JavaScript code.
pub fn raw_client_for<'a>(
self,
method: Method,
url: &str
) -> impl Future<Item = Response<Body>, Error = CmdError>
[src]
self,
method: Method,
url: &str
) -> impl Future<Item = Response<Body>, Error = CmdError>
Issue an HTTP request to the given url
with all the same cookies as the current session.
Calling this method is equivalent to calling with_raw_client_for
with an empty closure.
pub fn with_raw_client_for<F>(
self,
method: Method,
url: &str,
before: F
) -> impl Future<Item = Response<Body>, Error = CmdError> where
F: FnOnce(Builder) -> Request<Body>,
[src]
self,
method: Method,
url: &str,
before: F
) -> impl Future<Item = Response<Body>, Error = CmdError> where
F: FnOnce(Builder) -> Request<Body>,
Build and issue an HTTP request to the given url
with all the same cookies as the current
session.
Before the HTTP request is issued, the given before
closure will be called with a handle
to the Request
about to be sent.
pub fn find(
&mut self,
search: Locator
) -> impl Future<Item = Element, Error = CmdError>
[src]
&mut self,
search: Locator
) -> impl Future<Item = Element, Error = CmdError>
Find an element on the page.
pub fn find_all(
&mut self,
search: Locator
) -> impl Future<Item = Vec<Element>, Error = CmdError>
[src]
&mut self,
search: Locator
) -> impl Future<Item = Vec<Element>, Error = CmdError>
Find elements on the page.
pub fn wait_for<F, FF>(
self,
is_ready: F
) -> impl Future<Item = Self, Error = CmdError> where
F: FnMut(&mut Client) -> FF,
FF: IntoFuture<Item = bool, Error = CmdError>,
[src]
self,
is_ready: F
) -> impl Future<Item = Self, Error = CmdError> where
F: FnMut(&mut Client) -> FF,
FF: IntoFuture<Item = bool, Error = CmdError>,
Wait for the given function to return true
before proceeding.
This can be useful to wait for something to appear on the page before interacting with it.
While this currently just spins and yields, it may be more efficient than this in the
future. In particular, in time, it may only run is_ready
again when an event occurs on
the page.
pub fn wait_for_find(
self,
search: Locator
) -> impl Future<Item = Element, Error = CmdError>
[src]
self,
search: Locator
) -> impl Future<Item = Element, Error = CmdError>
Wait for the given element to be present on the page.
This can be useful to wait for something to appear on the page before interacting with it.
While this currently just spins and yields, it may be more efficient than this in the
future. In particular, in time, it may only run is_ready
again when an event occurs on
the page.
pub fn wait_for_navigation(
self,
current: Option<Url>
) -> impl Future<Item = Self, Error = CmdError>
[src]
self,
current: Option<Url>
) -> impl Future<Item = Self, Error = CmdError>
Wait for the page to navigate to a new URL before proceeding.
If the current
URL is not provided, self.current_url()
will be used. Note however that
this introduces a race condition: the browser could finish navigating before we call
current_url()
, which would lead to an eternal wait.
pub fn form(
&mut self,
search: Locator
) -> impl Future<Item = Form, Error = CmdError>
[src]
&mut self,
search: Locator
) -> impl Future<Item = Form, Error = CmdError>
Locate a form on the page.
Through the returned Form
, HTML forms can be filled out and submitted.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.