title: Use Python to call a JavaScript function that is on a webpage
body: <p>I created a webpage that has one JavaScript function called <code>foo(z)</code>. For the sake of this question, let's assume that all <code>foo(z)</code> does is call <code>console.log(z)</code>.</p>
  <p>Is it possible to run a Python script that can trigger the JavaScript <code>foo(z)</code> function that exists on the webpage?</p>
  <p>In other words, I load up the webpage in my browser that contains <code>foo(z)</code>. Then I execute the Python script on my local machine and it reaches into the browser and calls the JavaScript <code>foo(z)</code> function and you thus see <code>z</code> output to the browser console (because all <code>foo(z)</code> does is call <code>console.log(z)</code>).</p>
  <p>It seems like there is a lot of info on executing JavaScript with Python, but I don't think any of those resources deal with executing a JavaScript function that is inside a webpage.</p>
  <p>Edit: I built a game on a webpage that humans can play. Now I want to create a Python bot that can call the JavaScript functions on the webpage so that it too can play the game.</p>