<commit_before>#![deny(warnings)]

extern crate env_logger;
extern crate log;
extern crate serde_json;
extern crate webdriver;

use env_logger::LogBuilder;
use log::LogLevelFilter;
use std::env;
use webdriver::DriverSession;
use webdriver::firefox::GeckoDriver;
use webdriver::messages::ExecuteCmd;

#[test]
fn test_file() {
    init_logging();

    let gecko = GeckoDriver::new().unwrap();
    let mut sess = DriverSession::new(gecko).unwrap();

    // `cargo test` starts with current directory set to the crate root.
    let crate_root =
        std::env::current_dir().unwrap()
        .to_str().unwrap().to_owned();
    let test_url = format!("file://{crate}/tests/integration_test.html", crate = crate_root);

    sess.go(&test_url).unwrap();
    let url = sess.get_current_url().unwrap();
    assert_eq!(url, test_url);

    let title = sess.get_title().unwrap();
    assert_eq!(title, "Test page title");

    sess.back().unwrap();
    sess.forward().unwrap();
    sess.refresh().unwrap();
    sess.get_page_source().unwrap();

    sess.get_cookies().unwrap();
    sess.get_window_handle().unwrap();
    {
        let handles = sess.get_window_handles().unwrap();
        assert_eq!(handles.len(), 1);<commit_msg>Integration test includes firefox path (not just command name); new geckodriver seems to require it.<commit_after>#![deny(warnings)]

extern crate env_logger;
extern crate log;
extern crate serde_json;
extern crate webdriver;

use env_logger::LogBuilder;
use log::LogLevelFilter;
use std::env;
use webdriver::DriverSession;
use webdriver::firefox::GeckoDriver;
use webdriver::messages::ExecuteCmd;

#[test]
fn test_file() {
    init_logging();

    // TODO: Perhaps calculate path from PATH environment variable.
    let gecko = GeckoDriver::with_binary("/usr/bin/firefox").unwrap();
    let mut sess = DriverSession::new(gecko).unwrap();

    // `cargo test` starts with current directory set to the crate root.
    let crate_root =
        std::env::current_dir().unwrap()
        .to_str().unwrap().to_owned();
    let test_url = format!("file://{crate}/tests/integration_test.html", crate = crate_root);

    sess.go(&test_url).unwrap();
    let url = sess.get_current_url().unwrap();
    assert_eq!(url, test_url);

    let title = sess.get_title().unwrap();
    assert_eq!(title, "Test page title");

    sess.back().unwrap();
    sess.forward().unwrap();
    sess.refresh().unwrap();
    sess.get_page_source().unwrap();

    sess.get_cookies().unwrap();
    sess.get_window_handle().unwrap();
    {
        let handles = sess.get_window_handles().unwrap();
        assert_eq!(handles.len(), 1);
{'fraction_non_alphanumeric': 0.15669081204727411, 'fraction_numerical': 0.0007624857033930614, 'mean_word_length': 4.135029354207436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3937598', 'n_tokens_mistral': 857, 'n_tokens_neox': 848, 'n_words': 181}