Open d4h0 opened 2 years ago
Thank you for the issue that this crate holds. playwright is 1.15.2, but this crate is based on 1.11.0-1620331022000. I had to stop because there was a test that broke when I upgraded the version. I can ignore such details now.
playwright print-api-json
with new driver
2.2. scripts/src/gen.rs will create an incomplete generated.rs from jsontypes.json is a temporary file extracted from api.json to improve the type generation in gen.rs
I don't know if it will work though, since api.json is often changed and the directory structure of playwright is also changed.
Thanks for your fast response, @octaltree!
fix generated structures and create builder types as an optional argument. Finally, if there is no implementation, port the implementation from typescript or python
Will I get compiler error messages for all the missing things, or do I need to figure this out myself (e.g. by comparing the generated API to some API docs) ?
Get interface definition json by doing
playwright print-api-json
with new driver
playwright
is the command-line tool from the node.js Playwright package, right?
It seems, this doesn't work anymore (probably because api.json isn't bundled anymore).
Cloning 'https://github.com/microsoft/playwright', and running node utils/doclint/generateApiJson.js
generates 'api.json'. But I'm not sure, if there will be problems with compatibility.
I will add some notes to this issue, in case others want to contribute to this repo.
The issue that I've opened in the 'playwright' repo (linked above), might be interesting, too.
- Get the version of the driver from playwright-python and set it in build.rs
The version can be found in setup.py (search for 'driver_version = ').
2.1. Get interface definition json by doing
playwright print-api-json
with new driver
As mentioned above, playwright print-api-json
doesn't work anymore, instead:
node utils/doclint/generateApiJson.js > /tmp/api.json
from that repo directorymv /tmp/api.json src/api/api.json
2.2. scripts/src/gen.rs will create an incomplete generated.rs from json
cd
into 'scripts'stdin
: run cat ../src/api/api.json | cargo run --bin gen
This rust binding is something I'm doing on my own. I don't want it to be a conscious hindrance to the original. The author of Ruby Binding is really enthusiastic and keeps up with the latest. It is inevitable that there will be changes in the schema of the interface definition json. The type information in schema cannot be generated for the type of rust due to lack of information.
It's not that I've abandoned it, but it's become less of a priority because I don't find playwright clients as attractive as I used to. At the time of starting development, rust-headless-chrome had stopped being updated and chromiumoxide did not exist.
This rust binding is something I'm doing on my own. I don't want it to be a conscious hindrance to the original. The author of Ruby Binding is really enthusiastic and keeps up with the latest. It is inevitable that there will be changes in the schema of the interface definition json.
Don't worry, @octaltree. I know a binding like this is a lot of work to keep up-to-date. I hope you don't think that I'm criticizing you or anything. I just wanted to share my notes with other people who might want to contribute to this project. For example, so that people don't have to search for the version of the current driver, and just can open the file that contains it via the link I've posted above.
I just tried to generate the interface.
sed 's/1.11.0-1620331022000/1.16.0-next-1634703014000/' -i src/build.rs
rm -r /tmp/build-playwright-rust # remove download cache
rm -r ~/.cache/ms-playwright/playwright-rust/driver # remove runtime driver
cd scripts
make ../src/api/api.json # success
make ../src/api/generated.rs # thread 'main' panicked at 'internal error: entered unreachable code', src/gen.rs:335:22
It's not that I've abandoned it, but it's become less of a priority because I don't find playwright clients as attractive as I used to. At the time of starting development, rust-headless-chrome had stopped being updated and chromiumoxide did not exist.
The reason why I'd like to use Playwright is because it has more features than 'rust-headless-chrome' and 'chromiumoxide'.
However, a comment from one of the Playwright maintainers in the issue I've linked above discouraged me a bit to work on a Rust binding for Playwright. Tomorrow I'll think about if I shouldn't better focus on contributing to 'rust-headless-chrome' or 'chromiumoxide'.
A DevTools protocol client also seems easier to maintain because there is a machine-readable definition of the protocol that can be used to generate the complete Rust API. It seems with Playwright this isn't possible and its required to implement parts of the API by hand (e.g. derive it from the Python client). Not needing to package a node.js environment is also a great advantage.
Hi,
It would be great, if you would publish some instructions about how to update this crate to the latest Playwright version, and how to contribute to this crate in general if there is a new feature in Playwright that the code generator doesn't cover.
Since the last release of this crate on crates.io, Playwright has released many new versions.
My assumption is therefore, that this crate isn't up-to-date anymore, and I'm a bit worried about using it.
Therefore, I'd like to know how to update this crate to the latest Playwright version locally.
I've seen, that there are some "scripts" that generate code, so I guess the workflow isn't too complicated.
A short step-by-step guide would still be useful, however.
For example, lets say Playwright adds a new function or class – would this somehow automatically be covered by the code generator? Or would I have to change the code generator?
Or: There is a "scripts/types.json" – where does this file come from? I guess I'd have to get or generate the latest version of this file.
Thanks for publishing this crate!