-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
evaluate returns null when expected result is a list #243
Comments
Can you provide a way to reproduce? Just tried something like that and it seems to work as expected: import 'package:puppeteer/puppeteer.dart';
void main() async {
var browser = await puppeteer.launch();
var page = await browser.newPage();
var result = await page.evaluate('() => ["someData"]');
print('$result ${(result as List).first} ${result.runtimeType}');
// => [someData] someData List<dynamic>
var result2 = await page.evaluate('(a) => a', args: [
['myarg']
]);
print('$result2 ${(result2 as List).first} ${result2.runtimeType}');
// => [myarg] myarg List<dynamic>
await browser.close();
} |
@xvrh here in my library am using puppeteer for desktop but on mobile platform it returns correct list for desktop am using this to get result, and if i use evaluateHandler instead of this , then am getting a list (but in JsHandler form ) on mobile am using this Edit : and are you able to evaluate a method with args as list, for example in my case |
In your var result = await page?.evaluate('() => $source'); |
yes trying |
@xvrh adding but still getting issue in getting result when expecting list evaluate : null |
@xvrh tried to replicating something like this String content = '''
window.getData = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve([{ "someData" : 3 },{ "randomData" : 2}])
}, 1000);
});
};
''';
await page.addScriptTag(content: content, type: "module");
var result = await page.evaluate('window.getData()'); and its also working fine, but strangely its not working as expected in my library when i use |
@xvrh one thing i noticed with these methods which are returning null is : |
Can you try to debug by taking only some small part of the array. ie: var result = await page.evaluate('async () => (await WPP.group.getAllGroups()).slice(0, 10)'); |
still getting null after trying i also tried : but when i tried evaluateHandle with above , i got the result as expected ( in jsHandle ) |
@xvrh finally got the solution This worked for me : seems like issue is with the parsing on dart side, if we parse the result within js , then its working fine |
Hey thanks for this awesome library
am facing an issue
when i try to evaluate a method which should return a list, then
evaluate
method returns nullbut if i use
evaluateHandle
, then it returns list ofJsHandle
which seems to be fineand i am sure that , js method is fine and returns proper value, because i tried executing that manually and its fine
and am facing this issue only when expecting result is a List, rest all cases works fine
with this , i also face an issue if i try to execute a method with parameter as list, for example
evaluate('''SomeMethod( [ "someData" ] )''')
this will not workbut this works :
evaluate('''SomeMethod( [ ] )''')
, or we pass something else , that will also worksand i have to pass args like this , can't use args parameter from Puppeteer in my case
The text was updated successfully, but these errors were encountered: