Struct fantoccini::Client [−][src]
pub struct Client { /* fields omitted */ }
A WebDriver client tied to a single browser session.
Methods
impl Client
[src]
impl Client
pub fn new(
webdriver: &str
) -> impl Future<Item = Self, Error = NewSessionError> + 'static
[src]
pub fn new(
webdriver: &str
) -> impl Future<Item = Self, Error = NewSessionError> + 'static
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> + 'static
[src]
pub fn with_capabilities(
webdriver: &str,
cap: Capabilities
) -> impl Future<Item = Self, Error = NewSessionError> + 'static
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]
pub fn session_id(
&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]
pub fn set_ua<S: Into<String>>(
&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]
pub fn get_ua(
&mut self
) -> impl Future<Item = Option<String>, Error = CmdError>
Get the current User Agent string.
pub fn close(
&mut self
) -> impl Future<Item = (), Error = CmdError>
[src]
pub fn close(
&mut self
) -> impl Future<Item = (), Error = CmdError>
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> + 'static
[src]
pub fn set_window_rect(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32
) -> impl Future<Item = (), Error = CmdError> + 'static
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> + 'static
[src]
pub fn get_window_rect(
&mut self
) -> impl Future<Item = (u64, u64, u64, u64), Error = CmdError> + 'static
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> + 'static
[src]
pub fn set_window_size(
&mut self,
width: i32,
height: i32
) -> impl Future<Item = (), Error = CmdError> + 'static
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> + 'static
[src]
pub fn get_window_size(
&mut self
) -> impl Future<Item = (u64, u64), Error = CmdError> + 'static
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> + 'static
[src]
pub fn set_window_position(
&mut self,
x: i32,
y: i32
) -> impl Future<Item = (), Error = CmdError> + 'static
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> + 'static
[src]
pub fn get_window_position(
&mut self
) -> impl Future<Item = (u64, u64), Error = CmdError> + 'static
Gets the x and y top-left coordinate of the current window.
pub fn goto(
self,
url: &str
) -> impl Future<Item = Self, Error = CmdError> + 'static
[src]
pub fn goto(
self,
url: &str
) -> impl Future<Item = Self, Error = CmdError> + 'static
Navigate directly to the given URL.
pub fn current_url(
&mut self
) -> impl Future<Item = Url, Error = CmdError> + 'static
[src]
pub fn current_url(
&mut self
) -> impl Future<Item = Url, Error = CmdError> + 'static
Retrieve the currently active URL for this session.
pub fn screenshot(
&mut self
) -> impl Future<Item = Vec<u8>, Error = CmdError> + 'static
[src]
pub fn screenshot(
&mut self
) -> impl Future<Item = Vec<u8>, Error = CmdError> + 'static
Get a PNG-encoded screenshot of the current page.
pub fn source(
&mut self
) -> impl Future<Item = String, Error = CmdError> + 'static
[src]
pub fn source(
&mut self
) -> impl Future<Item = String, Error = CmdError> + 'static
Get the HTML source for the current page.
pub fn back(
&mut self
) -> impl Future<Item = (), Error = CmdError> + 'static
[src]
pub fn back(
&mut self
) -> impl Future<Item = (), Error = CmdError> + 'static
Go back to the previous page.
pub fn refresh(
&mut self
) -> impl Future<Item = (), Error = CmdError> + 'static
[src]
pub fn refresh(
&mut self
) -> impl Future<Item = (), Error = CmdError> + 'static
Refresh the current previous page.
pub fn execute(
&mut self,
script: &str,
args: Vec<Json>
) -> impl Future<Item = Json, Error = CmdError> + 'static
[src]
pub fn execute(
&mut self,
script: &str,
args: Vec<Json>
) -> impl Future<Item = Json, Error = CmdError> + 'static
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> + 'static
[src]
pub fn raw_client_for<'a>(
self,
method: Method,
url: &str
) -> impl Future<Item = Response<Body>, Error = CmdError> + 'static
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> + 'static,
[src]
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> + 'static,
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]
pub fn find(
&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]
pub fn find_all(
&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]
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>,
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]
pub fn wait_for_find(
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.
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]
pub fn form(
&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.