Giter Site home page Giter Site logo

playwright-rust's People

Contributors

octaltree avatar west14 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

playwright-rust's Issues

Playwright breaks if serde_json is used with arbitrary-precision feature.

Playwright fails to load any browser correctly if one has the following dependency in Cargo.toml

serde_json = { version = "1.0.66", features = [ "arbitrary_precision" ] }

If one removes features = [ "arbitrary_precision"], then it works.
This occurs on at least the async-std and tokio executors.

I would love to submit a PR to fix this bug, but I have not the foggiest idea how to get started fixing it. :-/

Reproduction case

use std::env;

use playwright::Playwright;

#[async_std::main]
async fn main() -> Result<(), playwright::Error> {
  if env::var("TOY_LOG").is_err() {
    env::set_var("TOY_LOG", "warn");
  }
  pretty_env_logger::try_init_custom_env("TOY_LOG").unwrap();

  let playwright = Playwright::initialize().await?;
  playwright.prepare()?; // Install browsers
  log::debug!("Creating browser.");
  let chromium = playwright.chromium();
  let browser = chromium.launcher().headless(false).launch().await?;
  log::debug!("Creating context.");
  let context = browser.context_builder().build().await?;
  let page = context.new_page().await?;
  page.goto_builder("https://en.wikipedia.org/").goto().await?;

  log::info!("Success");
  Ok(())
}

Logs

Here are the logs you get if you try to load with arbitrary_precision feature turned on:

 DEBUG toy                              > Creating browser.
 DEBUG playwright::imp::core::transport > SEND Req { id: 1, guid: "browser-type@22850ecee7392c91106a2feb3a1d26d5", method: "launch", params: {"headless": Bool(false)} }
 DEBUG playwright::imp::core::transport > RECV {"guid":"browser-type@22850ecee7392c91106a2feb3a1d26d5","method":"__create__","params":{"type":"Browser","initializer":{"version":"92.0.4498.0","name":"chromium"},"guid":"browser@c75fc2aa6fc81ca08a6bdf31ba109637"}}
 DEBUG playwright::imp::core::transport > RECV {"id":1,"result":{"browser":{"guid":"browser@c75fc2aa6fc81ca08a6bdf31ba109637"}}}
Error: Arc(Transport(Serde(Error("data did not match any variant of untagged enum Res", line: 0, column: 0))))

Traceback

And here is the traceback you get if you change the appropriate ? to .unwrap() and run with RUST_BACKTRACE=1:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Transport(Serde(Error("data did not match any variant of untagged enum Res", line: 0, column: 0)))', src/main.rs:16:68
stack backtrace:
   0: rust_begin_unwind
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/result.rs:1299:23
   4: toy::main::main::{{closure}}
             at ./src/main.rs:16:17
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/future/mod.rs:80:19
   6: toy::main::{{closure}}
             at ./src/main.rs:5:1
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/future/mod.rs:80:19
   8: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/builder.rs:199:17
   9: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/task_locals_wrapper.rs:60:13
  10: std::thread::local::LocalKey<T>::try_with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:399:16
  11: std::thread::local::LocalKey<T>::with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:375:9
  12: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/task_locals_wrapper.rs:55:9
  13: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/builder.rs:197:13
  14: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:526:33
  15: async_executor::Executor::run::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:242:9
  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/future/mod.rs:80:19
  17: async_executor::LocalExecutor::run::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:447:9
  18: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/future/mod.rs:80:19
  19: async_io::driver::block_on
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-io-1.6.0/src/driver.rs:142:33
  20: async_global_executor::reactor::block_on::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.0.2/src/reactor.rs:3:18
  21: async_global_executor::reactor::block_on
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.0.2/src/reactor.rs:12:5
  22: async_global_executor::executor::block_on::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.0.2/src/executor.rs:26:36
  23: std::thread::local::LocalKey<T>::try_with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:399:16
  24: std::thread::local::LocalKey<T>::with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:375:9
  25: async_global_executor::executor::block_on
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.0.2/src/executor.rs:26:5
  26: async_std::task::builder::Builder::blocking::{{closure}}::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/builder.rs:171:25
  27: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/task_locals_wrapper.rs:60:13
  28: std::thread::local::LocalKey<T>::try_with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:399:16
  29: std::thread::local::LocalKey<T>::with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:375:9
  30: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/task_locals_wrapper.rs:55:9
  31: async_std::task::builder::Builder::blocking::{{closure}}
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/builder.rs:168:17
  32: std::thread::local::LocalKey<T>::try_with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:399:16
  33: std::thread::local::LocalKey<T>::with
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/std/src/thread/local.rs:375:9
  34: async_std::task::builder::Builder::blocking
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/builder.rs:161:9
  35: async_std::task::block_on::block_on
             at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.10.0/src/task/block_on.rs:33:5
  36: toy::main
             at ./src/main.rs:5:1
  37: core::ops::function::FnOnce::call_once
             at /rustc/09c42c45858d5f3aedfa670698275303a3d19afa/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Not implemented yet

