lefengyang
2026-08-20 d01a28cb030b2cb0ff1d42273c877a0f728519a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import {wait} from "gs-base";
 
export async function setInput(input: HTMLInputElement, value: string) {
    if (!input) {
        return;
    }
    input.dispatchEvent(new Event('focus', {bubbles: true, cancelable: true}));
    await wait(50);
    input.value = value;
    await wait(50);
    input.dispatchEvent(new Event("input", {bubbles: true, cancelable: true}));
    input.dispatchEvent(new Event("change", {bubbles: true, cancelable: true}))
    await wait(50);
    input.dispatchEvent(new Event('blur', {bubbles: true, cancelable: true}));
}