开发者

canoo or jwebUnit for automated headless web client?

开发者 https://www.devze.com 2023-04-01 17:33 出处:网络
I\'m writing an application 开发者_C百科in groovy with grails that needs to do some automated usage of a couple of websites. So I need something that will perform a similar task to functional web appl

I'm writing an application 开发者_C百科in groovy with grails that needs to do some automated usage of a couple of websites. So I need something that will perform a similar task to functional web application testing, without a browser being needed. I would also like it to be as lightweight as possible and of course completely headless.

There are two options that I am aware of so far. Canoo which has a nice grails plugin and conveniently also a firefox recorder plugin and EasyB/JWebUnit which can be recorded with Selenium.

Canoo seems very heavy and I don't know what I'd have to do to get it to run in a grails service neatly.

Perhaps I'm thinking about this wrongly though. Has anyone here done this kind of thing in Java or Groovy? Am I better off just dropping out to curl on the command line perhaps?


Have you though about just sending your web requests? Maybe you don't need a full blown headless browser and a line like

def html = new Url("http://example.com").text

is enough for your app?

A testing tool or framework is great when you have to click virtual buttons. But if you only have to remote control a website, sending a request could be enough.

Update: if you need to send POST requests and handle cookies, then the Url-Class isn't enough. But you can use the http builder instead. Here are two URLs which will get you started:

  • http://blog.swwomm.com/2011/01/groovy-httpbuilder-cookies.html
  • http://groovy.codehaus.org/modules/http-builder/doc/post.html
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号