-
Couldn't load subscription status.
- Fork 277
Selenium CDP compatibility #424
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
Conversation
Mimic Chrome's endpoints to enable Selenium CDP connection.
Script example can be found here: lightpanda-io/demo#22
After establishing the connection, the first thing it does is issue this CDP command which we don't support:
{
"id": 1,
"method": "Target.getTargets",
"params": {
"filter": [
{ "exclude": true, "type": "browser" },
{ "exclude": true, "type": "page" },
{ "exclude": false}
]
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the branch for the demo project, I followed the instructions and ran pip install trio selenium. When I tried to run the selenium script against this PR, I got this error:
Message: session not created: cannot connect to chrome at 127.0.0.1:9222 from session not created: This version of ChromeDriver only supports Chrome version 133 Current browser version is 132.0.6834.110.
I wonder if this version response should be optionally loaded from the command line argument / a config file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
It looks like selenium is running a chrome --version command to select the right webdriver version.
So I guess it expects the same version is returned by the endpoint.
chromedriver not found in PATH
chrome detected at /usr/bin/google-chrome
Running command: /usr/bin/google-chrome --version
Output: "Google Chrome 132.0.6834.110 "
Detected browser: chrome 132.0.6834.110
Required driver: chromedriver 132.0.6834.159
chromedriver 132.0.6834.159 already in the cache
Driver path: /home/pierre/.cache/selenium/chromedriver/linux64/132.0.6834.159/chromedriver
Browser path: /usr/bin/google-chrome
Started executable: `/home/pierre/.cache/selenium/chromedriver/linux64/132.0.6834.159/chromedriver` in a child process with pid: 993207 using 0 to output -3
I would be better to configure selenium with the websocket url to connect to.
But Idk if it's possible.
Here It looks like it can either use an se:cdp capability or retrieve it from the /json/version endpoint. But I wasn't able to configure it properly for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured out that you can force which version it will download:
options = webdriver.ChromeOptions()
options.browser_version = '132'; # add this
# ...
It downloaded 132 instead of 133 with this, and it didn't complain about the version when I ran it.
Mimic Chrome's endpoints to enable Selenium CDP connection.
Selenium requires:
On
/json/version,Browserwith a Chrome version andWebkitVersion.On
json/list, at least one item containingid,urlandtype.