Testing links in a web app

2019-08-06 04:39发布

问题:

I need to test links inside a web application. I have looked at a couple tools (Xenu, various browser plugins, link-checker(ruby)). Nothing quite fits my needs which I will detail below.

  • I need to get past a login form
  • test needs to be rerun for different types of users (multiple sets of login credentials)
  • would like to automate this under a ci server (Jenkins)
  • the ability to spider the site

Does anyone have any ideas? Bonus if I can use Ruby to do this!

回答1:

What you are asking for is beyond most of the test tools once you throw in the ability to spider the site.

That final requirement pushes you into the realm of hand-coding something. Using the Mechanize gem you could do all those things, but, you get to code a lot of the navigation of the site.

Mechanize uses Nokogiri internally, so it's easy to grab all links in a page, which you could store in a database to be checked by a different thread, or some subsequent code. That said, writing a spider is not hard if you're the owner of the pages you're hitting, because you can be pretty brutal about accessing the server and let the code run at full speed without worrying about being banned for excessive bandwidth use.