Help with Code - If button not available then skip: FIXED

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
alexboy94
Posts: 9
Joined: Fri May 20, 2016 3:06 pm

Help with Code - If button not available then skip: FIXED

Post by alexboy94 » Fri May 20, 2016 3:15 pm

Hi,

I am making a simple code that selects buttons on peoples profiles and then does it over again.

The problem is, at times not all the buttons are there, so it creates an error and stops the code from running.

I was wondering if there was a way to say if this isn't available to press, then go to next step

Ex of code:

BACK
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(16)>DIV>DIV>DIV>DIV>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(3)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(4)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(8)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(7)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(6)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(5)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
BACK
WAIT SECONDS=100
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(17)>DIV>DIV>DIV>DIV>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(3)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(4)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(8)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(7)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(6)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(5)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
BACK

Its a random point where one of the event selectors will fail 1-8, due to the button not being there, due to the user not adding it. I was wondering if there was a statement for each button I could put. that would do:

EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(16)>DIV>DIV>DIV>DIV>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(3)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(4)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(8)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(7)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(6)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(5)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*

*1*
BACK

If I can get this to work, then my program will be flawless.
Last edited by alexboy94 on Mon Jun 06, 2016 4:19 pm, edited 1 time in total.
chivracq
Posts: 9412
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Help with Code - If button not available then skip

Post by chivracq » Fri May 20, 2016 4:52 pm

alexboy94 wrote:Hi,

I am making a simple code that selects buttons on peoples profiles and then does it over again.

The problem is, at times not all the buttons are there, so it creates an error and stops the code from running.

I was wondering if there was a way to say if this isn't available to press, then go to next step

Ex of code:

Code: Select all

BACK
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(16)>DIV>DIV>DIV>DIV>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(3)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(4)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(8)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(7)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(6)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(5)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
BACK
WAIT SECONDS=100
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(17)>DIV>DIV>DIV>DIV>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(3)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(4)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(8)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(7)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(6)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(5)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
BACK
Its a random point where one of the event selectors will fail 1-8, due to the button not being there, due to the user not adding it. I was wondering if there was a statement for each button I could put. that would do:

Code: Select all

EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(16)>DIV>DIV>DIV>DIV>A" BUTTON=0
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV>DIV>DIV>UL>LI>BUTTON" BUTTON=0 
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(3)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(4)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(8)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(7)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(6)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*
EVENT TYPE=CLICK SELECTOR="#main>DIV:nth-of-type(3)>DIV:nth-of-type(5)>DIV>DIV>UL>LI>BUTTON" BUTTON=0
*if not available skip to 1*

*1*
BACK
If I can get this to work, then my program will be flawless.
The "Help with Code" part in your Thread Title is a bit useless, all the Threads on the Forum are related to "Help with Code"...! :roll:

CIM for me too read, read my Sig, but from your Thread Title, I would think, simply use '!ERRORIGNORE'... :idea:

And URL not posted and the EVENT Mode is very difficult to follow, I hope you gave enough Details in your Description if my Suggestiion doesn't help...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
alexboy94
Posts: 9
Joined: Fri May 20, 2016 3:06 pm

Re: Help with Code - If button not available then skip

Post by alexboy94 » Mon Jun 06, 2016 4:18 pm

Firefox version is 46.0
Windows 10 Version 1511
I macros Version 8.9.7


Fix: SET !ERRORIGNORE YES

this fixes the problem
janib4all
Posts: 132
Joined: Wed Jul 21, 2010 6:44 am
Location: Karachi, Sindh, Pakistan
Contact:

Re: Help with Code - If button not available then skip: FIXE

Post by janib4all » Tue Jun 07, 2016 8:59 pm

Yes and use "Set !Timeout_Step 0" in order to avoid unnecessary waiting.
Hire the BoT-fReeak!
botspecialist.blogspot.com
Post Reply