All Projects → jonhoo → Fantoccini

jonhoo / Fantoccini

Licence: other
A high-level API for programmatically interacting with web pages through WebDriver.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Fantoccini

Thirtyfour
Selenium WebDriver client for Rust, for automated testing of websites
Stars: ✭ 191 (-69.14%)
Mutual labels:  automation, webdriver
Element
💦Load test your app using real web browsers
Stars: ✭ 204 (-67.04%)
Mutual labels:  automation, webdriver
Xctestwd
A Swift implementation of WebDriver server for iOS that runs on Simulator/iOS devices.
Stars: ✭ 195 (-68.5%)
Mutual labels:  automation, webdriver
Wdio Workshop
WebdriverIO Workshop
Stars: ✭ 20 (-96.77%)
Mutual labels:  automation, webdriver
Undetected Chromedriver
Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
Stars: ✭ 365 (-41.03%)
Mutual labels:  automation, webdriver
Edge Selenium Tools
An updated EdgeDriver implementation for Selenium 3 with newly-added support for Microsoft Edge (Chromium).
Stars: ✭ 41 (-93.38%)
Mutual labels:  automation, webdriver
Appium
📱 Automation for iOS, Android, and Windows Apps.
Stars: ✭ 14,469 (+2237.48%)
Mutual labels:  automation, webdriver
Python Scripts
Collection of Various Python Script's.💻
Stars: ✭ 195 (-68.5%)
Mutual labels:  automation, webdriver
Winium.desktop
Winium.Desktop is Selenium Remote WebDriver implementation for automated testing of Windows application based on WinFroms and WPF platforms.
Stars: ✭ 326 (-47.33%)
Mutual labels:  automation, webdriver
Cdp4j
cdp4j - Chrome DevTools Protocol for Java
Stars: ✭ 232 (-62.52%)
Mutual labels:  automation, webdriver
Webdriverio
Next-gen browser and mobile automation test framework for Node.js
Stars: ✭ 7,214 (+1065.43%)
Mutual labels:  automation, webdriver
Whole Foods Delivery Slot
Automated script for Whole Foods and Amazon Fresh delivery slot
Stars: ✭ 460 (-25.69%)
Mutual labels:  automation, webdriver
Webdriver Rust
Library implementing the wire protocol for the W3C WebDriver standard.
Stars: ✭ 56 (-90.95%)
Mutual labels:  library, webdriver
Automation Arsenal
Curated list of popular Java and Kotlin frameworks, libraries and tools related to software testing, quality assurance and adjacent processes automation.
Stars: ✭ 105 (-83.04%)
Mutual labels:  automation, webdriver
Splinter
splinter - python test framework for web applications
Stars: ✭ 2,476 (+300%)
Mutual labels:  automation, webdriver
Golem
A complete test automation tool
Stars: ✭ 441 (-28.76%)
Mutual labels:  automation, webdriver
Webdriver
Remote control interface that enables introspection and control of user agents.
Stars: ✭ 546 (-11.79%)
Mutual labels:  automation, webdriver
Instagram Api
Instagram's private API
Stars: ✭ 5,168 (+734.89%)
Mutual labels:  library
Leku
🌍 Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
Stars: ✭ 612 (-1.13%)
Mutual labels:  library
Libtmux
⚙️ python api for tmux
Stars: ✭ 599 (-3.23%)
Mutual labels:  library

fantoccini

Crates.io Documentation Build Status Gitter chat

A high-level API for programmatically interacting with web pages through WebDriver.

This crate uses the WebDriver protocol to drive a conforming (potentially headless) browser through relatively high-level operations such as "click this element", "submit this form", etc.

Most interactions are driven by using CSS selectors. With most WebDriver-compatible browser being fairly recent, the more expressive levels of the CSS standard are also supported, giving fairly powerful operators.

Forms are managed by first calling Client::form, and then using the methods on Form to manipulate the form's fields and eventually submitting it.

For low-level access to the page, Client::source can be used to fetch the full page HTML source code, and Client::raw_client_for to build a raw HTTP request for a particular URL.

Examples

These examples all assume that you have a WebDriver compatible process running on port 4444. A quick way to get one is to run geckodriver at the command line. The code also has partial support for the legacy WebDriver protocol used by chromedriver and ghostdriver.

The examples will be using panic! or unwrap generously when errors occur (see map_err) --- you should probably not do that in your code, and instead deal with errors when they occur. This is particularly true for methods that you expect might fail, such as lookups by CSS selector.

Let's start out clicking around on Wikipedia:

use fantoccini::{Client, Locator};

// let's set up the sequence of steps we want the browser to take
#[tokio::main]
async fn main() -> Result<(), fantoccini::error::CmdError> {
    let mut c = Client::new("http://localhost:4444").await.expect("failed to connect to WebDriver");

    // first, go to the Wikipedia page for Foobar
    c.goto("https://en.wikipedia.org/wiki/Foobar").await?;
    let url = c.current_url().await?;
    assert_eq!(url.as_ref(), "https://en.wikipedia.org/wiki/Foobar");

    // click "Foo (disambiguation)"
    c.find(Locator::Css(".mw-disambig")).await?.click().await?;

    // click "Foo Lake"
    c.find(Locator::LinkText("Foo Lake")).await?.click().await?;

    let url = c.current_url().await?;
    assert_eq!(url.as_ref(), "https://en.wikipedia.org/wiki/Foo_Lake");

    c.close().await
}

How did we get to the Foobar page in the first place? We did a search! Let's make the program do that for us instead:

// -- snip wrapper code --
// go to the Wikipedia frontpage this time
c.goto("https://www.wikipedia.org/").await?;
// find the search form, fill it out, and submit it
let mut f = c.form(Locator::Css("#search-form")).await?;
f.set_by_name("search", "foobar").await?
 .submit().await?;

// we should now have ended up in the rigth place
let url = c.current_url().await?;
assert_eq!(url.as_ref(), "https://en.wikipedia.org/wiki/Foobar");

// -- snip wrapper code --

What if we want to download a raw file? Fantoccini has you covered:

// -- snip wrapper code --
// go back to the frontpage
c.goto("https://www.wikipedia.org/").await?;
// find the source for the Wikipedia globe
let mut img = c.find(Locator::Css("img.central-featured-logo")).await?;
let src = img.attr("src").await?.expect("image should have a src");
// now build a raw HTTP client request (which also has all current cookies)
let raw = img.client().raw_client_for(fantoccini::Method::GET, &src).await?;

// we then read out the image bytes
use futures_util::TryStreamExt;
let pixels = raw.into_body().try_concat().await.map_err(fantoccini::error::CmdError::from)?;
// and voilla, we now have the bytes for the Wikipedia logo!
assert!(pixels.len() > 0);
println!("Wikipedia logo is {}b", pixels.len());

// -- snip wrapper code --

For more examples, take a look at the examples/ directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].