Barak B
Barak B

Reputation: 84

Run a javascript function of a website using Python

I've been wondering whether or not this is possible -

Here is a picture of Chrome's "inspect element" on this website. enter image description here

Is it possible for me to run the "goCourseDetails" js function with my own parameters?

I'm using Python and selenium to try and write a script that does that for me, but I don't know how to access the JS function.

Thanks in advance.

Upvotes: 1

Views: 532

Answers (1)

yong
yong

Reputation: 13712

You can use driver.execute_script() to execute javascript snippet in browser.

The function goCourseDetails can be obtain from browser global variable window

driver.execute_script('window.goCourseDetails.call(null, arguments)',
      <department>, <degreelevel>, <course>, <detail>, <year>, <semester>
)

Upvotes: 1

Related Questions