[MULTIPLE] Click Google Chrome Link

How to click on multiple links (with same anchor text) on a page in Chrome browser?

PROBLEM
Under Click Google Chrome Link Macro in Keyboard Maestro, it only clicks the 1st View Detail link

WANTED SOLUTION
Click on all 4 View Detail links

If there’s more than 1 View Detail link.
For example, there are 4 View Detail links



View Detail



View Detail



View Detail



View Detail

Take a look at this macro. The core of it does exactly what you are asking for.
You would just need to change the Actions that process each link to do as you wish.

Actually, this is probably a better macro to start with.
Take a look, and let me know how it goes.

Thanks.

But it seems pretty complicated.

Could you refine it down to these 4 simple anchor texts in my example?

Thing is, they’re the same anchor texts; View Detail

Extracting data from a web page usually is.
Of course, how "complicated" it is depends on the coders skill/experience.

Sorry, but I don't have the time for that right now.
Have you tried using the last macro I posted?

No I have not tried.

It’s a bit too complicated for me… hm

OK, I have enhanced my macro to provide for an optional FILTER of the Link Text. If used, it will return ONLY those links that CONTAIN the filter.

I have tested this ONLY on this page, so you will need to test on the real page you want to get the links from.

If you want to "click" of each of these links, you can ADD this KM Action in the "For Each" Action block:

To setup this macro for your web page, you will need to determine the CLASS of the major HTML Element that either contains, or is used by, each of the Links of interest. You can do this by inspecting the page. Right-click on the first link, and select "Inspect", and you will see:

The first part of this Youtube Video shows you how to use the Inspect Tool.


If you have any questions about setup or use of this macro, let me know.

###MACRO:   @WEB Extract & Process Links on Web Page Using HTML Class [Example]

~~~ VER: 1.2    2016-12-30 ~~~

####DOWNLOAD:
@WEB Extract & Process Links on Web Page Using HTML Class [Example].kmmacros (47 KB)


###ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Extract Web Page Links Using HTML Class, and Process Each Link

MACRO SETUP

Note that all Actions with the magenta color are designed to be changed by you.
In some cases, they MUST be changed to fit your specific requirements.

  1. Move Macro to Macro Group that limits trigger to apps you plan to use it with
  • (Note: This macro can be used ONLY with Google Chrome, but could be easily changed to use Safari, just by replacing the Chrome Actions with Safari Actions)
  1. Assign a Trigger
  2. Set the below Action "SET Source URL" to the URL of the Web Page that contains the list of links.
  3. Set the below Action "SET HTML Class" to the unique Class of the HTML Element that contains each, or all, of the list of links.
  4. Set the below Action "SET Filter for Link Text" to text that the link must contain. Clear the text (no characters) if you do NOT want a Filter.
  5. ADD Actions at the bottom of the Macro to process each link as you desire.
  6. If your web page has a lot of links, it is best to first TEST on a similar page with just a few links)

HOW TO USE:

  1. Open Google Chrome Browser (any page)
  2. Trigger this Macro

WHAT IT DOES:

  1. Gets a HTML Collection of all Elements that have the specified Class Name
  2. Gets a HTML Collection of all Links (Anchor Tags) within that collection
  3. Builds a TAB delimited list (array) of Link Text & URL from that collection
  4. Returns a TAB delimited String, with each link on a separate line
  5. FOR EACH link/line in that String:
  • Using RegEx, parses it into Title and URL
  • Process that Link

TAGS: @Links @Web @JavaScript @HTML

USER SETTINGS:

  • Any Action in magenta color is designed to be changed by end-user
  • This macro uses Google Chrome, but can be easily changed

ACTION COLOR CODES

  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Varibles or Clipboards

REQUIRES:
(1) Keyboard Maestro Ver 7.3+
(2) Yosemite (10.10.5)+


Did my macro posted above solve your problem?

If my macro/post solves your problem/question as originally stated, please check the "Solved" checkbox at the bottom of my above post.

Otherwise, please post your remaining questions/issues about this problem.
If you other questions, please start a new topic.