FAQ: How To Click on Link in a Browser

faq
tutorial

#1

###FAQ: How To Click on Link in a Browser

I’m starting this topic to collect examples of how to automate clicking on a link in a browser (Safari or Google Chrome). Once we have enough good examples, I’ll either rewrite this topic, and use the examples to create a KM Wiki article.

###Help Please

  • If you know of a good example that has already been posted, please reply and post the link to the example.
  • If you have a good script or macro for this, and it has not been posted, please first post in the “Macro Library” category, and then post a link to it here.
  • If you have a blog and/or video that addresses this subject, please post a link to it.

I’ll start it off by posting an example that was solved today.


#2

Answer:

Turns out the “link” is actually a form submit button.
All of the forms to “renew” had a HTML class of “manage renew”.
You can find this by using the Inspect tool of Chrome (best) or Safari.
See this short video to learn how to use the Inspect Tool.

You might try this in a Execute a JavaScript in Browser action (KM Wiki):

document.getElementsByClassName("manage renew")[0].submit()

This should submit the FIRST “renew” form, indicated by the [0] array element. If that is not it, you can try others by using [1] etc.


#3

###MACRO: [WEB] Click on Link Using XPath [Example]

###Video Showing How to Use Chrome Inspect Tool to Get XPath

  • The Inspect Tool is our most valuable tool to determine the JavaScript needed to click on a “link”.
  • Some Options for clicking on a link:
    • Using a XPath
    • Using the click() method
    • Using the submit() method

#4

I was using the “inspect element” in the developer’s tool in Safari, but the set up of the KM macro was above my pay grade!


#5

Another example:
###Click on Radio Button and Submit Button in Safari and Chrome

Uses the native KM Actions: