Execute arbitrary JS programmatically on a page
I want to programmatically开发者_StackOverflow社区 open a web page, execute some JS to fill out and submit a form, then examine the result. What is the best way to do this from Java?
Sounds like you need Cocoon WebTest
http://cocoon.apache.org/
HtmlUnit does all what you want: opening a web page, executing some JS and submitting the form. I'm only not sure how you'd expect to "see" the result. At least, HtmlUnit returns the response in flavor of an InputStream
.
See also:
- What are the pros and cons of the leading Java HTML parsers?
Update: if you're actually looking for automated webpage testing, you may find Selenium interesting.
精彩评论