How do I build Watir tests for websites? - watir

There is a repository of tests for the Mozilla addons site, although it's written using Selenium. I'd like to know if there are any real-world examples available for Watir, so I can see how the framework is implemented by professionals?
This is a more general question about how one goes about building a suite of tests for a website in Watir. On a superficial level, one can write a bunch of seperate .rb files with crude error reporting and fire them all off; but I'd like to know more about writing actual classes and proper test structures that raise issues and return reports. How is this done? Are there any books on this? Tutorials?

Check out WatirMelonCucumber - a set of watir-webdriver tests against google and bing, and also EtsyWatirWebDriver - a set of watir-webdriver tests against Etsy.com

The watir Wiki has a selection of tutorials, examples etc as well.
Start Here
Learning More
Wiki homepage
Those are however fairly basic and don't get into the 'how to organize things' level.
In that case there are a number of frameworks in various states of development. The most active ones are I think are perhaps Taza, and QA Robusta. Each of them approaches things a little differently. QA Robusta is wrapped a bit around Minitest (if I understand things right) and provides it's own reporting. I'm still learning about Taza so can't really comment on it much. I also recall hearing about a 'WatirSpash' gem/framework that was discussed in a recent watir podcast which is designed to help watir use along with RSpec (and I might presume Cucumber)
If you are a BDD/Spec-by-example sort, then you may want to use either (or both) RSpec or Cucumber perhaps in combination with the WatirSpash gem as a way to organize and describe you tests, and then implement the actual test code via Watir, In that case you would likely be using the HTML based reports that can be generated by RSpec/Cucumber instead of rolling your own or depending on a watir framework for the reporting.

More Watir frameworks:
https://github.com/jarmo/WatirSplash
https://cyberconnect.biz/opensource/qa_robusta.html
Not in active development:
https://github.com/scudco/taza
https://github.com/bret/watircraft

QA Robusta most likely will not have too many new features added but will be supported. Instead you may want to check out whirlwind. Whirlwind uses similar concepts as other frameworks such as qa_robusta and taza, but is lighter weight and tailored around cucumber/rspec. See the walk through for a google search example.

Related

Is it viable to build a Web Dashboard in Clojure?

I am planning to build a web dashboard where I can analyze the financial records from a company through graphics, tables, ...
I already have the software, so the dashboard will only read the data, and not manipulate it.
It will be something like this, but simpler. Containing reports, graphics, options to select dates, intervals, etc.
But I am thinking, is it viable to use Clojure? And jQuery, CSS, HTML also.
Currently I work with the Luminus Web Framework for Clojure, but I am wondering if it is worth to do this in Clojure or if there are other languages that are better to do it.
Of course I am familiar with the language already, so it is a pro. But I am also open to suggestions.
It is not that hard at all! In fact, there exist great libraries which solve all the challenges involved in building a dashboard - scheduling, caching, transferring data to the client, visualization(and auto reloading).
We are working on a framework for building realtime Clojure dashboard. Have a look at https://github.com/multunus/dashboard-clj. We have used the following libraries:
Immutant's scheduler for scheduling
Core.async to simplify data flow on the backend
Sente for websocket communication
re-frame for client side state and view management
Stuart Sierra's component library for managing stateful components
In order to create beautiful visualizations you may take a look at d3 or highcharts. CLJSJS and Reagent cookbook will gives a good overview of how to use these js libraries(and many many more).
Clojure is an absolutely fantastic tool for building a web dashboard. The other answers here do a pretty good job of laying out the landscape as far as basic web technologies. On this side of things, I'll simply add I'm a big Reagent / Re-frame fan, and would go that route for React wrapper over Om.
As far as data visualizations, you may be interested in checking out Vega-Lite & Vega, which you can use from Clojure or ClojureScript (Reagent) by using a simple but flexible dataviz library I wrote called Oz:
https://github.com/metasoarous/oz
Vega-Lite & Vega are designed based on the ideas of the Grammar of Graphics, which inspired R's popular ggplot2 library. The core idea is that data visualizations should be built according to declarative descriptions of how properties of the data map to aesthetics of the visualization. Vega-Lite & Vega however take things one step further in providing a grammar of interaction, which allows for the construction of interactive data visualizations and sophisticated explorer views. Moreover, it ups the ante on the declarative nature of the GG in that Vega-Lite and Vega specifications are described as pure data (JSON), making it very in line with the data-driven philosophy of the Clojure world, and paving the way for seamless interoperability with other languages and sharing features.
Vega-Lite is more or less the higher lever, day-to-day data science tool, focusing on providing high leverage and automation based on very spartan specifications. It compiles to Vega, which is a somewhat lower level and more powerful, but less automated version of Vega-Lite. Usually starting out with Vega-Lite, and switching to Vega only as needed is sufficient.
For more on Vega & Vega-Lite see: https://vega.github.io.
I don't see any reasons why it wouldn't be viable to build a web dashboard in Clojurescript.
I suggest that you look into a library call reagent, which provides a minimalistic interface between react and clojurescript, so theoretically everything you can do with react should be possible in clojurescript/reagent (with the added benefit that it will be faster than React). You probably might be interested in reframe which is a framework for building single page applications.
React has been proven as a robust tool to build powerful UI.
You can do everything you can do in JavaScript using ClojureScript (just as you can do everything you do in Java using Clojure). So as others have commented, I would definitely recommend ClojureScript, especially since you know Clojure already. You may find out that you do not need jQuery etc.
The common choice to generate html is to use React.js via a wrapper library like:
reagent
Om
Both can generate HTML.
Reagent (and maybe re-frame) are the easiest ones to get started. Especially since there are components libraries like soda-ash, and a hiccup-like syntax.
Om (by the creator of ClojureScript), and maybe untangled are also a good choice, especially if you need to manage complex data. You can get a hiccup-like syntax via sablono.
Dashboards have been built using it (see the circleCI dashboard as a real-life dashboard example). This is the one I use personally.
Hoplon is also an interesting choice, as you mentioned.
Also have a look at cljsjs for pre-packaged js libraries.
As for the CSS, this is an orthogonal concern but yes of course you can use it (or even less and sass, there are Clojure wrappers for it). You can even generate CSS from Clojure code with garden,
You can find an example project using boot (by the same authors as hoplon), sass, reagent called saapas, but there are many more in the wild.
As you see there are many viable options in ClojureScript to build a dashboard. I am myself building one and settled on Om.next, partly because I was using React.js before.

