Bash script to click button on an HTML page
You should consider using opensource Selenium.

With a Selenium IDE plugin to Firefox you can record your actions (opening a page, clicking on a button), replay these songs, and generate Python or Ruby scripts rich you can customise and call from CLI.

Sample script testing default Apache availability might look like this:

#!/usr/local/bin/python

DEST_URL='http://webserver.dev/'

import unittest
from selenium import webdriver
from selenium.webdriver.common.proxy import *

class WebInterfaceTest(unittest.TestCase):

  def setUp(self):
     self.driver = webdriver.Firefox()

  def tearDown(self):
     self.driver.quit()

  def test_web_interface(self):
    self.driver.get(DEST_URL)
    self.assertIn('Apache2 Debian Default Page: It works', self.driver.title)

if __name__ == "__main__":
  unittest.main()