All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.devtools.v124.autofill.Autofill Maven / Gradle / Ivy

Go to download

Selenium automates browsers. That's it! What you do with that power is entirely up to you.

There is a newer version: 4.22.0
Show newest version
package org.openqa.selenium.devtools.v124.autofill;

import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;

/**
 * Defines commands and events for Autofill.
 */
@Beta()
public class Autofill {

    /**
     * Trigger autofill on a form identified by the fieldId.
     * If the field and related form cannot be autofilled, returns an error.
     */
    public static Command trigger(org.openqa.selenium.devtools.v124.dom.model.BackendNodeId fieldId, java.util.Optional frameId, org.openqa.selenium.devtools.v124.autofill.model.CreditCard card) {
        java.util.Objects.requireNonNull(fieldId, "fieldId is required");
        java.util.Objects.requireNonNull(card, "card is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("fieldId", fieldId);
        frameId.ifPresent(p -> params.put("frameId", p));
        params.put("card", card);
        return new Command<>("Autofill.trigger", Map.copyOf(params));
    }

    /**
     * Set addresses so that developers can verify their forms implementation.
     */
    public static Command setAddresses(java.util.List addresses) {
        java.util.Objects.requireNonNull(addresses, "addresses is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("addresses", addresses);
        return new Command<>("Autofill.setAddresses", Map.copyOf(params));
    }

    /**
     * Disables autofill domain notifications.
     */
    public static Command disable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("Autofill.disable", Map.copyOf(params));
    }

    /**
     * Enables autofill domain notifications.
     */
    public static Command enable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("Autofill.enable", Map.copyOf(params));
    }

    public static Event addressFormFilled() {
        return new Event<>("Autofill.addressFormFilled", input -> input.read(org.openqa.selenium.devtools.v124.autofill.model.AddressFormFilled.class));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy