Unverified Commit 21b97504 authored by Yegor's avatar Yegor Committed by GitHub

[web] do not swallow WebDriver errors (#103754)

parent fe87538b
...@@ -294,34 +294,30 @@ class FlutterWebConnection { ...@@ -294,34 +294,30 @@ class FlutterWebConnection {
/// Sends command via WebDriver to Flutter web application. /// Sends command via WebDriver to Flutter web application.
Future<dynamic> sendCommand(String script, Duration? duration) async { Future<dynamic> sendCommand(String script, Duration? duration) async {
dynamic result; String phase = 'executing';
try { try {
// Execute the script, which should leave the result in the `$flutterDriverResult` global variable.
await _driver.execute(script, <void>[]); await _driver.execute(script, <void>[]);
} catch (error) {
// We should not just arbitrarily throw all exceptions on the ground.
// This is probably hiding real errors.
// TODO(ianh): Determine what exceptions are expected here and handle those specifically.
}
try { // Read the result.
result = await waitFor<dynamic>( phase = 'reading';
final dynamic result = await waitFor<dynamic>(
() => _driver.execute(r'return $flutterDriverResult', <String>[]), () => _driver.execute(r'return $flutterDriverResult', <String>[]),
matcher: isNotNull, matcher: isNotNull,
timeout: duration ?? const Duration(days: 30), timeout: duration ?? const Duration(days: 30),
); );
} catch (error) {
// We should not just arbitrarily throw all exceptions on the ground. // Reset the result to null to avoid polluting the results of future commands.
// This is probably hiding real errors. phase = 'resetting';
// TODO(ianh): Determine what exceptions are expected here and handle those specifically. await _driver.execute(r'$flutterDriverResult = null', <void>[]);
// Returns null if exception thrown.
return null;
} finally {
// Resets the result.
await _driver.execute(r'''
$flutterDriverResult = null
''', <void>[]);
}
return result; return result;
} catch (error, stackTrace) {
throw DriverError(
'Error while $phase FlutterDriver result for command: $script',
error,
stackTrace,
);
}
} }
/// Gets performance log from WebDriver. /// Gets performance log from WebDriver.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment