fill_with method

Future<Online> fill_with(
  1. Online browser,
  2. T value
)

Implementation

Future<Online> fill_with(Online browser, T value) async {
  Show.action("preparing", "to fill", value.toString());
  Show.tree(value);
  if (prepare_action != null) {
    await prepare_action!.call(browser);
  }

  Show.action("collecting", "input data");
  if (collect_data != null && value == null && mandatory) {
    value = collect_data!.call(browser)!;
  }

  // Show.action("filling", "data");
  await fill_action(browser, value);

  Show.action("validating", "input");
  if (validate_action != null) {
    final response = await validate_action!(browser);
    if (!response.valid) {
      Show.error("validation failed", response.message ?? "");
    } else {
      Show.success("validation successfull", response.message ?? "");
      if (submit_action != null) {
        Show.step("submitting", "form");
        await submit_action!.call(browser);
      }
    }
  } else {
    if (submit_action != null) {
      Show.step("submitting", "form");
      await submit_action!.call(browser);
    }
  }

  if (cleanup_action != null) {
    Show.action("cleaning", "up");
    await cleanup_action!.call(browser);
  }
  return browser;
}