How to deploy pyautogui app on server in headless mode selenium?

109 views Asked by At

i use selenium with pyautogui for clicking on chrome toolbar extensions . it work propely in local but when add headless it didnt work i even use xvfb-run on server and another library in python for virtual screen display but not effect!

driver.get("https://www.example.com")
while 1:

    try:
        e=pyautogui.locateOnScreen('img.jpg', confidence=0.65)
        print ("I can see it")
        break
    except pyautogui.ImageNotFoundException:
        print("I am unable to see it")
    time.sleep(0.1)
pyautogui.moveTo(e[0], e[1], 1)
pyautogui.click()   
1

There are 1 answers

1
Will C On

Try using the driver.maximize_window() function from selenium's web driver and add_argument(--headless) together.