Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Watir-Webdriver and Capybara have performance issues when compared to Webdriver?

I am about to change my test automation language from Java to Ruby (I have new job where Ruby fits better into the tech stack).

I have a lot of experience with Java and Webdriver but can see that wrappers such as Watir and Capybara appear to be used more in Ruby than directly accessing the Webdriver API.

My concern about using a such a library is performance. I normally try integrate 3rd party grids such as Saucelabs into my test frameworks but have learnt that caching of selenium web element objects is important as continually finding elements can have a performance impact.

If I use libraries such as Capybara, do I lose the ability to control caching strategies? I have previously investigated Geb and found that the framework continually re-created webelements rather than caching, and it appeared inflexible in changing that behaviour.

Is my concern that these libraries help you to avoid writing boiler plate code but at the cost of performance valid?

like image 941
Robbie Wareham Avatar asked Aug 24 '13 17:08

Robbie Wareham


1 Answers

TL;DR

Convention over configuration; use page-object for caching.


Here are my thoughts on this matter. And please consider this less of an answer, and more of a response for discussion. I want feedback on this answer, feel free to give it.

One of the primary patterns in Ruby (and it actually comes from Rails), is Convention over Configuration. The basic idea is that when there is a convention, either dictated by the language or the community, you roll with it whenever possible. In your case, I would recommend using the community frameworks if at all possible. This will make it easier for other developers to use your code and easier to seek help if you need it.

As far as the actual caching goes, with this I am less familiar. I do know the page-object gem stores elements instead of recreating them during every usage*. This would appear to conform with your requirements of caching elements. In any case, I highly recommend this gem as it enforces the page-object model of testing.

Note: I am not sure if the page-factory mixin supports this caching of objects, or if it recreates the class on every usage.

*You can see how the Element is stored in page-object by viewing the source code to the Element class.

def initialize(element, platform)
  @element = element
like image 110
Dan Grahn Avatar answered Sep 21 '22 23:09

Dan Grahn