3 ms·
This type of solution is faster than Selenium, at least when talking about PhantomJS, as well as it's headless so it does not require running graphical environm
by methyl 12y ago
This type of solution is faster than Selenium, at least when talking about PhantomJS, as well as it's headless so it does not require running graphical environment.
Bullet #2 is basically the same as #1, and advantage over #3 is that Mechanize won't run Javascript, so it's useless eg. for testing Single Page Applications.
- StevePerkins 12y agoHmm... can you elaborate further on that last point? I totally understand the value of headless browser testing, when you're not checking for browser-specific issues. However, I'm less clear on how a headless test runner's implementation language should ever matter one way or the other. If you're testing the behavior of a web application as it receives HTTP requests, then shouldn't the application be agnostic about which clients are sending those requests? If your test runner is reaching around the HTTP protocol and directly manipulating JavaScript on the rendered page, then doesn't that affect the reliability of the test suite... since it no longer represents true HTTP client interaction?
- orkj 12y agoI think what he was saying was: If I have a webpage that only does one thing, it executes alert('Hello world'); Then the headless solution would have to be able to check that the alert fired. If your testing framework does not execute the JavaScript on the page (i.e just fetching the resources) then you are back to square one. I have no idea if Mechanize executes page JavaScript, but SlimerJS (and PhantomJS) does. Which is the difference here. * execute alert will probably for most use cases be bootstrapping some MVC and setting properties, doing navigation and so on.
- StevePerkins 12y agoWhatever JavaScript a web page runs, shouldn't it be driven by some kind of event though? Rather it be the "onLoad" event itself, or the user clicking/hovering/changing something, etc. In a real use case setting, you wouldn't have users load a web page and then somehow arbitrarily execute JavaScript code directly, without any particular event firing. So why wouldn't you test through the relevant events?
- delluminatus 12y agoI don't know what your question means, especially the "reaching around the HTTP protocol" part, but I'm going to try to answer it anyway. Mechanize doesn't contain a JS engine, so it can't scrape sites that rely on JS execution. You can't use it, for example, to scrape (or run tests on) content that was loaded via AJAX. The other scrapers in question do include a JS engine, so you can use them to scrape or test pages that load content dynamically. Because more and more Web sites are implemented as client-side single-page applications (SPAs), the ability to scrape dynamic content is becoming more important.