Puppeteer for Rust. It looks a little something like this:
use headless_chrome::{Browser, LaunchOptionsBuilder};
fn browse_wikipedia() -> Result<(), failure::Error> {
let options = LaunchOptionsBuilder::default().build().expect("Failed to find chrome");
let browser = Browser::new(options)?;
let tab = browser.wait_for_initial_tab()?;
tab.navigate_to("https://www.wikipedia.org")?;
tab.wait_for_element("input#searchInput")?
.click()?;
tab.type_str("WebKit")?
.press_key("Enter")?;
tab.wait_for_element("#firstHeading")?;
assert_eq!(true, tab.get_url().ends_with("WebKit"));
Ok(())
}
assert!(browse_wikipedia().is_ok());
For fuller examples, take a look at tests/simple.rs
and examples/real_world.rs
.
If you're looking to do general browser testing or scraping (rather than anything specific to Chrome / DevTools), you're probably better off with fantoccini for now. It's a lot more feature-complete and stable.
- Frame / iframe support
window.alert
handlers- Frankly, most of what's possible using the Chrome DevTools Protocol
Pull requests and issues are most welcome, even if they're just experience reports. If you find anything frustrating or confusing, let me know!