This can be done using two ways:
- GUI way ==> Use Selenium
- Terminal way ==> Use
ghost.py or phantomjs
Terminal Way
You can go ahead and use ghost.py or phantomjs. Read their documentations on how to use them here : Ghost.py and phantomjs
An example using Ghost.py
First install ghost.py. To install this, you will need pip. Hence, do this on a ubuntu based system:
sudo apt-get install python-pip
sudo pip install Ghost.py
Now, you can use Ghost.py in your script to automate any javascript based actions. Here is a sample script derived from the official documentation:
#!/usr/bin/python
#script.py
from ghost import Ghost
ghost = Ghost()
page, resources = ghost.open('http://my.web.page')
#Run javascript action
result, resources = ghost.evaluate( "document.getElementById('my-input').getAttribute('value');")