WASM support
I haven't tried compiling this to WASM but I will assume it doesn't 😅
I might sound weird wanting to run a browser automation tool from a browser environment but I have a use case of a plug-in system where plugins are JS or Rust compiled to WASM running in a WebWorker, this plug-ins can run in the browser and the server with the help of Deno. The browser APIs limit me to use fetch or WebSocket based libraries so I was looking for Webdriver rust libraries that would use reqwest as HTTP client which supports compiling to browser WASM, I used fantoccini a bit and was planning to work on a fork that used reqwest but I'm glad to see Thirtyfour exists and the API might even be nicer.
Honestly I haven't tried compiling to WASM either. One thing I want to point out is that this library (and likewise fantoccini and other selenium/webdriver libraries) doesn't actually do any browser automation itself. Instead it issues HTTP requests/commands to a webdriver server (chromedriver/geckodriver etc) and it is the webdriver that actually takes care of launching another browser instance and interacting with it. Does that sound like what you're trying to do?
I'm wondering if it isn't easier to simply use javascript/WASM to control the browser you're currently running in, instead.
I guess that's where I'm still a little confused by what you're trying to do. To clarify, are you wanting to do web requests from a browser, to a local webdriver server (or I guess it could be remote if you wish), to then control a separate browser instance?
You got it right ;) I'm aware the webdriver server does the magic and the library is just a client. About the WASM/JS code controlling the current browser, unless I'm missing something one does not "just" control the current browser right? And for some of the stuff that I need to run(e.g. make a screen capture) it won't work to just let the Rust WASM code do things with the current document because this WASM plugin not only doesn't have DOM access(runs in a worker) but also doesn't know if it will be running in a browser or a server. Does it make sense? 😅 Anyway if I have time later enxt week I'll test the WASM compilation, doesn't seem that difficult maybe some parts of the code would need to be feature gated if they are doing things like accessing the file system.
Ok yes that makes sense. Let me know how the WASM compilation goes
@olanod you probably have to create a new HTTP request backend. The current default is reqwest which most likely will not even compile to WASM. However, wasm-bindgen or rather js-sys provides access to the native JavaScript APIs for making HTTP requests so it should not be too hard to work around it that way. AFAIK the HTTP client is already abstracted away in thirtyfour 🙂
Yes the http client is abstracted out and you can implement the relevant trait and supply your own.
I'm keen to see how far you get with this.