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

Getting started and unable to run first example #271

Open
smolattack opened this issue Aug 28, 2024 · 2 comments
Open

Getting started and unable to run first example #271

smolattack opened this issue Aug 28, 2024 · 2 comments

Comments

@smolattack
Copy link

smolattack commented Aug 28, 2024

Is there a getting started guide I could use? I looked in the examples folder but these don't seem to be complete projects. Quite new to Rust so not sure how to get started. I tried to make a project to run the first example in the readme but immediately got an error.

cargo run
   Compiling scraper-wiki v0.1.0 (~/code/scraper-wiki)
error[E0599]: no function or associated item named `rustls` found for struct `ClientBuilder` in the current scope
   --> src/main.rs:12:28
    |
12  |     let c = ClientBuilder::rustls()
    |                            ^^^^^^ function or associated item not found in `ClientBuilder<_>`
    |
note: if you're trying to build a new `ClientBuilder<_>` consider using one of the following associated functions:
      ClientBuilder::<hyper_tls::client::HttpsConnector<hyper_util::client::legacy::connect::http::HttpConnector>>::native
      ClientBuilder::<C>::new
   --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fantoccini-0.21.1/src/lib.rs:198:5
    |
198 |     pub fn native() -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^
...
207 |     pub fn new(connector: C) -> Self {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0599`.
error: could not compile `scraper-wiki` (bin "scraper-wiki") due to 1 previous error

Cargo.toml

[package]
name = "scraper-wiki"
version = "0.1.0"
edition = "2021"

[dependencies]
fantoccini = "0.21.1"
tokio = { version = "1.39.3", features = ["rt-multi-thread", "macros"] }
@smolattack
Copy link
Author

smolattack commented Aug 28, 2024

Ok fixed first error by changing Cargo.toml to

[package]
name = "scraper-wiki"
version = "0.1.0"
edition = "2021"

[dependencies]
fantoccini = { version = "0.21.1", features = ["rustls-tls"] }
tokio = { version = "1.39.3", features = ["rt-multi-thread", "macros"] }

After running cargo run a Firefox window opens but I get the following error

warning: unused variable: `c`
 --> src/main.rs:7:9
  |
7 |     let c = ClientBuilder::native()
  |         ^ help: if this is intentional, prefix it with an underscore: `_c`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: `scraper-wiki` (bin "scraper-wiki") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 17.31s
     Running `target/debug/scraper-wiki`
thread 'main' panicked at src/main.rs:16:10:
failed to connect to WebDriver: SessionNotCreated(WebDriver { error: SessionNotCreated, message: "Session is already started", stacktrace: "", data: None })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I installed geckodriver 0.35.0 with cargo install geckodriver and then started it with "geckodriver". The output of that terminal is

1724843444165	geckodriver	INFO	Listening on 127.0.0.1:4444
1724844860128	mozrunner::runner	INFO	Running command: MOZ_CRASHREPORTER="1" MOZ_CRASHREPORTER_NO_REPORT="1" MOZ_CRASHREPORTER_SHUTDOWN="1" MOZ_NO_REMOTE="1" "/usr/bin/firefox" "--marionette" "-no-remote" "-profile" "/tmp/rust_mozprofileq0ETJR"
console.warn: services.settings: Ignoring preference override of remote settings server
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
1724844860628	Marionette	INFO	Marionette enabled
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
1724844860840	Marionette	INFO	Listening on port 45503
Read port: 45503
console.error: ({})
1724844890706	addons.xpi	ERROR	System addon update list error SyntaxError: XMLHttpRequest.open: 'http://%(server)s/dummy-system-addons.xml' is not a valid URL.
1724844894253	Marionette	INFO	Stopped listening on port 45503
[Parent 68215, IPC I/O Parent] WARNING: process 68395 is a zombie: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_posix.cc:245
[Parent 68215, IPC I/O Parent] WARNING: process 68355 is a zombie: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_posix.cc:245
JavaScript error: chrome://remote/content/marionette/cert.sys.mjs, line 47: NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsICertOverrideService.setDisableAllSecurityChecksAndLetAttackersInterceptMyData]
[Parent 68215, IPC I/O Parent] WARNING: process 68505 is a zombie: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_posix.cc:245
[Parent 68215, IPC I/O Parent] WARNING: process 68499 is a zombie: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_posix.cc:245
[Parent 68215, IPC I/O Parent] WARNING: process 68512 is a zombie: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_posix.cc:245

@smolattack
Copy link
Author

Ok correction, I didn't copy the example from the readme but from docs.rs. The example from this repo's readme works but could use some improvement. We're not told what to expect when running the example (from the observer's POV, a browser window opens up and closes before you could see what has happened). How do we check the result of the test run? Do we have to manage the test log ourselves and if so, a suggestion or an example would be helpful.

Finally, is this the correct place to report the broken example code block on the docs page https://docs.rs/fantoccini/0.21.1/fantoccini/?

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

1 participant