class Request(AsyncBase):
    def redirected_to(self) -> typing.Optional["Request"]: # mutable
    def failure(self) -> typing.Optional[str]: # mutable
    def timing(self) -> ResourceTiming: # mutable
class WebSocket(AsyncBase):
    def expect_event( # event timeout
    async def wait_for_event( # event timeout
    def is_closed(self) -> bool: # event
class ElementHandle(JSHandle):
    async def select_option( # convert_select_option_values
    async def set_input_files( # normalize_file_payloads
class FileChooser(AsyncBase):
    def page(self) -> "Page":
    def element(self) -> "ElementHandle":
    def is_multiple(self) -> bool:
    async def set_files(
class Frame(AsyncBase):
    def page(self) -> "Page": # mutable
    def name(self) -> str: # event mutable
    def url(self) -> str: # event mutable
    def parent_frame(self) -> typing.Optional["Frame"]: # mutable
    def child_frames(self) -> typing.List["Frame"]: # mutable
    def expect_navigation( # event
    async def wait_for_load_state( # event
    def is_detached(self) -> bool: # event mutable
    async def select_option( # convert_select_option_values
    async def set_input_files( # normalize_file_payloads
    async def wait_for_function( # event
class Worker(AsyncBase):
    def url(self) -> str:
    async def evaluate(self, expression: str, arg: typing.Any = None) -> typing.Any:
    async def evaluate_handle(
class ConsoleMessage(AsyncBase):
    def type(self) -> str:
    def text(self) -> str:
    def args(self) -> typing.List["JSHandle"]:
    def location(self) -> SourceLocation:
class Dialog(AsyncBase):
    def type(self) -> str:
    def message(self) -> str:
    def default_value(self) -> str:
    async def accept(self, prompt_text: str = None) -> NoneType:
    async def dismiss(self) -> NoneType:
class Download(AsyncBase):
    def url(self) -> str:
    def suggested_filename(self) -> str:
    async def delete(self) -> NoneType:
    async def failure(self) -> typing.Optional[str]:
    async def path(self) -> typing.Optional[pathlib.Path]:
    async def save_as(self, path: typing.Union[str, pathlib.Path]) -> NoneType:
class Video(AsyncBase):
    async def path(self) -> pathlib.Path:
class Page(AsyncBase):
    def context(self) -> "BrowserContext": # mutable
    def frames(self) -> typing.List["Frame"]: # mutable
    def url(self) -> str: # event
    def viewport_size(self) -> typing.Optional[ViewportSize]: # mutable
    def workers(self) -> typing.List["Worker"]: # mutable
    def video(self) -> typing.Optional["Video"]: # mutable
    def frame( # mutable
    def set_default_navigation_timeout(self, timeout: float) -> NoneType: # timeout
    def set_default_timeout(self, timeout: float) -> NoneType: # timeout
    async def expose_function(self, name: str, callback: typing.Callable) -> NoneType: # mutable
    async def expose_binding( # mutable
    async def wait_for_load_state( # event
    async def wait_for_event( # event
    async def set_viewport_size(self, viewport_size: ViewportSize) -> NoneType: # mutable
    async def route( # mutable
    async def unroute( # mutable
    def is_closed(self) -> bool: # event
    async def select_option( # convert_select_option_values
    async def set_input_files( # normalize_file_payloads
    async def wait_for_function( # event
    async def pause(self) -> NoneType: # mutable
    def expect_event( # event
    def expect_console_message( # event
    def expect_download( # event
    def expect_file_chooser( # event
    def expect_navigation( # event
    def expect_popup( # event
    def expect_request( # event
    def expect_response( # event
    def expect_worker( # event
class BrowserContext(AsyncBase):
    async def expose_binding( # mutable
    async def expose_function(self, name: str, callback: typing.Callable) -> NoneType: # mutable
    async def route( # mutable
    async def unroute( # mutable
    def expect_event( # evnet
    async def wait_for_event( # event
    def expect_page( # event

_browser_context.py:63:14         self._channel.on("bindingCall"
_browser_context.py:67:14         self._channel.on("close", lambda _: self._on_close())
_browser_context.py:71:14         self._channel.on("route"
_page.py:129:14         self._channel.on(
_page.py:133:14         self._channel.on("close", lambda _: self._on_close())
_page.py:134:14         self._channel.on(
_page.py:140:14         self._channel.on("crash", lambda _: self._on_crash())
_page.py:141:14         self._channel.on("dialog", lambda params: self._on_dialog(params))
_page.py:142:14         self._channel.on(
_page.py:145:14         self._channel.on(
_page.py:151:14         self._channel.on(
_page.py:160:14         self._channel.on(
_page.py:164:14         self._channel.on(
_page.py:168:14         self._channel.on("load", lambda _: self.emit(Page.Events.Load))
_page.py:169:14         self._channel.on(
_page.py:175:14         self._channel.on(
_page.py:179:14         self._channel.on(
_page.py:185:14         self._channel.on(
_page.py:193:14         self._channel.on(
_page.py:199:14         self._channel.on(
_page.py:205:14         self._channel.on(
_page.py:211:14         self._channel.on(
_page.py:217:14         self._channel.on(
_page.py:223:14         self._channel.on(
_page.py:882:14         self._channel.on("close", lambda _: self._on_close())
_frame.py:75:14         self._channel.on("loadstate"
_frame.py:79:14         self._channel.on("navigated"
_network.py:279:14         self._channel.on(
_network.py:283:14         self._channel.on(
_network.py:287:14         self._channel.on(
_network.py:290:14         self._channel.on("close", lambda params: self._on_close())
_js_handle.py:35:14         self._channel.on(


BrowserContextImpl.java:389:18   protected void handleEvent(String event, JsonObject params) {
PageImpl.java:113:18   protected void handleEvent(String event, JsonObject params) {
FrameImpl.java:913:18   protected void handleEvent(String event, JsonObject params) {
WorkerImpl.java:97:18   protected void handleEvent(String event, JsonObject params) {
JSHandleImpl.java:106:8   void handleEvent(String event, JsonObject parameters) {
JSHandleImpl.java:110:11     super.handleEvent(event, parameters);
WebSocketImpl.java:168:8   void handleEvent(String event, JsonObject parameters) {

Please publish instructions about how to update the API bindings to the latest version

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!

Is it possible to use just a filepath for file upload with set_input_files_builder()?

I see that for other languages using playwright it is possible to just provide an element and a filepath to perform file upload https://stackoverflow.com/questions/66132097/playwright-upload-files-from-non-input-element-that-cannot-be-used-page-setinpu

But looking at the source for playwright-rust it appears that I need a File struct which consists of

pub struct File {
pub name: String,
pub mime: String,
pub buffer: String,
}

https://docs.rs/playwright/0.0.19/playwright/api/struct.File.html
https://docs.rs/playwright/0.0.19/playwright/api/element_handle/struct.ElementHandle.html#method.set_input_files_builder

Is there any way I can call this like those other examples using just the filepath instead of having to provide buffer and mime type?

If I do have to provide buffer can you point me in the right direction of how to produce that in the correct format?

My current test code looks like this:

let f:File = File {
                        name: "../Downloads/video.mp4".to_string(), 
                        mime: "video/mp4".to_string(), 
                        buffer: "".to_string()
                 };
videoInput.set_input_files_builder(f).set_input_files().await.unwrap();

Though for some reason respite setting the mime type I still get the following error:

files[0].mimeType: expected string, got undefined

Browser has black screen when not headless

I'm turning headless mode off while I debug, but all that is rendered is a black screen. When I run eval I see that the dom is there and can be interacted with for the website, however I can't see anything on the screen.

I've tried looking through the Browser Launcher options but I don't see anything that I think would help. Does anyone have a solution to this?

let playwright = Playwright::initialize().await.unwrap();
playwright.prepare().unwrap();

let chromium = playwright.chromium();
let browser = chromium.launcher().headless(false).launch().await.unwrap();
let context = browser.context_builder().build().await.unwrap();
let page = context.new_page().await.unwrap();
page.goto_builder("https://www.duckduckgo.com").goto().await.unwrap();

ksnip_20220114-120535

About my machine: Running Ubuntu 21.04

Apple silicon support

I guess the version of playwright will need to be updated to support it Error: ERROR: Playwright does not support chromium on mac12-arm64

Equivalent of `await page.waitForEvent("load");`

What's the equivalent of await page.waitForEvent("load"); when using this crate? :)
So that I can call it after e.g. page.click_builder("#login-button").click().await?;.

When I try page.expect_event(EventType::Load).await?; it hangs here forever, even after the page loaded.

Is this project still maintained?

Hi,

I would like to use playwright with rust in my project. When searching, I found thks repository. But it seems that there hasnot been updated for a while. So, I would like to know if this project is still maintained? If yes, does it work with the latest version of Playwright?

Best regards

NT

"No such file or directory" error when calling Playwright::initialize()

I started with this issue of a black browser display, then in an attempt to fix it I set up my dev environment on my new PC (also running Ubuntu 21). Now I'm running into this issue:

thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" })', src/bin/webview.rs:39:58

when I call initialize:

let playwright = Playwright::initialize().await.unwrap();

This is the same code that was previously able to launch the browser on my other PC (though it produced a black display, it was operable with javascript and didn't crash).

Does anyone have an idea of what might be happening here? I'm not specifying a file or directory, but the playwright-rust code apparently is. Though I can't see why it would it be a problem.

Playwright dev branch no longer Send (thread safe) after this line of code.

Conditions: I'm running playwright (dev branch) in two parallel threads like so:

tokio::spawn(job_x); 
tokio::spawn(job_y); 

Error: Compilation error occurs saying Playwright is not Send.

std::marker::Send is not implemented for std::sync::MutexGuard<'_, playwright::"imp"::core::connection::Context>
./src/imp/playwright.rs:76:17

Diagnosis: I was able to narrow it down to this line of code std::mem::drop(ctx); in imp/playwright.rs

Partial Solution: After removing that line of code it will compile ๐Ÿ‘ . However, though playwright works, it will hang indefinitely after I close the browser window and I have to kill the program manually. I'm not 100% sure it is from removing that line or not yet, but it seems likely.

Creating an incognito window

Hello,

is there a way to create an incognito window in playwright-rust?

I see the comment

/// Playwright allows creation of "incognito" browser contexts with `browser.newContext()` method. "Incognito" browser

granted, I am not super familiar with playwright and still coming to terms with rustlang.

page.evaluate_on_selector hangs indefinitely and doesn't timeout on error

I have two calls to page.evaluate_on_selector, the first completes, but the second seems to have a problem. Changing the order doesn't matter, so it looks like the problem is with my selector and I can fix that. The issue I want to address is that the error itself never occurs and the function simply hangs.

Here is the code in question:

let title_xpath = "xpath//*[@itemprop='title']";
let title: String = page.evaluate_on_selector::<String, String>(title_xpath,"node => node.innerHTML", None).await.unwrap();

I see the error in my code, but we should expect some kind of error to be produced* and visible, instead of the program hanging indefinitely.

press_builder() seems broken. Missing 3 default values on the builder

When I use press_builder() on my script I get this error at runtime.

Error "delay: expected number, got object"

Then I update my code to be page.press_builder().delay(30.0).press()

and then I get an error

Error "noWaitAfter: expected boolean, got object"

so then I add no_wait_after() function like so page.press_builder().no_wait_after(false).delay(30.0).press()

after that I see see this error

Error "timeout: expected number, got object"

and manually adding the timeout() to the chain makes it work.

So those three default values are not being set on my press_builder() for some reason. I'm not having this issue with any other builder so far.

DISCLAIMER: I'm not 100% sure this is true on your version. I modified my playwright slightly, but I don't think I changed anything that would effect default values for press_builder().

monitor request and response

Thank you for making a good library. I need response data from the page.
This feature is in the rust-headless-chrome, but the overall stability of the library is poor. src_line

I found this in the playwrite document. Can I use it here, too? network-events

running in docker env reports some libraries are missing

Error "Host system is missing dependencies!\n\n  Missing libraries are:\n      libgobject-2.0.so.0\n      libglib-2.0.so.0\n      libnss3.so\n      libnssutil3.so\n      libsmime3.so\n      libnspr4.so\n      libatk-1.0.so.0\n      libatk-bridge-2.0.so.0\n      libcups.so.2\n      libdrm.so.2\n      libdbus-1.so.3\n      libgio-2.0.so.0\n      libexpat.so.1\n      libxcb.so.1\n      libxkbcommon.so.0\n      libX11.so.6\n      libXcomposite.so.1\n      libXdamage.so.1\n      libXext.so.6\n      libXfixes.so.3\n      libXrandr.so.2\n      libgbm.so.1\n      libpango-1.0.so.0\n      libcairo.so.2\n      libasound.so.2\n      libatspi.so.0\n      libxshmfence.so.1\n"

Can't cross compile to windows

I'm trying to compile for Windows from Ubuntu 20.x but Playwright seems to be failing during the process.

I ran the following commands to make it possible to cross compile (or at least that's what a stack overflow article said ๐Ÿ˜… ):

rustup target add x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu

cargo build --target x86_64-pc-windows-gnu;

Here is the outputted error:

rror: couldn't read /home/onx2/Documents/my-project/target/x86_64-pc-windows-gnu/debug/build/playwright-33e13a0aa96f0c95/out\driver.zip: No such file or directory (os error 2)
  --> /home/onx2/.cargo/registry/src/github.com-1ecc6299db9ec823/playwright-0.0.18/src/imp/core/driver.rs:21:32
   |
21 |     const ZIP: &'static [u8] = include_bytes!(concat!(env!("OUT_DIR"), sep!(), "driver.zip"));
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error: couldn't read /home/onx2/Documents/my-project/target/x86_64-pc-windows-gnu/debug/build/playwright-33e13a0aa96f0c95/out\platform: No such file or directory (os error 2)
  --> /home/onx2/.cargo/registry/src/github.com-1ecc6299db9ec823/playwright-0.0.18/src/imp/core/driver.rs:22:36
   |
22 |     const PLATFORM: &'static str = include_str!(concat!(env!("OUT_DIR"), sep!(), "platform"));
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `playwright` due to 2 previous errors

None of the browsers are downloading in Playright - Mac M1

I get the below error if I use

let playwright = Playwright::initialize().await.unwrap();
playwright.prepare();

Error

Failed to install browsers
Error: Failed to download chromium, caused by
Error: ERROR: Playwright does not support chromium on mac13-arm64

Now, even if I select installation of firefox, this same happens

let playwright = Playwright::initialize().await.unwrap();
playwright.install_firefox();

Error

Error: Failed to download firefox, caused by
Error: ERROR: Playwright does not support firefox on mac13-arm64

I am not willing to have any executable path option, this will be used by some non-tech guy, so I want to keep it simple, like installing the browser and launching automatically.

My System Config
Screenshot 2022-11-12 at 4 08 44 PM

Can you recommend something here?

Startup error with Firefox

I'm not sure of what changed to introduce this issue, and it may just be my own box.

Firefox started throwing this error on startup: "Gah. Your tab just crashed." The same code was working this last week.

Error: ErrorResponded(ErrorMessage { name: "Error", message: "Page closed", stack: "Error: Page closed\n    at FFSession.<anonymous> (/home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffPage.js:97:31)\n    at Object.onceWrapper (events.js:420:28)\n    at FFSession.emit (events.js:314:20)\n    at /home/user/.cache/ms-playwright/playwright-rust/driver/package/lib/server/firefox/ffConnection.js:175:43" })

playwright-rust: 0.0.20
playwright binary: ms-playwright/firefox-1250
firefox: 89.0b6
os: arch linux

Chromium appears to work, but sadly is not an option for my use case.

I've tried deleting the playwright cache and re-downloading but the issue remains.

When I tried the dev branch it failed with Error: Arc(Serde(Error("missing field `utils`", line: 0, column: 0))).

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

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.

Running on Lambda Function

Was wondering if anyone has tried getting the to run on a Rust AWS Lambda function? The Node.js side has
playwright-aws-lambda
to assist. It's currently failing for me because Playwright::initialize() attempts to download the driver to the read-only file system. Wondering if it'd be possible to use Playwright::with_driver(driver) with a driver packaged with the function.

Thank you

Playwright stop responding in Docker

[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] SEND Req { id: 10, guid: "browser-type@43af88863e863765963c2986930eac42", method: "launch", params: {"headless": Bool(true)} }
None
Committing offsets: Ok(())
[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] RECV {"guid":"browser-type@43af88863e863765963c2986930eac42","method":"__create__","params":{"type":"Browser","initializer":{"version":"92.0.4498.0","name":"chromium"},"guid":"browser@aeeb8a7bc1cd03be692db83160e2636d"}}
[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] RECV {"id":10,"result":{"browser":{"guid":"browser@aeeb8a7bc1cd03be692db83160e2636d"}}}
[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] SEND Req { id: 11, guid: "browser@aeeb8a7bc1cd03be692db83160e2636d", method: "newContext", params: {"sdkLanguage": String("")} }
[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] RECV {"guid":"browser@aeeb8a7bc1cd03be692db83160e2636d","method":"__create__","params":{"type":"BrowserContext","initializer":{"isChromium":true},"guid":"browser-context@744e111f024c383f760775a92d3f98cb"}}
[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] RECV {"id":11,"result":{"context":{"guid":"browser-context@744e111f024c383f760775a92d3f98cb"}}}
[2023-01-12T18:55:38Z DEBUG linkedin::meta::linkedin] browser has been created
[2023-01-12T18:55:38Z INFO  linkedin::meta::linkedin] browser context built
[2023-01-12T18:55:38Z DEBUG playwright::imp::core::transport] SEND Req { id: 12, guid: "browser-context@744e111f024c383f760775a92d3f98cb", method: "newPage", params: {} }

After this It never respond. and I am not sure what's wrong.
And it appears to be in loop or keep waiting and upon looking at container process we can see in fact browser instance is running, but does not respond anything, not even error. Here are the process running in docker container.

bhuman@bhuman-7400:~$ sudo docker top fad8a5ea55ac
[sudo] password for bhuman: 
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                19272               19201               0                   22:57               ?                   00:00:07            /app/target/release/linkedin
root                19550               19272               0                   22:57               ?                   00:00:00            /bin/sh /root/.cache/ms-playwright/playwright-rust/driver/playwright.sh run-driver
root                19554               19550               0                   22:57               ?                   00:00:00            /root/.cache/ms-playwright/playwright-rust/driver/node /root/.cache/ms-playwright/playwright-rust/driver/package/lib/cli/cli.js run-driver
root                20265               19554               31                  23:08               ?                   00:10:04            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=/tmp/playwright_chromiumdev_profile-sJjhND --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
root                20267               20265               0                   23:08               ?                   00:00:00            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=zygote --no-zygote-sandbox --no-sandbox --headless --headless
root                20268               20265               0                   23:08               ?                   00:00:00            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=zygote --no-sandbox --headless --headless
root                20286               20268               81                  23:08               ?                   00:26:13            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=renderer --no-sandbox --disable-dev-shm-usage --disable-background-timer-throttling --disable-breakpad --enable-automation --force-color-profile=srgb --remote-debugging-pipe --allow-pre-commit-input --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --ozone-platform=headless --field-trial-handle=5151956782728765150,10929878616647120254,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=BlinkGenPropertyTrees,ImprovedCookieControls,LazyFrameLoading,PaintHolding,SameSiteByDefaultCookies,TranslateUI --disa
root                20321               20267               0                   23:08               ?                   00:00:00            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=gpu-process --field-trial-handle=5151956782728765150,10929878616647120254,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=BlinkGenPropertyTrees,ImprovedCookieControls,LazyFrameLoading,PaintHolding,SameSiteByDefaultCookies,TranslateUI --no-sandbox --disable-dev-shm-usage --disable-breakpad --headless --ozone-platform=headless --headless --gpu-preferences=UAAAAAAAAAAgAAAQAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --use-gl=disabled --override-use-software-gl-for-tests --shared-files
root                22047               19554               31                  23:17               ?                   00:07:15            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=/tmp/playwright_chromiumdev_profile-c8EaqE --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
root                22049               22047               0                   23:17               ?                   00:00:00            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=zygote --no-zygote-sandbox --no-sandbox --headless --headless
root                22050               22047               0                   23:17               ?                   00:00:00            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=zygote --no-sandbox --headless --headless
root                22067               22050               81                  23:17               ?                   00:18:27            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=renderer --no-sandbox --disable-dev-shm-usage --disable-background-timer-throttling --disable-breakpad --enable-automation --force-color-profile=srgb --remote-debugging-pipe --allow-pre-commit-input --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --ozone-platform=headless --field-trial-handle=3248009288479842313,6307992858770365040,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=BlinkGenPropertyTrees,ImprovedCookieControls,LazyFrameLoading,PaintHolding,SameSiteByDefaultCookies,TranslateUI --disab
root                22097               22049               0                   23:17               ?                   00:00:00            /root/.cache/ms-playwright/chromium-878941/chrome-linux/chrome --type=gpu-process --field-trial-handle=3248009288479842313,6307992858770365040,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=BlinkGenPropertyTrees,ImprovedCookieControls,LazyFrameLoading,PaintHolding,SameSiteByDefaultCookies,TranslateUI --no-sandbox --disable-dev-shm-usage --disable-breakpad --headless --ozone-platform=headless --headless --gpu-preferences=UAAAAAAAAAAgAAAQAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --use-gl=disabled --override-use-software-gl-for-tests --shared-files

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.