Closed Boscop closed 3 years ago
You don't have to wait explicitly because it will wait automatically after clicking. https://playwright.dev/docs/api/class-page#pageclickselector-options
noWaitAfter
<boolean>
Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to inaccessible pages. Defaults tofalse
.
expect_event
timeout works even with single-threaded runtimes, but if it runs forever, let me know the environment.
The environment is manjaro Linux and I'm using playwright-rust with the chromium browser.
I'm using the standard Tokio main function like in your readme.
And yes, it hangs forever.
But if I don't wait after click, it gives me still the old url if I do an assert_eq of page.url()
and the expected url it should have after loading finishes.
And btw, when I call expect_event I see in the browser window that the url actually changes to the expected url after the loading has finished. Just my expect_event call doesn't return.
playwright::api::page::Event::Load
is implemented in 0.0.7.
While this test passes, many functions wait automatically, so there is no need to wait explicitly.
If it hangs, please let me know with a code.
Now I'm getting:
Error: Arc(ErrorResponded(ErrorMessage { name: "Error", message: "net::ERR_CERT_AUTHORITY_INVALID
Even though I'm using .ignore_https_errors(true)
.
Any idea why? :)
Sorry, I forgot ignoreHTTPSErrors isn't a camelCase. 0.0.8 is ready.
Thanks for the quick fix.
But now my program returns with Error: Arc(ReceiverClosed)
:
#[tokio::main]
async fn main() -> Result<(), playwright::Error> {
let playwright = Playwright::initialize().await?;
playwright.prepare()?;
let chromium = playwright.chromium();
let browser = chromium
.launcher()
.headless(false)
.launch()
.await?;
let context = browser
.context_builder()
.ignore_https_errors(true)
.build()
.await?;
let page = context.new_page().await?;
page.goto_builder(LOGIN_URL).goto().await?; // here
Ok(())
}
When I tried to reproduce the error, it was caused by parsing consolemessage, which was released at the same time. 0.0.9, how about this?
Thanks for the quick fix. But now, at the same source line, it returns this error:
Error: Arc(Serde(Error("invalid type: map, expected a string", line: 0, column: 0)))
Any idea why?
I tried it on a page with NET::ERR_CERT_AUTHORITY_INVALID, but unfortunately it did not reproduce.
If you use env_logger and give me the output of RUST_LOG=trace cargo run
, I might be able to figure it out. Just don't forget to cut off the credential information.
Thanks, it works now (with v0.0.14).
@octaltree Btw, is there a way to get the HTTP response from the latest request that was made?
Would page::EventType::Request
and Request::response
help, I haven't written any tests for them yet.
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.