Getting a 'type error-cannot unpack' on every second try

Viewed 19

Using pyautogui, I'm creating a simple program to log me into a VPN. First part of the code works fine each time, (double clicking an icon on desktop), the second part, left clicking on the connect button, works every other try. When it doesn't work I'm getting TypeError: cannot unpack non-iterable NoneType object.

However, this only occurs every second try. Every other try it works just fine. I ran it 50 times, and exactly every other try it works/doesn't work.

import pyautogui as pg
import time


def rpats_update():
    time.sleep(1.5)
    pg.doubleClick(cisco)
    time.sleep(0.2)
    attempts = 0
    while attempts < 3:
        try:
            pg.leftClick(connect)
        except TypeError:
            attempts += 1



rpats_update()
0 Answers
Related