I need a way to change the value of the input field with my new value
I tried input.value didn't work.
Tried this function:
function simulateTyping(element, value, i) {
i === 0 && element.setAttribute("value", value);
i === 0 && (element.value = "");
if (i < value.length) {
element.value += value.charAt(i);
element.dispatchEvent(
new Event("textInput", {
data: value.charAt(i),
inputType: "textInput",
bubbles: true,
cancelable: true,
})
);
element.dispatchEvent(
new Event("input", {
bubbles: true,
data: value.charAt(i),
cancelable: true,
})
);
setTimeout(simulateTyping.bind(this, element, value, i + 1), 10);
} else {
element.dispatchEvent(
new Event("change", {
bubbles: true,
cancelable: true,
})
);
element.dispatchEvent(new Event("blur", { bubbles: true }));
var evt = document.createEvent("KeyboardEvent");
evt.initEvent("keyup", true, true);
element.dispatchEvent(evt);
}
}
This function changed the value but suddenly the website is changing the value but If I type the number with my keyboard the website didn't change the value .
I think there is something more which we need to find to actually simulate real keypress This is the website https://tibiablackjack.com/crash
Video demo https://www.loom.com/share/cb568c04ac85427395c2f0e1481c7fb9