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.

Set the User Agent string to use for all subsequent requests.

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.by_selector("img.central-featured-logo").unwrap()
           .attr("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());

Find an element by CSS selector.

Find an element by its link text.

The text matching is exact.

Find an element using an XPath expression.

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