I have a simple tornado app here.
class TestHandler(tornado.web.RequestHandler):
def get(self):
print "here ~!"
self.render("test.html")
def post(self):
action = self.get_argument("add")
print "action : ", action
self.write(action)
if __name__ == "__main__":
application = tornado.web.Application([
(r"/test", TestHandler),
])
application.listen(8126)
tornado.ioloop.IOLoop.current().start()
then here is the "test.html".
<html>
<head>
</head>
<body>
<form action="/test" method="post" id="aaa">
<input type="text" id="add" name="add" value="add">
<button id="go" onclick="submit();">go</button>
</form>
</body>
</html>
and finally the phantomjs script:
var page = require('webpage').create();
page.open('http://host-ip/test', function() {
page.evaluate(function() {
document.getElementById("aaa").submit();
});
phantom.exit();
});
when I run the script, I got "here ~!" in my tornado-app, but no more output. meanwhile, I open 'http://host-ip/test' and click the button, then I got both "here ~!" and "action : add" in my tornado-app's output.
BTW, I also tried jQuery in PhantomJS script to click the button, but still only get "here ~!", no "action : add"...