Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spock + GEB vs. Robot Framework [closed]

Previously I used Robot Framework to automate testing of applications, but a new client asked pay attention to Spock + GEB. I've never used it, but I need to quickly compare two of these tools and make a choice. Please help me to understand how they differ and what are the strengths / weaknesses of each.

like image 815
Evgeniy Avatar asked May 10 '13 09:05

Evgeniy


People also ask

What is Geb and Spock?

Geb is a browser automation solution. It can be used for scripting, scraping and general automation — or equally as a functional/web/acceptance testing solution via integration with testing frameworks such as Spock or JUnit. Spock. Spock is a testing and specification framework for Java and Groovy applications.

Is GEB a framework?

Geb is a Web automation framework using Groovy. Geb uses WebDriver to test web applications using either real browsers or the HtmlUnit library.

What is Geb in automation?

What is it? Geb is a browser automation solution. It brings together the power of WebDriver, the elegance of jQuery content selection, the robustness of Page Object modelling and the expressiveness of the Groovy language.


1 Answers

I tell you about Geb, i use gebish for testing web-applications more 6 months. That's all his benefits:

  • Cross Browser Automation
  • jQuery-like API
  • Page Objects
  • Asynchronicity
  • Testing
  • Build System Integration

Now more details about each of them.

  • Cross Browser Automation

Geb leverages the WebDriver library for browser automation. This means that Geb works with any browser that WebDriver works with, and the list of browsers that WebDriver works with is growing all the time.

The core supported browsers are:

  • FireFox
  • Internet Explorer
  • Google Chrome
  • Opera

There is also experimental support for:

  • Chrome on Android
  • Safari on iPhone & iPad

WebDriver also supports remote drivers. This allows you to automate a browser running on another machine! This means you can easily run your test suite against an IE browser from the comfort of your Mac or Linux machine (and vice versa).

  • jQuery-like API

Geb takes inspiration from jQuery to provide a concise and effective way to get at content. This is called the Navigator API.

The dollar function can be used anywhere to select content based on CSS selectors, attribute matchers and/or indexes.

// CSS 3 selectors
$("div.some-class p:first[title='something']")

// Find via index and/or attribute matching
$("h1", 2, class: "heading")
$("p", name: "description")
$("ul.things li", 2)

// 'text' is special attribute for the element text content
$("h1", text: "All about Geb")

// Use builtin matchers and regular expressions
$("p", text: contains("Geb"))
$("input", value: ~/\d{3,}-\d{3,}-\d{3,}/)

// Chaining
$("div").find(".b")
$("div").filter(".c").parents()
$("p.c").siblings()
  • Page Objects

Geb has first class support for the Page Object pattern, leveraging Groovy's DSL capabilities to allow you the developer to easily define the interesting parts of your pages in a concise, maintanable and extensible manner.

import geb.Page

class LoginPage extends Page {
    static url = "http://myapp.com/login"
    static at = { heading.text() == "Please Login" }
    static content = {
        heading { $("h1") }
        loginForm { $("form.login") }
        loginButton(to: AdminPage) { loginForm.login() }
    }
}

class AdminPage extends Page {
    static at = { heading.text() == "Admin Section" }
    static content = {
        heading { $("h1") }
    }
}
  • Asynchronicity

Modern web pages are full of asynchronous operations like AJAX requests and animations. Geb provides built in support for this fact of life.

Any content lookup, or operation can be wrapped in a waitFor clause.

waitFor { 
    $("p.status").text() == "Asynchronous operation complete!"
}

This will keep testing the condition for a certain amount of time (which is configurable) until it passes. The same technique can be used to just wait for the content, not necessarily for the content to have some characteristic.

def dynamicParagraph = waitFor { $("p.dynamically-added") }
dynamicParagraph.text() == "Added dynamically!"

You can also define that content should be implicitly waited for in the Content DSL for page objects

import geb.Page

class DynamicPage extends Page {
    static content = {
        dynamicParagraph(wait: true) { $("p.dynamically-added") }
    }
}

With this definition, when dynamicParagraph is requested Geb will implictly wait for a certain amount of time for it to appear.

  • Testing

Geb provides integration modules for popular testing frameworks such as Spock, JUnit, TestNG, EasyB and Cucumber (via Cuke4Duke)

While Geb works great with all of these frameworks, it really shines with Spock. Spock is an innovative testing framework that is a great match for using with Geb. Using Spock + Geb gives you very clear, concise and easy to understand test specifications with very little effort.

import geb.Page
import geb.spock.GebSpec

class LoginSpec extends GebSpec {
    def "login to admin section"() {
        given:
        to LoginPage

        when:
        loginForm.with {
            username = "admin"
            password = "password"
        }

        and:
        loginButton.click()

        then:
        at AdminPage
    }
}
  • Build System Integration

Geb is easy to integrate into any build system, and information and examples on integrating with the following build/project systems is available:

  • Gradle
  • Grails
  • Maven

You can look my Example (Spock+GEB) here: github

Read more about geb here: Official Site

Thanks!!!

like image 184
plsgogame Avatar answered Sep 18 '22 12:09

plsgogame