Need help! Macro stops in the middle of loop.

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
feedz
Posts: 3
Joined: Sat Jun 23, 2018 1:51 am

Need help! Macro stops in the middle of loop.

Post by feedz » Sat Jun 23, 2018 1:59 am

So I basically have recorded a macro that has a basic function.

1. I have 100 tabs open in google, all of them have some google search results for different search terms.

2. There is an extension active that creates a link on the left side of search results and if you click it it will export the results as a csv file.

3. I need the macro to click this link, move to the next tab, click the same link for that one, next tab etc... so I have 100 csv's.

4. When I run the macro it works for like 4 tabs and then an error comes up saying "tag waiting (6s)" or something like that, and after that count down is finished the macro's basically stopped. The error message it gives is this

"RuntimeError: element specified by #gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4) not found, line: 4"

Here is the original macro code.

Code: Select all

TAB T={{!LOOP}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:Export<SP>CSV
EVENT TYPE=KEYDOWN SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17 MODIFIERS="ctrl"    <------- Line 4
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=34 MODIFIERS="ctrl"
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17
So basically the button link button text from the extension I mentioned is Export CSV hence the first step. Then the next bit you see is when I press "ctrl+pg down" to move to the next tab. And that is basically my macro. Apparently it has an issue on line 4.

Need help with this, what should I change?
Last edited by feedz on Sat Jun 23, 2018 5:35 am, edited 1 time in total.
feedz
Posts: 3
Joined: Sat Jun 23, 2018 1:51 am

Re: Need help! Macro stops in the middle of loop.

Post by feedz » Sat Jun 23, 2018 4:51 am

Update!

So I have managed to make it work now for some reason by changing the code to this

Code: Select all

TAB T={{!LOOP}}
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=BUTTON ATTR=TXT:Export<SP>CSV
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=DIV ATTR=ID:rcnt
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=BUTTON ATTR=TXT:Export<SP>CSV
EVENT TYPE=KEYDOWN SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17 MODIFIERS="ctrl"
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=34 MODIFIERS="ctrl"
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17

I added two click events on the "export csv" link because previously, after I finally got it to continue past 4 tabs, it would then download some tabs twice and others not at all, so to bypass this I did two clicks, so basically, then I get a bunch of duplicates as well, which I delete to get a final list. So it seems to work, but I would still like to make it more reliable. Maybe wait 2 seconds between each tab?

Secondly another issue.

I have a extension called mozbar, it appears as a "bar" below the bookmarks bar, I want to also click an export link on this extension for every tab, but the imacro does not detect any activity I do on this bar, it's like, it pushes the whole page window down? So its not actually a part of the webpage? I dont know but it seems like that. I just found out that the link is actually an xpath, all I know is the div class where the link is placed in.

here is the code for the button, the class is "btn export"

Code: Select all

<div class="serp-toolbar">
    <div class="btn export" data-tooltip="Export SERP Analysis to CSV">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 60">
      <path d="M40 48.407H20v-14h4v10h32v-30H44v-10H24v15h-4v-19h32.544l3.728 3.073L60 6.552v41.855H40zm12-38c2.2 0 4-.247 4-.548 0-.304-1.237-1.64-2.75-2.97-1.513-1.33-3.313-2.435-4-2.453L48 4.407v6h4zm-40.788 27H9.425l-4.713-4.785L0 27.838v-2.606l4.75-4.373 4.75-4.375 1.75-.04 1.75-.04v3.425l-2.75 2.25-2.75 2.253 14.69.036 14.692.036.645 1.044.645 1.044-1.208 1.457-1.21 1.458H7.73l2.635 2.072L13 33.55v3.854h-1.788z"></path>
    </svg>
    <div class="onboarding-text">
      <em>Export this SERP to a CSV.</em>
    </div>
  </div>

  <div class="divider"></div>

  <h3>Search Profiles</h3>

  <div class="btn search-profile selected" data-engine="google" data-tooltip="">
      Google US (non-personalized)
      <div class="arrow arrow-down"></div>
      <div class="onboarding-text">
        <p>Open <em>Search Profiles</em>.</p>
        <p>Use the MozBar to perform geo-located searches.</p>
      </div>
  </div>


    <div class="right-panel">
      <a href="https://moz.com/logout" target="_blank" class="logout">
        Logout
      </a>
    </div>
</div>
chivracq
Posts: 8523
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Need help! Macro stops in the middle of loop.

Post by chivracq » Sat Jun 23, 2018 5:42 am

feedz wrote:So I basically have recorded a macro that has a basic function.

1. I have 100 tabs open in google, all of them have some google search results for different search terms.

2. There is an extension active that creates a link on the left side of search results and if you click it it will export the results as a csv file.

3. I need the macro to click this link, move to the next tab, click the same link for that one, next tab etc... so I have 100 csv's.

4. When I run the macro it works for like 4 tabs and then an error comes up saying "tag waiting (6s)" or something like that, and after that count down is finished the macro's basically stopped. The error message it gives is this

Code: Select all

"RuntimeError: element specified by #gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4) not found, line: 4"
Here is the original macro code.

"

Code: Select all

TAB T={{!LOOP}}
TAG POS=1 TYPE=BUTTON ATTR=TXT:Export<SP>CSV
EVENT TYPE=KEYDOWN SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17 MODIFIERS="ctrl"    <------- Line 4
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=34 MODIFIERS="ctrl"
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17
"

So basically the button link button text from the extension I mentioned is Export CSV hence the first step. Then the next bit you see is when I press "ctrl+pg down" to move to the next tab. And that is basically my macro. Apparently it has an issue on line 4.

Need help with this, what should I change?
(F)CIM...! :mrgreen: (Read my Sig...)
feedz wrote:Update!

So I have managed to make it work now for some reason by changing the code to this

Code: Select all

TAB T={{!LOOP}}
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=BUTTON ATTR=TXT:Export<SP>CSV
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=DIV ATTR=ID:rcnt
SET !TIMEOUT_STEP 1
TAG POS=1 TYPE=BUTTON ATTR=TXT:Export<SP>CSV
EVENT TYPE=KEYDOWN SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17 MODIFIERS="ctrl"
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=34 MODIFIERS="ctrl"
EVENT TYPE=KEYUP SELECTOR="#gsr>DIV:nth-of-type(9)>DIV:nth-of-type(2)>DIV>BUTTON:nth-of-type(4)" KEY=17
I added two click events on the "export csv" link because previously, after I finally got it to continue past 4 tabs, it would then download some tabs twice and others not at all, so to bypass this I did two clicks, so basically, then I get a bunch of duplicates as well, which I delete to get a final list. So it seems to work, but I would still like to make it more reliable. Maybe wait 2 seconds between each tab?
feedz wrote:Secondly another issue.

I have a extension called mozbar, it appears as a "bar" below the bookmarks bar, I want to also click an export link on this extension for every tab, but the imacro does not detect any activity I do on this bar, it's like, it pushes the whole page window down? So its not actually a part of the webpage? I dont know but it seems like that. I just found out that the link is actually an xpath, all I know is the div class where the link is placed in.

here is the code for the button, the class is "btn export"

Code: Select all

<div class="serp-toolbar">
    <div class="btn export" data-tooltip="Export SERP Analysis to CSV">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 60">
      <path d="M40 48.407H20v-14h4v10h32v-30H44v-10H24v15h-4v-19h32.544l3.728 3.073L60 6.552v41.855H40zm12-38c2.2 0 4-.247 4-.548 0-.304-1.237-1.64-2.75-2.97-1.513-1.33-3.313-2.435-4-2.453L48 4.407v6h4zm-40.788 27H9.425l-4.713-4.785L0 27.838v-2.606l4.75-4.373 4.75-4.375 1.75-.04 1.75-.04v3.425l-2.75 2.25-2.75 2.253 14.69.036 14.692.036.645 1.044.645 1.044-1.208 1.457-1.21 1.458H7.73l2.635 2.072L13 33.55v3.854h-1.788z"></path>
    </svg>
    <div class="onboarding-text">
      <em>Export this SERP to a CSV.</em>
    </div>
  </div>

  <div class="divider"></div>

  <h3>Search Profiles</h3>

  <div class="btn search-profile selected" data-engine="google" data-tooltip="">
      Google US (non-personalized)
      <div class="arrow arrow-down"></div>
      <div class="onboarding-text">
        <p>Open <em>Search Profiles</em>.</p>
        <p>Use the MozBar to perform geo-located searches.</p>
      </div>
  </div>


    <div class="right-panel">
      <a href="https://moz.com/logout" target="_blank" class="logout">
        Logout
      </a>
    </div>
</div>
Hum..., good-good, you seem to be making some Progress... :D
... Hum, and editing your previous Posts a bit "wildly", Reason why I always quote, ah-ah...!

But mention your FCI for me to have a look, I still "see" a few "strange Things" in your Script(s)..., and you could mention which first Add-on you use to create the Download Links...

Hum, and 'Ctrl^Key=34' = 'Ctrl^PgDn' to switch to the 'Next Tab', but what are 'Ctrl^Key=17' and 'Key=17' supposed to do...?
You should add that Info as Comments to your Script, even just for yourself if you ever want to rework on your Script after a while..., the 'EVENT' Mode is very difficult to follow if you don't put Comments in your Script...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
feedz
Posts: 3
Joined: Sat Jun 23, 2018 1:51 am

Re: Need help! Macro stops in the middle of loop.

Post by feedz » Sat Jun 23, 2018 5:55 am

chivracq wrote:
Hum..., good-good, you seem to be making some Progress... :D
... Hum, and editing your previous Posts a bit "wildly", Reason why I always quote, ah-ah...!

But mention your FCI for me to have a look, I still "see" a few "strange Things" in your Script(s)..., and you could mention which first Add-on you use to create the Download Links...

Hum, and 'Ctrl^Key=34' = 'Ctrl^PgDn' to switch the next Tab, what are 'Ctrl^Key=17' and 'Key=17' supposed to do...?
You should add that Info as Comments to your Script, even just for yourself if you ever want to rework on your Script after a while..., the 'EVENT' Mode is very difficult to follow if you don't put Comments in your Script...
The add on I use is called mozbar, I am attaching an image. It basically creates this bar on all open tabs once you activate the extension, then when you click that button, it exports a csv of the google search results. This is the one I really need. However the macro cant seem to click it. I am using another extension called "seo quake" which also has a similar button which CAN be clicked by the macro, but its export is not as good as the mozbar extension. So I want to find out how I can click the mozbar button, the imacro simply does not detect any activity I carry out on the "mozbar" bar on the top...

Image

I dont know anything about coding, dont know what FCI means. I do know that the inspect element of that button reveals that there is some "xlmns" code which is xpath or something?


as for the key=17, I dont know what that is. All I do on the keyboard is hold down ctrl and pgdown together for a brief instant, to change tabs (which is part of my macro) but it results in that extra key as well, but as long as it works its okay. I also just noted that the chrome extension bar that pops up form mozbar is an iframe. Below is the code for where the frame starts

Code: Select all

<iframe id="mozbar-wGA7MhRhQ3WS" class="mozbar-wGA7MhRhQ3WS" frameborder="0" scrolling="no" srcdoc="<html class="">
Bilby
Posts: 1
Joined: Thu Jul 19, 2018 10:03 am

Re: Need help! Macro stops in the middle of loop.

Post by Bilby » Thu Jul 26, 2018 1:51 pm

I'd appreciate if you shared your progress with this, Feedz. I'm trying to accomplish a similar thing and I'm also stuck.
Post Reply