executeScript method
Executes JavaScript in the browser and returns the result
Implementation
Future<dynamic> executeScript(String script) async {
_checkDisposed();
if (_controller == null) {
throw ScrapingException.validation(
'Browser not initialized',
isRetryable: false,
);
}
try {
final result = await _controller!.evaluateJavascript(source: script);
return result;
} catch (e) {
_log('Error executing script: $e', isError: true);
throw ScrapingException.parsing(
'Failed to execute script',
originalException: e,
isRetryable: false,
);
}
}