Error Invalid tab id 1 when running as a cron job

Hi
When I run a script using a cron job ( it is a desktop automation script), sometimes I get this error
Error Invalid tab id : 1

This occurs usually when I run the script first time during the day using a cron. When I run it again using cron, it works fine.

Can someone tell me what am I doing wrong?

Thanks,
Samir

This indicates that your system is a “little bit” slow, and there is a timing issue when starting the browser the first time. I assume that at your 2nd (etc) call the browser is already running, and thus all works well.

=> Workaround: Start browser first, and then the RPA command line

Hi:
I do not understand your solution. Let me explain what I am doing.
I am running the following shell script on Ubuntu Linux via a cron job

#!/bin/bash
/usr/bin/firefox “file:///root/Downloads/desktop.html?direct=1&macro=skype” &
sleep 60
/usr/bin/killall firefox

Now, skype is the name of the macro. The first line of the macro is
XRun /root/skype2.sh

And skype2.sh is
#!/bin/bash
/usr/bin/skypeforlinux &

Now, what do you want me to do?
How can I just run firefox without the url that contains the skype macro?

If I just run firefox, pause, and then again run firefox with skype macro in the url, I will get the error message saying “firefox is already running. Close it.”

I hope you understand my problem. So, how can I start the browser first, and then the RPA command line?

Thanks,
Samir

I confirmed the issue with launching Firefox is Firefox is already open. Chrome does not show this issue. So one solution is to use Chrome.

If you want to work with Firefox, I found that using wdg-open for the first launch solves the issue. (I am not sure why this works/what makes the difference here, if anyone knows, please let us know)

Here is a video of the test. First I run the normal script twice, and then the one that first opens Firefox, then runs the command line. What also helps on slow machines is to add continueInLastUsedTab=0 - With 0 it avoids the tab switching, which can also cause a timing issue (and then we get Invalid tab id).

#!/bin/bash

# Clean up left-overs before start
/usr/bin/killall firefox

# start Firefox first. Any URL can be used. This is for slow systems
xdg-open "https://ocr.space"

sleep 5s #Give the browser enough time to fully open

#Now run the actual RPA command line URL
/usr/bin/firefox "file:///home/m/Desktop/ui.vision.html?continueInLastUsedTab=0&macro=linux%20test&storage=browser&direct=1&closeBrowser=true&closeRPA=true"