Struct fantoccini_stable::Client
[−]
[src]
pub struct Client(_);
A WebDriver client tied to a single browser session.
Methods
impl Client
[src]
fn new(
webdriver: &str,
handle: &Handle
) -> (Box<Future<Item = Self, Error = NewSessionError>>, Box<Future<Item = (), Error = ()>>)
[src]
webdriver: &str,
handle: &Handle
) -> (Box<Future<Item = Self, Error = NewSessionError>>, Box<Future<Item = (), Error = ()>>)
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) -> Box<Future<Item = Self, Error = CmdError>>
[src]
Navigate directly to the given URL.
fn current_url(&self) -> Box<Future<Item = Url, Error = CmdError>>
[src]
Retrieve the currently active URL for this session.
fn source(&self) -> Box<Future<Item = String, Error = CmdError>>
[src]
Get the HTML source for the current page.
fn back(&self) -> Box<Future<Item = Self, Error = CmdError>>
[src]
Go back to the previous page.
fn refresh(&self) -> Box<Future<Item = Self, Error = CmdError>>
[src]
Refresh the current previous page.
fn execute(
&self,
script: &str,
args: Vec<Json>
) -> Box<Future<Item = Json, Error = CmdError>>
[src]
&self,
script: &str,
args: Vec<Json>
) -> Box<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.
fn raw_client_for(
&self,
method: Method,
url: &str
) -> Box<Future<Item = Response, Error = CmdError>>
[src]
&self,
method: Method,
url: &str
) -> Box<Future<Item = Response, 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.
fn with_raw_client_for<F>(
&self,
method: Method,
url: &str,
before: F
) -> Box<Future<Item = Response, Error = CmdError>> where
F: FnOnce(&mut Request) + 'static,
[src]
&self,
method: Method,
url: &str,
before: F
) -> Box<Future<Item = Response, Error = CmdError>> 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
) -> Box<Future<Item = Element, Error = CmdError>>
[src]
&self,
selector: &str
) -> Box<Future<Item = Element, Error = CmdError>>
Find an element by CSS selector.
fn by_link_text(
&self,
text: &str
) -> Box<Future<Item = Element, Error = CmdError>>
[src]
&self,
text: &str
) -> Box<Future<Item = Element, Error = CmdError>>
Find an element by its link text.
The text matching is exact.
fn by_xpath(&self, xpath: &str) -> Box<Future<Item = Element, Error = CmdError>>
[src]
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) -> Box<Future<Item = Form, Error = CmdError>>
[src]
Locate a form on the page.
Through the returned Form
, HTML forms can be filled out and submitted.