fromOperationArgs static method

ElementTarget fromOperationArgs(
  1. Map<String, dynamic> args
)

Reads the target shape used by an operation's input map.

Implementation

static ElementTarget fromOperationArgs(Map<String, dynamic> args) {
  final raw = args['target'];
  if (raw is Map) {
    final target = Map<String, dynamic>.from(raw);
    if (target.containsKey('testId') ||
        target.containsKey('elementId') ||
        target.containsKey('observationId') ||
        target.containsKey('locator')) {
      return ElementTarget.fromJson(target);
    }
    return ElementTarget(locator: ElementLocator.fromJson(target));
  }
  final testId = args['id']?.toString();
  return testId == null
      ? const ElementTarget()
      : ElementTarget(testId: testId);
}