Node.js programming workflow - Tests, Code, Tests

Before you start developing something useful in Node.js, what's your process? Do you create tests on VowJS, Expresso? Do you use Selenium tests? When?
I'm interested in gaining a nice workflow to develop all my node.js applications similar to Rails (Cucumber, Rspec, Code).
Sorry for the amount of questions.
Let me know how it works out with you.
The first thing I do is to write some documentation or do some wireframes. It helps to visualize what do I want to implement.
Then I code the interface/skeleton of my module/application, without implementations.
Then I add specs and tests using testosterone (although vows and expresso are more popular options) and I make them pass by implementing them.
If you find that a private method needs to be tested (it deals with I/O, has complex logic ...) move it to a another class and test it independently.
Stub your I/O calls as much as you can. Tests will run faster and you will not have to deal with side effects. I recommend gently.
My testing methodology isn't up the snuff as in for example Java/Junit and I should really work more on this(improve). I should really practice TDD more.
I played a little bit with expresso and liked to the fact that you could generate code coverage reports. What I thought was missing was something like #before #beforeclass #after which you can find in java.
I also played a bit with nodeunit which does have setup/teardown. I still like to play a little bit more with this framework.
I don't like the vowjs syntax, but it is very popular BDD framework, so maybe I should use it (more) to get sold like a lot of other users. But for now I am going to dismiss vowjs.
I also played with zombie.js a litle bit which is also pretty cool. I also lately saw another cool testing framework which I can't remember the name, but there are luckily enough options to do testing in node.js.
The only thing I don't like is that the integration with IDE is not up to snuff in my opinion. The IDE I had for Java cannot be compared with what I have found for node.js, but I think with a little bit effort I can make a more useful programming environment. I will try and keep you guys informed about this progress.
P.S: But what I do like a lot is the npm package manager. When you compare it to for example maven you just say wow. I still has some minor bugs because it is still a young project. But still npm is very good in my opinion!

Can I (relatively easily) test ZK interfaces in Watir?

How easily will Watir interact with a ZK interface? If "not at all" do you have any recommendations for automated testing of the web interface for me?
Edit: Another way to put this would be can I test a Spring/ZK generated page (Ajax/JScript). I found another issue too: I need not to use a proxy to test (like Sahi does) if at all possible.
Edit: I have been testing ZK interfaces now for quite some time. With a higher knowledge of Watir (and now webdriver) I can say it's definitely possible. Timing isn't usually an issue, but finding the elements certainly can be as the ids are dynamically generated. I recommend a strong, maintainable, object oriented approach with a powerful and dynamic DSL, or you'll be listing every element on the page in a custom built object library of some sort. So... it works, but it needs extra effort.
If you're talking about this: http://zssdemo.zkoss.org/ you can take a look at the DOM output, it's atrocious, but possible to test it with Watir. I've dealt with some apps that generate awful output like that. It makes for a challenge. :) Search the Watir google group for testing Ajax, plenty of people do it.
HTH,
Charley

