is there any way I can scrape web pages that uses AJAX?
by using something like ruby + mechanize on linux server that doesn't have monitor attached (linode.com for example)
http://watir.com/ would be a solution but I guess not applicable to linode.
Check out TestPlan. It can do testing without a monitor -- by using the HTMLUnit backend. It handles quite a lot of JavaScript, including AJAX. I use it to scrape several pages and have built several tests of AJAX with it.
You can also run TestPlan with a browser if you want. This gives you the best of both worlds: develop tests and visually see what is happening, and then switch to the display-less mode.
Related
I should crawl https://motul.lubricantadvisor.com/Default.aspx?data=1&lang=ENG&lang=eng
but how can I do crawl the this website. I think it use jQuery. some people say you should use ajax. but I'll contain database by mongodb so I'll use node.js how can I do that?
Instead of using NodeJS (designed for other purposes), use PhantomJS, which is specially designed for testing/scraping of webpages. Since it uses JavaScript, it should be pretty easy to learn for you.
Another method (if you want to use Node) is to figure out how this webpage communicates to the underlying backend and connect directly to the backend using a library such as node-XMLHttpRequest.
Yet another option is to scrape data directly from the webpage using artoo.js, which injects directly into the rendered webpage and allows you to scrape the webpage using jQuery selectors.
Ethics note: However, as with all scraping, please be careful and only scrape websites for which you have explicit permission to. Not only may you be stealing their data, you may be wasting their bandwidth (and therefore their money), so please be considerate when using any sort of scraping tool.
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!
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.
Is there a way to visually see if htmlunit is performing the correct commands? I have a hard requirement to use htmlunit. I just don't know if it's filling out all the form correctly.
HTMLunit is designed to be GUI less browser and for your requirements you can consider using Webdriver or Watir or Selenium etc such tools. In case you are in to Ruby, take a look at Celerity which wrapped HtmlUnit in a Watir-ish API; In fact Celerity is itself being wrapped by Culerity, which integrates Celerity and Cucumber and that could be of more interest to you.
Yes. you can see the HTTP traffic by using proxy like webscarab, fiddler..etc.
Make sure the following
Set the proxy details to Htmlunit via contsructor. I think it is webclient
Make sure you either trust all the certs or add proxy certificate to truststore
What do you mean by "correct commands"? HtmlUnit itself won't give you a running description of what it's doing, if that's what you mean. As suthasankar says, HtmlUnit is a headless browser (intentionally so) and will never give you the cool Watir experience of watching pages fly by.
Any time I've wanted to know what's happening during a test's execution, I have added logging statements at various points in the test code and then watched them in the console. You could send messages to any other monitoring system you instead.
It wouldn't take much to then write wrappers around the "commands" you're interested in, like "getPage" and button clicks and form entries and the like.
It's not possible to view what HtmlUnit is doing unless you code logging and some sort of display yourself. I have done this in the past, and it's helpful to a certain degree but it's not really possible to have a visual feedback to see what HtmlUnit is doing. Even with logging, it's not possible to know every single detail what HtmlUnit is doing or where it goes wrong, so it's an extremely time consuming task. I even resorted to outputting the current page viewed but this is pretty limited as an html page cannot tell the actual "commands" HtmlUnit is executing on that page.
Another approach would be to use Selenium, which executes your "commands" in a visual manner you can see where things go wrong instantly by watching it.
When I make HTTP Request in JMeter I get Response data like "This page uses JavaScript and requires a JavaScript enabled browser." How is it possible to fix this problem.
JMeter is not a browser, and does not interpret the JavaScript in downloaded pages.
From the JMeter wiki:
JMeter does not process Javascript or applets embedded in HTML pages.
JMeter can download the relevant resources (some embedded resources
are downloaded automatically if the correct options are set), but it
does not process the HTML and execute any Javascript functions.
If the page uses Javascript to build up a URL or submit a form, you
can use the Proxy Recording facility to create the necessary sampler.
If this is not possible, then manual inspection of the code may be
needed to determine what the Javascript is doing.
Depending on what you are doing, you could create an execution test using Selenium IDE for Firefox. The test will run in your browser so the JavaScript will also run. Note though that I never used Selenium as a substitute for JMeter and don't know about common features to both the tools.
I suppose you can use the WebDriver plugin to run real browser tests (IE/Firefox/Chrome/Selenium).
There is good documentation here
You can add WebDriver to JMeter test to fully evaluate the page rendering.
Web Driver Sampler automates the execution and collection of
Performance metrics on the Browser (client-side). A large part of
performance testing, up to this point, has been on the server side of
things. However, with the advancement of technology, HTML5, JS and CSS
improvements, more and more logic and behaviour have been pushed down
to the client. This adds to the overall perceived performance of
website/webapp, but this metric is not available in JMeter. Things
that add to the overall browser execution time may include:
Client-side Javascript execution - eg. AJAX, JS templates
CSS transforms - eg. 3D matrix transforms, animations
3rd party plugins - eg. Facebook like, Double click ads, site analytics, etc
All these things add to the overall browser execution time, and this
project aims to measure the time it takes to complete rendering all
this content.
Official guide: https://jmeter-plugins.org/wiki/WebDriverTutorial/
You need to add HTTP Cookie/Cache Manager to your thread in order to solve this.
There seems to be a lot of stress/load testing tool that support AJAX.
I am wondering how well does these tool implemented.
Do they only record http request and replay it?
Is it the right way to test AJAX app?
How does google test their ajax apps?
Most of the load testing tools out there do AJAX load testing the same way: they execute the raw HTTP traffic that is seen during a "recording" phase (which can be page requests, image requests, or even AJAX requests). The main difference among them is how good their recorder/IDE tool is and how easily it helps you parameterize the HTTP requests such that they reflect real world traffic based on dynamic/realtime results.
Warning, blatant plug: The only real exception to this is my company, BrowserMob. Instead of simulating the traffic observed, it actually uses real web browsers to drive back load. As such, the AJAX stuff is handled by the browser.
Useful link: Separate from the blatant plug above (though I do hope you check it out - we're up front with the pricing and provide a free trial), I recently wrote an article for Ajaxian about AJAX load testing. It goes in to more detail about the technical implications of using real browser users (RBUs) vs. virtual users (VUs).
Take a look at LoadBooster(https://www.loadbooster.com). It utilizes headless scriptable browser PhantomJS/CasperJs to test web sites. Phantomjs will parse and render every page, execute the client-side script. The headless browser approach is easier to write test scenarios to support complex AJAX heavy Web 2.0 app,browser navigation, mouse click and keystrokes into the browser or wait until an element exists in DOM. LoadBooster support selenium HTML script too.
Disclaimer: I work for LoadBooster.
If you are worried about functionality only, something like Watin, Watir, Selenium or any functional tool for that matter would work. As long as you put sufficient timing in your functional tests to allow for ajax callbacks then that should do the trick.
To add to my response,
If you are talking about unit testing your javascript you could use something like qunit as described by a fellow LosTechian in this posting. This is a pretty inventive use of an nunit addin and qunit for integrating js unit tests.
By pure coincidence, the same person that posted that qunit testing blog post just posted one yesterday about this very topic
Google apps are written in GWT, which comes with its own extension to JUnit. Article on unit testing ajax applications with GWT.
If you don't want to setup your own load testing server there are a couple of free online load testing services that can run load tests directly over the Internet. For example http://loadimpact.com or http://loadstorm.com
I've used Virtual User Generator, which is a part of the Loadrunner software from HP, to test AJAX applications. The software has several application protocols that can be used to record web applications, e.g. AJAX, and Click and Script.
For the majority of web application load testing it is sufficient to record and replay http requests. This will give the result of how the servers are handling the load. If your web application does a lot of asynchronous loading, and rendering on the client side, e.g. parsing large datasets of xml or json, or many DOM modifications, it can be relevant to include the browser tier to measure the end user experience.
All load testers would support AJAX- they're just additional http connections.
There are a few free ones out there- Jmeter, BadBoy, Grinder that all do it well.
All of them have some sort of support for recording/playback, but that's not always what you're looking for.
Easiest way I've done it is to record a sample session, replace a few params with variables and loop it off of a csv or excel file.
Great starting point: video of a google presentation on open source testing.
Edit: updated video link.
I've used SilkPerformer at a previous job. According to the link, they have some AJAX enhancements. Unfortunately, Silk is far from free.
Check out Jiffy. It's an end-to-end measurement suite, and is subsequently kind of complex. However, the statistics are quite impressive.
Siege? it can do HTTP testing and pass whatever you want.
You can also have a look at fwptt it is open source. If you are a .net developer you can make use of the parameter automatic handling and the possibility to use your own .net object for doing the tests.
I've successfully used JMeter to load test our Ajax (JSF/RichFaces) application. I didn't bother with JMeter's recording tool - rather I used the HttpFox plugin for Firefox to monitor what the browser is POST-ing to the server and I recreated this in JMeter.
It did get a bit complex, but the load test is now fairly robust. JMeter has all kinds of useful 'elements' to extract ID's from a web page, perform conditional logic, increment counters etc.
Better write isolated test method or API for load testing ajax application. There are some reasons:
It's not so easy to write functional tests to Ajax applications, for example for GWT.
You can use Jmeter WebDriver plugin, but for each run it starts browser which will use most of RAM and CPU.
You will load backend not frontend, so you can avoid ajax.
You can devide your testing like that: for Ajax application use Selenium or PhantomJS/CasperJS. For load testing use JMeter, Gatling via API not via Ajax.
My choice is firebug(browser addon). its very lightweight and easy to handle