from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
import time
def wait_for_user_input(x, y):
autofill_btn="""
// create button element
var btn = document.createElement('button');
btn.setAttribute("id", "automation");
btn.innerText = "AutoFill Form";
// styling it as button
btn.style.cursor = "pointer"
btn.style.color = "red";
btn.style.fontWeight = "bold";
btn.style.backgroundColor = "yellow";
btn.style.borderStyle = "solid";
btn.style.borderRadius = "25px";
// positioning it
btn.style.position = "absolute";
btn.style.top = "{x}px";
btn.style.left = "{y}px";
btn.style.padding = "10px";
// when select it self remove
btn.onclick = function () {
element = document.getElementById('automation');
element.remove();
};
var body = document.body;
body.appendChild(btn);
"""
autofill_btn = autofill_btn.replace("{x}", str(x))
autofill_btn = autofill_btn.replace("{y}", str(y))
driver.execute_script(autofill_btn)
while (len(driver.find_elements(By.ID, "automation"))>0):
time.sleep(2)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
wait_for_user_input(100, 300)
driver.find_element(By.XPATH, '/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys("this is a test")
input("Press Enter to quit Chrome...")
driver.quit()