Why I dont see YUI used that much often

I have been using jQuery/Prototype/ExtJs and other frameworks for last two years. These frameworks have been very useful.
I switched to YUI recently and finding the learning curve a bit too steep. Also the framework is not making my life as easy as with Extjs or Jquery.
When I consulted several other developers no one seems to be very enthusiastic about YUI. Very few of them have actually used it. Of course this depends on where I stay and what kind of people I interact with but can I say safely that YUI is not beign received as enthusiastically as jQuery? Why is it so ?
NB: I'm an engineer on the YUI team! I think you ask a great question, something I have wondered myself.
IMO, jQuery is more widespread than YUI because it is easy to sprinkle it on web pages that need simple DOM manipulations and basic AJAX or animations. That said, YUI is an extremely popular library that has historically been a favorite of more advanced developers and application builders. We do have a huge and thriving online community on yuilibrary.com -- perhaps folks are too busy writing great code to make a lot of noise? ;-)
That said, we are hearing a lot of buzz these days from jQuery folks hitting the limits of that library as they transition from throwing together simple effects to needing more maintainable, performant, and well-architected code. YUI 3 takes you from the basics to the most complex applications without missing a beat. It is a world-class platform for novices, hackers, and application developers alike: a concise, convenient, and intuitive API that is lightweight and lightning fast, PLUS a well-thought-out infrastructure and comprehensive suite of tools to help you code like a professional.
I agree that the learning curve for YUI has been high -- we are in the midst of a website redesign and writing an O'Reilly cookbook to address exactly that issue. We're also hosting our second annual YUIConf this November to unveil our latest and greatest. We've coming a long way since the days of YUI 2 and we're excited to make it as easy as possible for folks like you to ramp up on YUI 3.
Akshar -- my response is YUI-centric, for sure, but the YUI developer community is huge, enthusiastic, and growing. Check out http://yuiblog.com/blog/category/in-the-wild for some of the implementations we've seen recently. In addition to what's out there in open source, the Yahoo! home page, Yahoo! Search, Flickr, and the upcoming redesign of Yahoo! Mail are all based on YUI 3, the next generation of the library -- which has been welcomed by developers as having industrial strength power along with the concision and selector-driven syntax that makes libraries like Prototype and jQuery so fun to use. My advice: Try it out. YUI 3 is a unique, incredibly powerful library, and its 200 community contributed gallery modules (a number that grows by the week) make it one of the most comprehensive libraries out there.
As a user of both jQuery and YUI, I have to admit that I look at them in almost completely different lights. I use jQuery for custom effects, animation, interactivity on our externally-facing website. The visual extensibility of jQuery means that we can customize the look and feel of these elements to match the rest of our website. I've used YUI as a quick and easy way to develop a snazzy front interface for some of our internal applications. These internal applications are simple Apache/MySQL/PHP apps, and YUI allows for simplified data visualization, form handling, tabs, etc. without having to worry about the look and feel as much. The standardized, slightly bland interface elements are a perfect, no-nonsense approach to quickly developing and rolling out these apps.
I found the learning curve to be a bit steep myself, but the examples help out a lot.
I've been using ExtJS and JQuery for some time, but now i'm experimenting with YUI 3. I like the general idea behind YUI (modules, async loader, plugins) but some things annoy me:
lots of documentation, but some things aren't documented at all or very scarcely
some features are very basic (data grids) compared to their ExtJS counterparts.
you never know which features are there in the core, in gallery or aren't implemented at all. You need to do the research yourself.
the framework feels less coherent than ExtJS
I'm trying to find a replacement for ExtJS for building business applications, but didn't find any framework that would be as rich and complete as ExtJS. I don't like how ExtJS looks and how it forces some strange implementation/architecture decisions on you (MVC!), but have to admit it's really hard to replace.

Good image gallery engines

What are the best open source image gallery engines? Both stand-alone, and for existing frameworks such as Wordpress or Drupal.
Hopefully we can build a good list here over time.
Gallery is the classic choice. It has skins, security layers, heaps of plugins, etc, but can be run with the default settings easily if you want to. I've used it for years.
GOOD QUESTION, lots of people ask this in many web forums so hopefully we will get some good responses to this, and have a good list of solutions.
Personally I always used to say something like Gallery or some other OS script, but recently I have found myself using more and more something like a simple php script which just spits our a list of images (maybe 7 a page) but relying on a Javascript library such as mootools or Ext to provide all the functionality, particularly for small or individual galleries. Im particularly loving the noobslide mootools class at the moment which has some lovely gallery effects.
Noobslide
I suppose at the end of the day its all down to what you need, there will be no one answer that fits all but a number of different solutions will hopefully show up here that will suit different peoples needs.

Resources