stevepryde/thirtyfour

Chrome Driver Hanging

servonlewis opened this issue · 9 comments

Hello,

I am unsure how to troubleshoot this issue, but the library is hanging when using WebDriver::new(). I am using the Chrome Driver, with the 105 version.

I cannot get past the "let driver =" line.

This has worked before, and I think the only change was an update to the chrome version. I use the correct Driver version, and other selenium processes work correctly.

Version: thirtyfour = "0.31.0"

    println!("pre-driver");
    let mut caps = DesiredCapabilities::chrome();
    caps.add_chrome_arg("--enable-automation")?;
    let driver = WebDriver::new("http://server:4444/wd/hub", caps).await?;
    println!("driver");

What selenium version are you using?
I believe with selenium 4 you don't need the /wd/hub on the end of the url. Likewise if you're using chromedriver directly.

I will have to check the selenium version. I believe I've only looked at the chrome driver version.

I did however remove the rest of the url and it did not work, and other programs using the same url is still working.

I will double check in the morning though.

Ok cool. Have a look at the examples in the thirtyfour repo and see if they work.

Thirtyfour uses fantoccini to interact with the webdriver, and that uses hyper as the http client. I do plan to add a timeout at some point, but that isn't directly related to your issue.

Make sure the hyper client has access to your webdriver server, and that you're using http or https as required. You can also put the same url into postman and see what you get back.

If thirtyfour is hanging it would almost certainly be that the http post request to the webdriver server is waiting for a response.

What selenium version are you using?
I believe with selenium 4 you don't need the /wd/hub on the end of the url. Likewise if you're using chromedriver directly.

We are using selenium server standalone 3.141.59

Ok cool. Have a look at the examples in the thirtyfour repo and see if they work.

Thirtyfour uses fantoccini to interact with the webdriver, and that uses hyper as the http client. I do plan to add a timeout at some point, but that isn't directly related to your issue.

Make sure the hyper client has access to your webdriver server, and that you're using http or https as required. You can also put the same url into postman and see what you get back.

If thirtyfour is hanging it would almost certainly be that the http post request to the webdriver server is waiting for a response.

This is the error that I am receiving:

NewSessionError(
    NotW3C(
        String(
            "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"/assets/displayhelpservlet.css\" media=\"all\"/>\n  <link href=\"/assets/favicon.ico\" rel=\"icon\" type=\"image/x-icon\" />\n  <script src=\"/assets/jquery-3.1.1.min.js\" type=\"text/javascript\"></script>\n  <script src=\"/assets/displayhelpservlet.js\" type=\"text/javascript\"></script>\n  
<script type=\"text/javascript\">\n    var json = Object.freeze('{\"consoleLink\": \"\\u002fwd\\u002fhub\",\"type\": \"Standalone\",\"class\": \"org.openqa.grid.web.servlet.DisplayHelpHandler$DisplayHelpServletConfig\",\"version\": \"3.141.59\"}');\n  </script>\n</head>\n<body>\n\n<div id=\"content\">\n  <div id=\"help-heading\">\n    <h1><span id=\"logo\"></span></h1>\n    <h2>Selenium <span class=\"se-type\"></span>&nbsp;v.<span class=\"se-version\"></span></h2>\n  </div>\n\n  <div id=\"content-body\">\n    <p>\n      Whoops! The URL specified routes to this help page.\n    </p>\n    <p>\n      For more information about Selenium <span class=\"se-type\"></span> please see the\n      <a class=\"se-docs\">docs</a> and/or visit the <a class=\"se-wiki\">wiki</a>.\n      <span id=\"console-item\">\n        Or perhaps you are looking for the Selenium <span class=\"se-type\"></span> <a class=\"se-console\">console</a>.\n      </span>\n    </p>\n    <p>\n      Happy Testing!\n    </p>\n  </div>\n\n 
 <div>\n    <footer id=\"help-footer\">\n      Selenium is made possible through the efforts of our open source community, contributions from\n 
     these <a href=\"https://github.com/SeleniumHQ/selenium/blob/master/AUTHORS\">people</a>, and our\n      <a href=\"http://www.seleniumhq.org/sponsors/\">sponsors</a>.\n   </footer>\n  </div>\n </div>\n\n</body>\n</html>",
        ),
    ),
)

Sorry for the delay in getting back to you. I managed to replicate this issue locally. It works with selenium 4.x but not 3.x.
I believe this breakage was caused by the switch to the fantoccini backend, which is designed to work directly with the webdriver server (e.g. chromedriver / geckodriver etc). Selenium should still work, as should anything that conforms to the W3C spec.

In short the issue seems to be that fantoccini does not add the /session path to the url when creating a new session.

The workaround here is to use "http://server:4444/wd/hub/session" as your url. Note that this is only required for selenium 3.x. If you switch to selenium 4.x (which should be a drop-in replacement) you can instead just use "http://server:4444" on its own.

I'll add some documentation to this effect, because I think more people will trip up on this. It had me stumped for a while.

Extra docs added to main branch. Let me know if the http://server:4444/wd/hub/session url works for you.

Extra docs added to main branch. Let me know if the http://server:4444/wd/hub/session url works for you.

Thank you!! I will try it out in the morning (EST) and get back to you. I appreciate you working on this.

Worked like a charm! Thank you!