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

[Firefox] find_element() returns Json(Error("invalid type: null ... #34

Open
NiklasRosenstein opened this issue Aug 4, 2020 · 3 comments

Comments

@NiklasRosenstein
Copy link

Hey, first time using selenium-rs, and also I'm a Rust newbie.

fn wait_for_element<'a, F, T>(f: F, interval: u32) -> Element<'a>
  where F: Fn() -> Result<Element<'a>, T>, T: std::fmt::Debug
{
  loop {
    match f() {
      Ok(el) => return el,
      Err(err) => println!("{:?}", err)
    }
    std::thread::sleep_ms(interval);
  }
}

impl ProfileConfig {

  /// Performs the login-flow with Selenium.
  #[allow(unused_must_use)]
  fn login_flow(&self, twofa: &str) {
    let mut driver = WebDriver::new(Browser::Firefox);
    driver.start_session();
    driver.navigate(&self.url.as_str());
    let el = wait_for_element(|| driver.find_element(Selector::ID, "vpnForm"), 1000);
    println!("Got element: {:?}", el)
  }

}

This leaves me with the following in the console:

Error(Status(500), "http://localhost:4444/wd/hub/session/0ac0314d-66e2-7041-b83c-5f3bcabd84d7/element")
Error(Status(500), "http://localhost:4444/wd/hub/session/0ac0314d-66e2-7041-b83c-5f3bcabd84d7/element")
Error(Status(500), "http://localhost:4444/wd/hub/session/0ac0314d-66e2-7041-b83c-5f3bcabd84d7/element")
Error(Json(Error("invalid type: null, expected a string", line: 3, column: 19)))
Error(Json(Error("invalid type: null, expected a string", line: 3, column: 19)))

The Status(500) errors is while the page has not fully loaded. Then the Json(Error(... appears once the page is loaded, so I'm assuming that the element now exists but something is going wrong in the communication with the Selenium Server?

There's nothing in the Selenium Server's stdout that seems to have a correlation with this error.

I tried using Browser::Chrome but unfortunately that leaves me with this error message instead (I believe this is due to the Chrome configuration deployed by my company disallowing loading of custom Java Script which appears to be injected by Selenium).

image

@NiklasRosenstein
Copy link
Author

Actually the Chrome version works when I use a chromedriver with the correct version 😄 It still shows the popup, but it works.

@Y0GAAAA
Copy link

Y0GAAAA commented Nov 14, 2020

Actually the Chrome version works when I use a chromedriver with the correct version 😄 It still shows the popup, but it works.

Could you link the right versions for the Java server and the chrome WebDriver ? I can't seem to find any working combination that does not throw "Error(Json(Error("invalid type: null, expected a string", line: 3, column: 19)))"

Sorry for being late :/

@nixpulvis
Copy link

Same issue as #35.

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

3 participants