ahertel/Amazon-Fresh-Whole-Foods-delivery-slot-finder

"Safari got an error: Can’t get window id 3536."

lxnxrd22 opened this issue · 13 comments

"Safari got an error: Can’t get window id 3536." number -1728 from window id 3536

@lxnxrd22 That error means that the Safari window used by the tool was closed. When the script starts running it opens a window and then minimizes. That window must stay open at all times while using the tool. Is it possible that you either A) quit Safari or B) closed the window used by the tool?

Other users have reported the same issue as you and the cause of the problem has so far always been either A or B. Let me know your thoughts. Thanks for your message.

"Safari got an error: Can't get window id 2360."
491586276136_ pic_hd

@lxnxrd22 thanks for letting me know it worked for you! Great to hear!!

@lxnxrd22 That error means that the Safari window used by the tool was closed. When the script starts running it opens a window and then minimizes. That window must stay open at all times while using the tool. Is it possible that you either A) quit Safari or B) closed the window used by the tool?

Other users have reported the same issue as you and the cause of the problem has so far always been either A or B. Let me know your thoughts. Thanks for your message.

@anniehu4502 Sorry to hear you're having issues. We'll figure it out! Did my above advice to @lxnxrd22 help you?

I experienced this error a few times. Pretty sure it wasn't either A or B every time--I left the computer, and then some minutes later the script gave the error. To alert myself when I needed to restart the script because an error occurred, I added a try...on error block along these lines:

	try
		repeat while found_slot is false
			-- (existing code)
		end repeat
	on error errStr number errorNumber
		-- send text notification
		if sendTexts then
			-- Credit for texting code: Sean Pinkey, https://github.com/spinkney
			tell application "Messages"
				set targetService to 1st service whose service type = iMessage
				set targetBuddy to buddy phoneNumber of targetService
				send (((current date) as string) & ": " & errorMsg & errStr & " #" & errorNumber) to targetBuddy
			end tell
			log "text message sent about error"
		end if
	end try

I tested it by deliberately closing the window, and it worked.

Not sure if there's a way to automate restarting of the loop by re-creating the Safari tab. I like to have a timestamp on the message because iMessage doesn't always show the time if there are several messages not that far apart. And of course, if using the send texts code more than once, it'd be good to write a function for it, passing in the message string.

Thanks for this script! Saved us from having to go out for groceries.

@lxnxrd22 That error means that the Safari window used by the tool was closed. When the script starts running it opens a window and then minimizes. That window must stay open at all times while using the tool. Is it possible that you either A) quit Safari or B) closed the window used by the tool?
Other users have reported the same issue as you and the cause of the problem has so far always been either A or B. Let me know your thoughts. Thanks for your message.

@anniehu4502 Sorry to hear you're having issues. We'll figure it out! Did my above advice to @lxnxrd22 help you?

Thank you so much for the script and I just got the notification for the first time! Really really appreciate it!

@ahertel I'm getting 'safari got an error: can't get window id 3413.' Do you know if that's the same error? I still have everything open. (Struggling to attach screenshot here.) Thank you for creating this. (Even if I can't figure it out on my end. I also have autoimmune disease and was just wishing for something like this!) Forwarding your resume to a friend. Update: Looks like I have it running now. Thank you again. :)

I got the error from closing a neighboring tab in the safari browser, which then happened to crash the script and suddenly the safari window closed, resulting in the same error. Wondering is anyone also experienced something similar..

@tatianajiselle the neighboring "empty" tab in the window used by the script must remain open. Please don't close it :) The script opens and closes the amazon webpage tab, which would close the window if this were the only tab in the window. Thus I added the additional empty tab to the window so that the window stays alive at all times. let me know if that helps

I just started using your app today. I'm getting this error: "Safari got an error: Can’t get last tab of window id 1249. Invalid index." number -1719 from last tab of window id 1249

The only Safari window open is the one created by the script for Amazon Fresh. I'm not touching it. But I've gotten this error repeatedly while trying to run the program.

THanks! This is a great service you're doing here.

Hi, thank you for creating this! I keep getting the same error:
Safari got an error: Can’t get last tab of window id 682. Invalid index." number -1719 from last tab of window id 682

Before I get the error I get a voice message saying something like "ignore out of stock item". I do not touch the window. Is there something else I could do?