Closed TheFriendlyCoder closed 6 months ago
I also tried a variation of this using the waitForSelector
method as well, with similar results:
print("Click and wait");
var result = await myPage.waitForSelector(".joinSimpliiLink",
visible: true, hidden: false);
if (result == null) {
print("Error not found");
return;
}
print("Clicking...");
await Future.wait([myPage.waitForNavigation(), result!.click()]);
print(myPage.url);
print(result);
which produces the output:
Click and wait
Clicking...
Unhandled exception:
Context is disposed
which tells me the selector lookup works, but the click/waitForNavigation doesn't.
One more similar variation for comparison:
print("Click and wait");
var result = await myPage.waitForSelector(".joinSimpliiLink",
visible: true, hidden: false);
print("clicking...");
await result!.click();
print("navigating...");
var result2 = await myPage.waitForNavigation();
print(result2.status);
print(myPage.url);
which produces:
Click and wait
clicking...
navigating...
Unhandled exception:
Context is disposed
Which further isolates the problem to the waitForNavigation
method.
Intriguing... Luckily, there is this open pull request to address that: https://github.com/xvrh/puppeteer-dart/pull/312 I'll have a look to merge it.
Can you try v3.11.0
?
Seems to work now. Thanks for the quick fix!
I am testing out Puppeteer for the first time, and thought I'd try a simple scenario: I want to open a web page that has a hyperlink on it, click the hyperlink, and wait for the page to refresh. Below is the sample code I am using:
I expect the value of
result
to get printed, which should give me the success status from the navigation operation, and themyPage
variable to be updated to point to the target URL for the hyperlink selected. What I get instead is an exception:I'm running on a Mac with the last OS, Dart v3.3, and the latest version of puppeteer-dart in case this helps isolate the problem.