octaltree / playwright-rust

Playwright port to Rust
316 stars 36 forks source link

Error: files[0].mimeType: expected string, got undefined. Even though I'm supplying the mime type string. #24

Open randall-coding opened 2 years ago

randall-coding commented 2 years ago

I'm having this error while attempting to upload a file using set_input_files_builder(). I'm supplying a file and mime type but I'm receiving an error that files[0].mimeType is undefined, how could this be?

Here is the code in question:

let file:File = File::new("Test".to_string(), "video/mp4".to_string(), &std::fs::read("/home/super/Downloads/test.mp4").unwrap());
video_input.set_input_files_builder(file).set_input_files().await.unwrap();

I'm new to playwright and even when I use Selenium I haven't been uploading files. So I may be just being a newb here. Any help is greatly appreciated.

litttley commented 2 years ago

I have the same problem, how to solve it

randall-coding commented 2 years ago

@littley It may be this feature is not yet implemented in playwright-rust. I say "may be" because I couldn't get any official word from the devs yet.

But when I look at the tests folder the only test commented out is the test involving file upload. The test is tests/page/mod.rs#file_chooser. I'm yet to actually run those tests to investigate further.

I am also planning on testing this by downloading playwright-java (or python) and testing the feature to make sure it works there and that this isn't a problem with my system.

randall-coding commented 2 years ago

@litttley UPDATE: I've got something working and made a pull request for it here https://github.com/octaltree/playwright-rust/pull/26

To run it you'll first need to delete the previous downloaded driver at ~/.cache/ms-playwright/playwright-rust/driver.

Then you'll need to clone the pull request locally into your project folder and tell cargo to add it as a dependency

Here is what I added to my Cargo.toml file to do that: playwright = { path = "./playwright-rust"} under [dependencies]