Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chromeOptions is not the name of a known capability or extension capability #36

Closed
rochacbruno opened this issue Oct 2, 2018 · 7 comments

Comments

@rochacbruno
Copy link

I download and installed geckodriver

wget https://github.com/mozilla/geckodriver/releases/{latest}linux64.tar.gz
tar -xvzf geckodriver*
chmod +x geckodriver
geckodriver
(running on port 4444)

Used this code:

extern crate tokio;
extern crate futures;
extern crate fantoccini;

fn main() {
    use fantoccini::{Client, Locator};
    use futures::future::Future;
    let c = Client::new("http://localhost:4444");
   
    // let's set up the sequence of steps we want the browser to take
    tokio::run(
        c
            .map_err(|e| {
                unimplemented!("failed to connect to WebDriver: {:?}", e)
            })
            .and_then(|c| {
                // first, go to the Wikipedia page for Foobar
                c.goto("https://en.wikipedia.org/wiki/Foobar")
            })
            .and_then(|mut c| c.current_url().map(move |url| (c, url)))
            .and_then(|(mut c, url)| {
                assert_eq!(url.as_ref(), "https://en.wikipedia.org/wiki/Foobar");
                // click "Foo (disambiguation)"
                c.find(Locator::Css(".mw-disambig"))
            })
            .and_then(|e| e.click())
            .and_then(|mut c| {
                // click "Foo Lake"
                c.find(Locator::LinkText("Foo Lake"))
            })
            .and_then(|e| e.click())
            .and_then(|mut c| c.current_url())
            .and_then(|url| {
                assert_eq!(url.as_ref(), "https://en.wikipedia.org/wiki/Foo_Lake");
                Ok(())
            })
            .map_err(|e| {
                panic!("a WebDriver command failed: {:?}", e);
            })
    );
}

Result:

$ cargo run   
   Compiling web_ui_testing v0.1.0 (file:///home/rochacbruno/Projects/rust/i_am_learning_rust/web_ui_testing)           
    Finished dev [unoptimized + debuginfo] target(s) in 2.62s
     Running `target/debug/web_ui_testing`
thread 'tokio-runtime-worker-2' panicked at 'unexpected webdriver error; webdriver returned error: chromeOptions is not the name of a known capability or extension capability', /home/rochacbruno/.cargo/registry/src/github.com-1ecc6299db9ec823/fantoccini-0.11.2/src/session.rs:314:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'tokio-runtime-worker-2' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21
@rochacbruno
Copy link
Author

rochacbruno commented Oct 2, 2018

Same problem on nightly

@rochacbruno
Copy link
Author

There is a different error when using WebKitWebDriver -p 4444

 $ cargo run       
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s                                                           
     Running `target/debug/web_ui_testing`
thread 'tokio-runtime-worker-2' panicked at 'unexpected webdriver error; webdriver returned error: Invalid alwaysMatch capabilities', /home/rochacbruno/.cargo/git/checkouts/fantoccini-37a5b9f98b789092/c1c515d/src/session.rs:314:17
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'tokio-runtime-worker-1' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21

@jonhoo
Copy link
Owner

jonhoo commented Oct 2, 2018

Ah, good catch! This is because WebDriver apparently now serializes legacy new session parameters incorrect (see b030fc3). I'd worked around that by setting this capability, but it's Google Chrome specific, and I'd left off the vendor prefix (fixed in 65081eb). I think this should now be fixed in the about-to-be-published 0.11.3!

@jonhoo jonhoo closed this as completed Oct 2, 2018
@rochacbruno
Copy link
Author

Thanks!

I used

[dependencies.fantoccini]
git = "https://github.com/jonhoo/fantoccini"
rev = "52cf5b1f763a5f19d3735bafd378fede9d193a07"

And now it works with geckodriver

ut using WebKitWebDriver -p 4444 it still fails with

thread 'thread 'tokio-runtime-worker-2tokio-runtime-worker-3' panicked at '' panicked at 'not yet implemented: failed to connect to WebDriver: SessionNotCreated(WebDriverError { error: SessionNotCreated, message: "Failed to match capabilities", stack: "", delete_session: false })called `Option::unwrap()` on a `None` value', ', src/main.rslibcore/option.rs::14355::1721

@jonhoo I'll give a talk on saturday about testing strategies and Iam going to show Factoccini demo!

Thanks

@jonhoo
Copy link
Owner

jonhoo commented Oct 2, 2018

That's truly bizarre. As far as I can tell, we're hitting this line in WebKitWebDriver, but I don't see why the matched capabilities list would be empty. Can you try chromedriver instead?

@rochacbruno
Copy link
Author

@jonhoo chromedriver works fine! thanks

@jonhoo
Copy link
Owner

jonhoo commented Oct 2, 2018

Filed it as #37 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants