I want to extract the array "o" which holds data that is used to draw a polygon. Just using driver.execute("return o")
or using console.log doesn´t work. Has someone an idea how to achieve this ?
const zt = function(e, t, n, r) {
const i = r.playerId
, {subscribe: a} = de.get(r.playerId)
, o = r.hotspots
, s = Ce(`#${f}skin_desktop .${f}svg_hotspots`)
, l = 100;
let d = null
, c = "";
if (!s || o.data.length <= 2)
return;
const {is: p, browser: u} = H.get()
, g = p.ie || p.edge && u.version <= 18;
o.data.splice(0, 2);
const m = o.data.length
, h = 1e3 / (m - 1)
, _ = Math.max.apply(null, o.data) / l
, v = (s.firstChild || s.content.firstChild).cloneNode(!0);
v.getElementsByTagName("clipPath")[0].setAttribute("id", i + "_hotspotsClip"),
v.getElementsByTagName("g")[0].setAttribute("clip-path", "url(#" + i + "_hotspotsClip)"),
n.appendChild(v),
d = Ce(t.polygon);
const b = Ce(t.container)
, y = Ce(t.progress);
y.setAttribute("fill", o.chartColor),
b.style.height = o.chartHeight;
for (let f = 0; f < m; f++) {
const e = parseInt(o.data[f], 10);
c += h * f + "," + (l - Math.floor(e / _)) + " "
}
function A() {
St(b, "visible")
}.....
2
Answers
You might be able to in certain circumstances. The problem is that
o
doesn’t exist outside of that function meaning the only way you would be able to print out the contents is from *within* that function. I’m assuming you aren’t on the dev team for this site so that means that you would have to find that method in the page, grab the entirefunction()
, modify it, and then trigger it somehow. If it runs only on load, etc. then I don’t think there’s any way to get that info. If there was a way to trigger the code, e.g. a Submit button, etc., then it should output the info you’re looking for.One way to achieve this is to modify the code and assign the value of o to a property of the window object. For example, you can add the following line after the declaration of the o variable:
Then, in your Selenium script, you can execute javascript to retrieve the value of the window.myPolygonData property: