How to find the value of a Javascript element in a web page?

Hi, I am trying to learn the beginnings of how to scrape data in a website using Javascript, and I am a babe in the woods unfortunately. I have a website with a field I am trying to read the result from (starting with XLV HALO...). How would I go about getting the results of this field either using KM directly, or Applescript, which would be executed through KM? Any help would be appreciated.


example 1

I'm no JS wiz, but I'll have a go while we're waiting for @ComplexPoint :wink:

The general form for getting this sort of thing is

referenceToElement.attributeToGet

Luckily this button has an id -- id="select-chart-button" -- and ids are required to be unique on a page. That means we easily get a reference to the element we want without having mess with an array of objects

getElementById("select-chart-button")

You can see a list of a button's attributes at <button>: The Button element - HTML: HyperText Markup Language | MDN. From that and the "Accessibility" section of your screenshot, the name attribute looks like a good bet. Putting that together with the previous and we have

getElementById("select-chart-button").name

So I'd try that in an "Execute JavaScript in Front Browser" action and see what happens:

image

1 Like

What kind of value / result do you need ?

More importantly, what is the problem that you want to solve ?

1 Like