Comments (9)
Turns out that you need the version of Chrome to be the same as the version of Chromedriver. That solved our problem.
from hound.
You may want to load hound as a local dependency and put some IO.puts
on the requests and responses. I was getting the same error message as you, and when hound made a call to http://localhost:9515/session
the result was:
{"sessionId":"d6187f3aee07899a2f7773ffcd967ff6","status":33,"value":{"message":"session not created: This version of ChromeDriver only supports Chrome version 77\n (Driver info: chromedriver=77.0.3865.10 (bc3579f611bbc73331171afe020ec7a45e6ccc55-refs/branch-heads/3865@{#93}),platform=Linu\
x 3.13.0-24-generic x86_64)"}}
I didn't investigate further, but you can see that there's a sessionId
that hound probably tries to use again, but according to the embedded message (session not created: This version of ChromeDriver only supports Chrome version 77
) it's not valid.
Would love to see this error surfaced cos I just spent 3 hours tracking it down. 💯
It makes me think that libraries that wrap http apis should have a simple debug toggle so you can see all requests and responses, cos something in those usually seems to be the problem. Maybe they do and I just missed it.
Love that hound exists, it's crucial! 🥇
from hound.
Hi @edwinthinks,
I experienced the same error locally in earlier today and installing google-chrome-stable helped in my case. Maybe CI environment is also missing one of the dependencies. Thought to share it in case it might help someone else.
My Vagrant box with Ubuntu 18 inludes Google Chrome 75.0.3770.80
and ChromeDriver 75.0.3770.8
.
from hound.
Having a similar issue, macOS Mojave.
@edwinthinks have you solved this?
@mimimalizam. How did you install google-chrome-stable
? Any difference in the workflow? If so, could you please post them here?
Thank you!
from hound.
@pdgonzalez872 hey there; I didn't end up getting any solution :( I haven't had much time with using hound lately and left it as is. Hope you find a solution :)!
from hound.
Can we close this issue @edwinthinks?
from hound.
@pdgonzalez872 sure although I haven't been actively working with hound. If its reported working I can close this and only reopen if there is still an issue. Thanks @pdgonzalez872 !
from hound.
Problem Statement
I have the same problem collecting performance metrics from a company-internal website.
I do not have the problem with the first session, that works perfectly, but if I try to asynchronously start another session I get the following error and both sessions crash (Browser windows open and the first session already navigated to the website):
13:13:25.005 [error] Task #PID<0.274.0> started from #PID<0.269.0> terminating
** (RuntimeError) invalid session id
(hound) lib/hound/request_utils.ex:52: Hound.RequestUtils.handle_response/3
(hound_playground) lib/hound_playground.ex:56: HoundPlayground.collect_performance_metrics/2
(elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<0.22341430/0 in HoundPlayground.async_pisa_test/2>
Both chromedriver and chromium have the same version:
sc1se@VM-65220044-Linux:~$ chromium-browser --version
Chromium 77.0.3865.90 Built on Ubuntu , running on Ubuntu 18.04
sc1se@VM-65220044-Linux:~$ chromedriver --version
ChromeDriver 77.0.3865.90 (58c425ba843df2918d9d4b409331972646c393dd-refs/branch-heads/3865@{#830})
I initialize each session with the following:
@chrome_prefs %{"protocol_handler" => %{"excluded_schemes" => %{"psadims" => false}}}
def start_new_session() do
args =
if System.get_env("browser") == "headless" do
["user-data-dir=/home/sc1se/.chromedriver", "headless"]
else
["user-data-dir=/home/sc1se/.chromedriver"]
end
Hound.start_session(
metadata: %{pid: self(), safe: false},
driver: %{
chromeOptions: %{
"args" => args,
"prefs" => @chrome_prefs
}
},
browser: "chrome_driver"
)
end
The error also occurred when I used google-chrome (same major-, minor- and patch-version, only the build was a different one) instead of chromium.
Therefore this error is not only due to version differences in chromedriver and chrome. Any ideas why I get an invalid id error?
Solution
My problem was the my user-data-dir
was the same for both sessions. Now I just appended the user-data-dir with a randomlz generaed character string e.g.: :crypto.strong_rand_bytes(5) |> Base.url_encode64() |> binary_part(0, 5)
.
I only found the problem thanks to @formido. I recompiled the Hound dependency with the following simple changes in the file deps/hound/lib/hound/request_utils.ex
in the sending and receiving functions. I added a puts function before the request is sent to chromedriver and after the response is received.
defp send_req(type, path, params, options) do
url = get_url(path)
has_body = params != %{} && type == :post
{headers, body} = cond do
has_body && options[:json_encode] != false ->
{[{"Content-Type", "text/json"}], Jason.encode!(params)}
has_body ->
{[], params}
true ->
{[], ""}
end
IO.puts("the params #{inspect params}, the options #{inspect options}") # Here the request to chromedriver
:hackney.request(type, url, headers, body, [:with_body | http_options()])
|> handle_response({url, path, type}, options)
end
defp handle_response({:ok, code, headers, body}, {url, path, type}, options) do
IO.puts("the params #{inspect body}, the code #{inspect code} the options #{inspect options}") # Here the response from chromedriver
case Hound.ResponseParser.parse(response_parser(), path, code, headers, body) do
:error ->
raise """
Webdriver call status code #{code} for #{type} request #{url}.
Check if webdriver server is running. Make sure it supports the feature being requested.
"""
{:error, err} = value ->
if options[:safe],
do: value,
else: raise err
response -> response
end
end
Thus I get the following logging:
the params %{desiredCapabilities: %{browserName: "chrome_driver", chromeOptions: %{"args" => ["user-data-dir=/home/sc1se/.chromedriver"], "prefs" => %{"protocol_handler" => %{"excluded_schemes" => %{"psadims" => false}}}}, cssSelectorsEnabled: true, javascriptEnabled: false, nativeEvents: false, platform: "ANY", rotatable: false, takesScreenshot: true, version: ""}}, the options %{}
the params "{\"sessionId\":\"e3332b47e7527c99dadb17d4d85ffc1e\",\"status\":61,\"value\":{\"message\":\"invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir\\n (Driver info: chromedriver=77.0.3865.90 (58c425ba843df2918d9d4b409331972646c393dd-refs/branch-heads/3865@{#830}),platform=Linux 5.0.0-31-generic x86_64)\"}}", the code 200 the options %{}
the params %{url: "https://pisasales.elobau.de:9443/pisatest/pisasales"}, the options %{}
the params "{\"value\":{\"error\":\"invalid session id\",\"message\":\"invalid session id\",\"stacktrace\":\"#0 0x558b42a125c9 \\u003Cunknown>\\n\"}}", the code 404 the options %{}
Telling me I should not use user-data-dir again as it is already locked by another session.
I love hound but I suggest to improve the accuracy of the returned error. The error message only states the result but not what caused it.
from hound.
Turns out that you need the version of Chrome to be the same as the version of Chromedriver. That solved our problem.
Confirmed, same here. Windows 10.
from hound.
Related Issues (20)
- "catch" should always come after "rescue" in try [Question] HOT 1
- anonymous functions in execute_script
- Fix broken source links from hexdocs HOT 1
- Hound + Selenium/Firefox does not work with `find_element` HOT 3
- set_cookie error with ChromeDriver
- release a new version? is this package still maintained? HOT 2
- Can "other element would receive the click" become an error?
- Change driver in start_session
- Problem with acceptance test in hound not starting server on port 4001 in phoenix HOT 2
- Could not transform value %{"element-6066-11e4-a52e-4f735466cecf" => "d2c5deba-fdff-48db-b319-694aa6542c81"} to element HOT 2
- Support w3c for latest chrome / chromedriver releases HOT 2
- Using hound on Heroku HOT 2
- Incomplete list of keys in the documentation of set_keys
- 1.1.0 3be56f4 mismatch between github and hex HOT 5
- Should all retries load from :retries configuration value? HOT 1
- chromedriver can't start automatically HOT 2
- Improvement: the retry argument of find_element
- fill_field(email, "[email protected]")) transforms `@` into `_`
- Headless Chrome sessions not starting on recent Chrome versions HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hound.