Skip to content

Archive for

29
Nov

Thucydides Release 0.9.77 – Finer control on screenshots management


We have released another version of Thucydides today. Release 0.9.77 contains the following features and bug fixes:

Finer screenshots control (Thucydides-105)

Whenever a step is executed, Thucydides saves a screenshot which is displayed in the report. In order to manage disk space better, some users require finer control on when and how many screenshots are generated and stored. Thucydides provided some support for this in the past by allowing users to set the properties thucydides.only.save.failing.screenshots for saving screenshots for only failed steps and thucydides.verbose.screenshots for saving screenshots at every web element action (like click(), typeAndEnter(), type(), typeAndTab() etc.).

In the latest release, these properties are deprecated and replaced with a new property thucydides.take.screenshots which can have the following values:

  • FOR_EACH_ACTION : Similar to thucydides.verbose.screenshots
  • BEFORE_AND_AFTER_EACH_STEP,
  • AFTER_EACH_STEP, and
  • FOR_FAILURES : Similar to thucydides.only.save.failing.screenshots

An even more granular level of control is now possible using annotations. You can annotate any test or step method (or any method used by a step or test) with the @Screenshots annotation to override the number of screenshots taken within this step (or sub-step). Some sample uses are shown here:

@Step
@Screenshots(onlyOnFailures=true)
public void screenshots_will_only_be_taken_for_failures_from_here_on() {…}

@Test
@Screenshots(forEachStep=true)
public void should_take_screenshots_for_each_step_in_this_test() {…}

@Test
@Screenshots(forEachAction=true)
public void should_take_screenshots_for_each_action_in_this_test() {…}

Other minor Bug fixes

  • Thucydides-89 : Fixed problem with tests failing randomly on Windows while building Thucydides.
  • Thucydides-96 : Fixed a bug that caused tests annotated with @WithDriver(“firefox”) to open in Internet Explorer browser.
  • Thucydides-108: Fixed a bug that caused Stories and Feature links on All Available tags section of Dashboard (report) to not work due to broken links.
25
Nov

Thucydides Release 0.9.75 – Bug fixes, improvements and more…


Release 0.9.75 is now available to download and includes the following improvements:

Support for Safari webdriver

Safari webdriver is now supported: just set the webdriver.driver property to “safari”. Make sure you follow the instructions here to install the Selenium SafariDriver extension first.

Support for FluentLenium (experimental)

This release also brings the awesomeness of FluentLenium‘s fluent API to Thucydides. The best way to use FluentLenium within Thucydides is to use ThucydidesFluentAdapter which is available in PageObject. Here’s an example of the same PageObject written in the traditional style and with FluentLenium.

Traditional style:

import ch.lambdaj.function.convert.Converter;
import net.thucydides.core.annotations.DefaultUrl;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import net.thucydides.core.pages.PageObject;

import java.util.List;

import static ch.lambdaj.Lambda.convert;

@DefaultUrl("http://en.wiktionary.org/wiki/Wiktionary:Main_Page")
public class DictionaryPage extends PageObject {

    @FindBy(name="search")
    private WebElement searchTerms;

    @FindBy(name="go")
    private WebElement lookupButton;

    public DictionaryPage(WebDriver driver) {
        super(driver);
    }

    public void enter_keywords(String keyword) {
        element(searchTerms).type(keyword);
    }

    public void lookup_terms() {
        element(lookupButton).click();
    }

    public List getDefinitions() {
        WebElement definitionList = getDriver().findElement(By.tagName("ol"));
        List results = definitionList.findElements(By.tagName("li"));
        return convert(results, toStrings());
    }

    private Converter<WebElement, String> toStrings() {
        return new Converter<WebElement, String>() {
            public String convert(WebElement from) {
                return from.getText();
            }
        };
    }
}

and with FluentLenium…

import ch.lambdaj.function.convert.Converter;
import net.thucydides.core.annotations.DefaultUrl;
import net.thucydides.core.pages.PageObject;
import org.fluentlenium.core.domain.FluentList;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import java.util.List;

import static ch.lambdaj.Lambda.convert;
import static org.fluentlenium.core.filter.FilterConstructor.withName;

@DefaultUrl("http://en.wiktionary.org/wiki/Wiktionary:Main_Page")
public class FluentDictionaryPage extends PageObject {

    public FluentDictionaryPage(WebDriver driver) {
        super(driver);
    }

    public void enter_keywords(String keyword) {
        fluent().fill("input", withName("search")).with(keyword);
    }

    public void lookup_terms() {
        fluent().click("input", withName("go"));
    }

    public List getDefinitions() {
        FluentList results = fluent().findFirst("ol").find("li");
        return results.getTexts();
    }
}

A special shout-out to MathildeLemee for helping with the integration.

Shortcut for the element() method

Another new experimental feature introduces the ability to replace the commonly-used element() method with ‘$’, as illustrated in the following examples:

    ...
    @FindBy(name="search")
    private WebElement searchTerms;

    @FindBy(name="go")
    private WebElement lookupButton;

    public DictionaryPage(WebDriver driver) {
        super(driver);
    }

    public void enter_keywords(String keyword) {
        $(searchTerms).type(keyword);
    }

    public void lookup_terms() {
        $(lookupButton).click();
    }

    public void click_on_article(int articleNumber) {
        $("//section[@id='searchResults']/article[" + articleNumber + "]//a").click();
    }

    public String getHeading() {
        return $("section>h1").getText()
    }
}

Bug fixes

  • #Thucydides-93: PageObject.containsText() now returns true only if the text is visible on the page. Earlier this method returned true even if the text was not visible (for example, if CSS property display:none was set)
  • #Thucydides-99: The screenshots names now use SHA instead of MD5 for hashing to prevent name collision in some situations.
  • #Thucydides-106: Fixed SLF4J binding issue.

As usual, we encourage you to get in touch via this blog, our mailing lists or Jira tracker for any queries or comments.