octaltree / playwright-rust

Playwright port to Rust
316 stars 36 forks source link

Fix basic file upload functionality -> ElementHandle#set_input_files #26

Open randall-coding opened 2 years ago

randall-coding commented 2 years ago

Why?

Changes made to address this issue https://github.com/octaltree/playwright-rust/issues/24

I also ran into a second issue half way through. The video file I was trying to upload would only partially upload and then stop.

How?

I fixed the first issue by modifying the File struct in utils.rs to call mime mimeType which, although breaking Rust naming conventions, ensures the driver is receiving the attribute name in the form it expects.

After fixing that, I found the upload was still not working correctly unto completion (specifically trying a file upload on Bitchute). To fix this issue I updated the playwright driver version. Current version is 1.11.0, which was upgraded to 1.12.2 to solve that issue. Trying to upgrade to higher versions (I tried 1.16 and 1.19) breaks the code because no "objects" are returned to the Context struct from the driver process stdout.

Tests

No tests were added and I did not fix the file_chooser test.

Before you test out the code yourself it is important to to delete the previous driver folder which is located at ~/.cache/ms-playwright/playwright-rust/driver , at least on Linux machines.