jonhoo / fantoccini

A high-level API for programmatically interacting with web pages through WebDriver.
Apache License 2.0
1.62k stars 120 forks source link

`Session::with_capabilities_and_connector` hides the WebDriver response #195

Open OtaK opened 1 year ago

OtaK commented 1 year ago

Hi!

I'm currently implementing a WASM browser-only test runner based on WebDriver & fantoccini and I was thinking of using WebDriver BiDi protocol to follow progress on tests.

But following up on that I couldn't find a way to get the original NewSession command response which contains the webSocketUrl that webdriver creates for the communication - after providing the { "websocketUrl": true, ...} capability.

https://w3c.github.io/webdriver-bidi/#establishing

Would it be possible to save the session handshake response somewhere and access it later?

Note: If needed I can make the PR myself. I honestly don't think WebDriver BiDi support is needed in fantoccini right now as it's still a W3C draft - but nonetheless at least partially implemented in all webdriver implementations -. And it would pull in a couple of other dependencies that are websocket-related. But if we could just access the NewSession response and extract the websocket URL, we could establish the connection from the outside quite easily for those use-cases.

Thanks!

jonhoo commented 1 year ago

That sounds like an entirely reasonable thing to add! I'm a fan of storing the NewSession response and making it accessible later :+1: A PR would be very welcome.