i am making a bot that looks for a Add to cart button Through Images So when it finds the button it clicks it i got that down But when The button is not shown it spits out a error Here is the code
`import pyautogui
import time
Null = “None”
time.sleep(5)
while True:
ATC = pyautogui.locateCenterOnScreen(‘AddToCart.png’)
if (ATC == Null):
print(ATC)
if (ATC != Null):
pyautogui.click(ATC.x, ATC.y)
print("Added To Cart")
break
`
And here Is A download To tynker with Everything you need to test
This is the error
Traceback (most recent call last):
File “/Users/EVAstudent/Desktop/New Folder With Items/WebBot.py”, line 14, in
pyautogui.click(ATC.x, ATC.y)
AttributeError: ‘NoneType’ object has no attribute ‘x’
When it works it prints
Added To Cart