Struct fantoccini::Client [] [src]

pub struct Client { /* fields omitted */ }

A WebDriver client tied to a single browser session.

Methods

impl Client
[src]

Create a new Client associated with a new WebDriver session on the server at the given URL.

Navigate directly to the given URL.

Retrieve the currently active URL for this session.

Get the HTML source for the current page.

Get a hyper::RequestBuilder instance with all the same cookies as the current session has for the given url.

The RequestBuilder can then be used to fetch a resource with more granular control (such as downloading a file).

Note that the client is tied to the lifetime of the client to prevent the Client from navigating to another page. This is because it would likely be confusing that the builder did not also navigate. Furthermore, the builder's cookies are tied to the URL at the time of its creation, so after navigation, the user (that's you) may be confused that the right cookies aren't being included (I know I would).

Examples

use fantoccini::Client;
let mut c = Client::new("http://localhost:4444").unwrap();
c.goto("https://www.wikipedia.org/").unwrap();
let img = c.lookup_attr("img.central-featured-logo", "src").unwrap().unwrap();
let raw = c.raw_client_for(fantoccini::Method::Get, &img).unwrap();
let mut res = raw.send().unwrap();

use std::io::prelude::*;
let mut pixels = Vec::new();
res.read_to_end(&mut pixels).unwrap();
println!("Wikipedia logo is {}b", pixels.len());

Look up an attribute value by name for the element matching selector.

selector should be a CSS selector. Ok(None) is returned if the element does not have the given attribute. Err(NoSuchElement) is returned if the element could not be found.

Look up a DOM property for the element matching selector.

selector should be a CSS selector. Ok(None) is returned if the element is not found, or it does not have the given property.

Look up the text contents of a node matching the given CSS selector.

Ok(None) is returned if the element was not found.

Look up the HTML contents of a node matching the given CSS selector.

Ok(None) is returned if the element was not found. inner dictates whether the wrapping node's HTML is excluded or not. For example, take the HTML:

<div id="foo"><hr /></div>

With inner = true, <hr /> would be returned. With inner = false, <div id="foo"><hr /></div> would be returned instead.

Simulate the user clicking on the element matching the given CSS selector.

For convenience, Ok(None) is returned if the element was not found.

Note that this may result in navigation.

Simulate the user clicking on a link with the given text.

For convenience, Ok(None) is returned if the element was not found.

The text matching is exact.

Follow the href target of the element matching the given selector without causing a click interaction.

For convenience, Ok(None) is returned if the element was not found, or if it does not have an href attribute.

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.

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.

Locate a form on the page.

Through the returned Form, HTML forms can be filled out and submitted.

Trait Implementations

impl Drop for Client
[src]

A method called when the value goes out of scope. Read more