Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to run JavaScript function in browser console?

In my Python program, I need to run the hcaptchaCallback function (screenshot), but the function name has a different numbers each time. Can I somehow run this function by specifying only the first part of the name (hcaptchaCallback)?

driver.execute_script('hcaptchaCallback...()')

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

There is nothing that lets you really do that. You might be able to pull off looping over the globals and looking for a variable that starts with your string.

window[Object.keys(window).find(k=>k.startsWith("hcaptchaCallback"))]();

that will call it the way you showed, but looking at the function signature, looks like you are going to have to use call()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading