Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
krichprollsch wants to merge 1 commit into main
base: main
Choose a base branch
Loading
from selenium-cdp
Draft

Selenium CDP compatibility #424

krichprollsch wants to merge 1 commit into main from selenium-cdp

Conversation

@krichprollsch
Copy link
Member

@krichprollsch krichprollsch commented Feb 13, 2025

Mimic Chrome's endpoints to enable Selenium CDP connection.

Selenium requires:

On /json/version, Browser with a Chrome version and WebkitVersion.
On json/list, at least one item containing id, url and type.

⚠️ This PR blocks on WS connection.

Mimic Chrome's endpoints to enable Selenium CDP connection.
@krichprollsch krichprollsch changed the title (削除) server: implement /json/list (削除ここまで) (追記) Selenium CDP comaptibility (追記ここまで) Feb 13, 2025
Copy link
Member Author

Script example can be found here: lightpanda-io/demo#22

Copy link
Collaborator

karlseguin commented Feb 14, 2025
edited
Loading

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}
 ]
 }
}
krichprollsch reacted with thumbs up emoji

address: net.Address,
) ![]const u8 {
const body_format = "{{\"webSocketDebuggerUrl\": \"ws://{}/\"}}";
const body_format = "{{\"Browser\": \"Chrome/132.0.6834.110\", \"WebKit-Version\": \"537.36 (@df453a35f099772fdb954e33551388add2ca3cde)\", \"webSocketDebuggerUrl\": \"ws://{}/\"}}";
Copy link
Collaborator

@karlseguin karlseguin Feb 14, 2025

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?

Copy link
Member Author

@krichprollsch krichprollsch Feb 14, 2025

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.

Copy link
Collaborator

@karlseguin karlseguin Feb 15, 2025
edited
Loading

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.

@krichprollsch krichprollsch changed the title (削除) Selenium CDP comaptibility (削除ここまで) (追記) Selenium CDP compatibility (追記ここまで) Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@karlseguin karlseguin karlseguin left review comments

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /