I've written hundreds of KM macros. But I'm a little stuck on this one. Maybe someone has some suggestions?
I have to go through a long list of 2000 items on a website. On some of them I want to run a macro. This macro works great. I've fine tuned everything. I manually go through the list and for the ones I have to correct, I hit control-mac-B and it does its thing. The trouble it, it has 25 steps, and takes 30 seconds and I have thousands of them to do.
All I can think of is to create another macro that allows me to manually go through the list and pick "Y" or "N" and send it to an Excel sheet ....
... then create a wrapper for my macro that goes through the Excel sheet and runs the macro when it sees a Y, and skips to the next one when it see an N.
Can anyone think of a less clunky way to do this?
What if I went through the list using KM macro record? It would record ...
Type the up arrow
Type the Y
Type the up arrow
Type the Y
Type the up arrow
Type the N
... etc. I thought I could just search and replace, but it doesn't look like there is a 'search and replace' function in KM.
Let's see if I understand your question. What you'd like to do is go through all the items manually, and determine which ones you want to run your macro against. Then you want to go back through the items, and have it automatically run the macros on the items you've selected, so you don't have to sit there and wait for it. Right?
Well, you could make an empty variable, then append either Y or N followed by a newline. This would give you a list, which you could then use "For each item in a list", while going back through the web items.
So you wouldn't be playing back keystrokes - your macro that goes through the web items would just use the answers in the list, instead of asking you what to do.
Yes, your first paragraph is exactly right. That's what I want to do.
Are you saying I could manually type out the Y/N list into a multi-line variable? Interesting.
I'll most likely have to kill and restart this macro at some point when the internet burps or whatever. Actually, now that you make me think of it, there is no numbering the web page, so I suppose I should probably save off the name if the item too because if I have to restart it will be much easier to find the spot to restart.
So anyway, I really need to just go through them on the web page because there are thousands, and even at 1 second each it's going to take an hour or more.
Okay, so let's say I have this list all done and it's sitting in a text editor or Excel.
1 Y Amber shoes
2 Y sandals
3 N green trainers
4 Y tennis shoes
5 N gold shoes
6 N running shoes
7 N high heels
8 Y nurse shoes
9 Y surfing shoes
999 Y brown dress shoes
I'm looking for the most professional way to run this macro on the Y items?
Should I just tell the macro to go to excel, down arrow, get the cell value, if Variable = 'Y' then run the macro? Actually, I remember doing a macro like this before. I did use Excel to give me values to paste in. Pretty similar, and I remember last time too, thinking "this is really kind of a hack, there's got to be something in KM that can do this better."
No, I'm sayin that you have a macro (with a hotkey) build this variable, but let's hold on a second:
So you're saying that each item has a name? If so, it gets even easier. And forget about a spreadsheet - you can do all this in KM.
So right now, when you're on an item you want to process, you hit a hotkey to run your macro. You'll do the same thing, except you'll launch a different macro which appends the item name to a variable. So this variable will only have the names of the items you want to process, each name on a new line within the variable.
Then you have two options, depending on which works best for you:
You could walk through the item names in the variable, and for each item name, go to that item on the web page and process it.
If it's better to walk through all the items on the web page, then do that, and for each item name, see if it's in the variable and if it is, process the item.
Does that make sense? If so, I can write something to show you exactly how I was thinking it would work.
By the way, I'm not saying that you should run your macro in counter-based loop like this. Maybe it's the right way for you, maybe not. But I just wanted to show you how the variable could be used.
Another thought. If there's a unique way to identify each item on your web page, like a unique ProductID or something like that, then instead of storing Yes and No lines, you could store only the ProductID:
So you'd do what you do now - go through each line, and press a hotkey when it's something you want to process. The hotkey would launch a macro that appends the ProductID to the variable. So you'd end up with a variable that has ProductIDs on separate lines.
Then when you do the ForEach on the variable, you could use the ProductID to position yourself on the right product line, then do your 30 second process.
First off, Dan, your script was very helpful in advancing this project. Thanks again.
So, it looks like the number of items is going to be more like 20,000 - 50,000 instead of 2000 - 3000. And this website with the products on it is flaky. I've been using your script, set at 100. Occasionally the script goes off the rails because one of the responses, like a 'save' will take 15 seconds instead of the usual 2, or the page auto-reloads ever few hours ... and several other traps. I tried setting the pause timers higher and neutralized the keystrokes when possible to prevent catastrophes, but basically I need to sit here and watch it, or it goes off the rails and the macro is basically throwing random keystrokes at the site.
In all my hours of watching it. I realize I really do need feedback. The KM macro needs to know when the page is done saving or when new items have loaded. I'm trying out the 'Find an Image' command. There's no 'loading complete' image or anything though, so it's tricky.
Got any suggestions? Is this a good application of KM, or should I be using Ansible or something else for this?
Sorry, I meant Selenium, not Ansible. It seems to be a browser automation tool used for testing. I really don't want to jump to a new platform when all I really need is for KM to wait until something is done happening instead of using a high timer for the worst case. Like when I make the changes and hit save. It usually takes about 2 seconds. Once in a while it takes 10 to 15 seconds. If I set the timer at 18, I'm wasting 15 seconds every time, but it fails only very rarely. If I set the timer to wait for 3 seconds only, it will be fine for probably 50 items and then go berserk because the save wasn't done.
I need to figure out how to make KM wait until something happens, like the 'save' finishing, so I don't spend 45 seconds on every item when most of the time it only takes 15 - 20 seconds.