Struct fantoccini::Client
[−]
[src]
pub struct Client(_);
A WebDriver client tied to a single browser session.
Methods
impl Client
[src]
fn new(
webdriver: &str,
handle: &Handle
) -> (impl Future<Item = Self, Error = NewSessionError> + 'static, impl Future<Item = (), Error = ()> + 'static)
[src]
webdriver: &str,
handle: &Handle
) -> (impl Future<Item = Self, Error = NewSessionError> + 'static, impl Future<Item = (), Error = ()> + 'static)
Create a new Client
associated with a new WebDriver session on the server at the given
URL.
Returns two futures -- one that resolves to a handle for issuing additional WebDriver tasks, and one that resolves once all tasks have been completed and the WebDriver session has been destroyed. Note that it is important to eventually wait for this future, as otherwise the WebDriver browser session may not be closed. For some drivers, such as geckodriver, this is particularly important, as multiple simulatenous sessions are not supported.
Note that the second future will not resolve until the Client
has been dropped.
fn set_ua<S: Into<String>>(&mut self, ua: S)
[src]
Set the User Agent string to use for all subsequent requests.
fn shutdown(&mut self) -> bool
[src]
Terminate the connection to the webservice.
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.
Note that this call only takes effect if there are no other copies of this Client
. This
function is safe to call multiple times. Returns true if the shutdown took effect.
Returns true if the shutd
fn goto(
&self,
url: &str
) -> impl Future<Item = Self, Error = CmdError> + 'static
[src]
&self,
url: &str
) -> impl Future<Item = Self, Error = CmdError> + 'static
Navigate directly to the given URL.
fn current_url(&self) -> impl Future<Item = Url, Error = CmdError> + 'static
[src]
Retrieve the currently active URL for this session.
fn source(&self) -> impl Future<Item = String, Error = CmdError> + 'static
[src]
Get the HTML source for the current page.
fn back(&self) -> impl Future<Item = Self, Error = CmdError> + 'static
[src]
Go back to the previous page.
fn refresh(&self) -> impl Future<Item = Self, Error = CmdError> + 'static
[src]
Refresh the current previous page.
fn execute(
&self,
script: &str,
args: Vec<Json>
) -> impl Future<Item = Json, Error = CmdError> + 'static
[src]
&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.
fn raw_client_for(
&self,
method: Method,
url: &str
) -> impl Future<Item = Response, Error = CmdError> + 'static
[src]
&self,
method: Method,
url: &str
) -> impl Future<Item = Response, 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.
fn with_raw_client_for<F>(
&self,
method: Method,
url: &str,
before: F
) -> impl Future<Item = Response, Error = CmdError> + 'static where
F: FnOnce(&mut Request) + 'static,
[src]
&self,
method: Method,
url: &str,
before: F
) -> impl Future<Item = Response, Error = CmdError> + 'static where
F: FnOnce(&mut Request) + '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.
fn by_selector(
&self,
selector: &str
) -> impl Future<Item = Element, Error = CmdError> + 'static
[src]
&self,
selector: &str
) -> impl Future<Item = Element, Error = CmdError> + 'static
Find an element by CSS selector.
fn by_link_text(
&self,
text: &str
) -> impl Future<Item = Element, Error = CmdError> + 'static
[src]
&self,
text: &str
) -> impl Future<Item = Element, Error = CmdError> + 'static
Find an element by its link text.
The text matching is exact.
fn by_xpath(
&self,
xpath: &str
) -> impl Future<Item = Element, Error = CmdError> + 'static
[src]
&self,
xpath: &str
) -> impl Future<Item = Element, Error = CmdError> + 'static
Find an element using an XPath expression.
fn wait_for<F>(&mut self, is_ready: F) -> &mut Self where
F: FnMut(Client) -> bool,
[src]
F: FnMut(Client) -> bool,
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.
[src]
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.
fn form(
&self,
selector: &str
) -> impl Future<Item = Form, Error = CmdError> + 'static
[src]
&self,
selector: &str
) -> impl Future<Item = Form, Error = CmdError> + 'static
Locate a form on the page.
Through the returned Form
, HTML forms can be filled out and submitted.