'The while loop inside the Python for loop is repeated only once

This is a part of the code that checks the notice that appears while working using pyautogui and resumes the work when it disappears.

Capture the guide and make it into an image, check it with pyautogui, and if it exists, move on to the next one.

    number = 0
    for mark in sub_list:
        pyautogui.moveTo(1105, 356)
        pyautogui.click()
        time.sleep(random.uniform(0.5, 1.2))
        pyautogui.moveTo(291, 529)
        pyautogui.click()
        time.sleep(random.uniform(0.5, 1.2))
        pyautogui.moveTo(190, 207)
        pyautogui.click()
        time.sleep(random.uniform(0.5, 1.2))
        pyautogui.moveTo(347, 529)
        pyautogui.click()
        pyautogui.write(sub_list[number])
        print(sub_list[number])
        time.sleep(random.uniform(0.5, 1.2))
        pyautogui.moveTo(702, 531)
        pyautogui.click()
    
        icon_to_click = "Recycle Bin"
    
        r = None
        while r is None:
            r = pyautogui.locateOnScreen('rb.png', grayscale=True)
        print(icon_to_click + ' now loaded')
    
        pyautogui.write(''.join(a_record))
        time.sleep(random.uniform(0.5, 1.2))
        pyautogui.moveTo(210, 616)
        pyautogui.click()
    
        tiu = str(sub_list[number]) + "." + str(main_domain)
        sub_domain.append(tiu)
        print(sub_domain[number])
        time.sleep(random.uniform(4, 5))
        number = number + 1
    

However, it works fine once, but from the second iteration it can't find the image and stops.

<pre>
    icon_to_click = "Recycle Bin"

    r = None
    while r is None:
        r = pyautogui.locateOnScreen('rb.png', grayscale=True)
    print(icon_to_click + ' now loaded')
</pre>

Should I change the settings in this part? Help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source