Coder Social home page Coder Social logo

Comments (7)

octaltree avatar octaltree commented on May 21, 2024

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.

The update went as follows

  1. Get the version of the driver from playwright-python and set it in build.rs
  2. scripts/Makefile
    2.1. Get interface definition json by doing playwright print-api-json with new driver
    2.2. scripts/src/gen.rs will create an incomplete generated.rs from json
  3. While copying and pasting generated.rs into each src/api/, fix generated structures and create builder types as an optional argument.
  4. Finally, if there is no implementation, port the implementation from typescript or python

types.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.

from playwright-rust.

d4h0 avatar d4h0 commented on May 21, 2024

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.

from playwright-rust.

d4h0 avatar d4h0 commented on May 21, 2024

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.

  1. 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:

  1. clone https://github.com/microsoft/playwright
  2. run node utils/doclint/generateApiJson.js > /tmp/api.json from that repo directory
  3. copy 'api.json' to the 'playwright-rust' repo: mv /tmp/api.json src/api/api.json

2.2. scripts/src/gen.rs will create an incomplete generated.rs from json

  1. cd into 'scripts'
  2. 'gen.rs' expects 'api.json' as input via stdin: run cat ../src/api/api.json | cargo run --bin gen

from playwright-rust.

octaltree avatar octaltree commented on May 21, 2024

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.

from playwright-rust.

d4h0 avatar d4h0 commented on May 21, 2024

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.

from playwright-rust.

octaltree avatar octaltree commented on May 21, 2024

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

from playwright-rust.

d4h0 avatar d4h0 commented on May 21, 2024

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.

from playwright-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.