Quantcast
Channel: Official Serenity BDD Automated Acceptance Testing Blog » Tips and Tricks
Viewing all articles
Browse latest Browse all 31

Thucydides Release 0.9.103 – Improved reporting, other enhancements and bug fixes

$
0
0

Thucydides Release 0.9.103 adds some useful new features and enhancements.

Reports distinguish between errors and failures

Test reports now distinguish between test errors and failures. The following screenshot will make this clear.

Reports distinguish between Test Errors and Failures

Reports distinguish between Test Errors and Failures

Detailed report will not show screenshots column if there are no screenshots in the test

Tests that do not have any screenshots will no longer show an empty screenshots column in the details page.

no-screenshots-column

Injecting WebElementFacades in Page objects

Instead of declaring WebElement variables in Page Objects and then calling element() or $() to wrap them in WebElementFacades, you can now declare WebElementFacade variables directly inside the Page Objects. This will make the Page Object code simpler more readable.

So, instead of writing


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

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

    private WebElement go;    //variable name matches element id or name

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

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

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

    public List getDefinitions() {
        WebElement definitionList = getDriver().findElement(By.tagName("ol"));
        List<WebElement> 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();
            }
        };
    }
}

you can write

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

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

    private WebElementFacade go;       //variable name matches element id or name

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

    public void enter_keywords(String keyword) {
        searchTerms.type(keyword);  //directly use facade
    }

    public void lookup_terms() {
        go.click();                //directly use facade
    }

    public List getDefinitions() {
        WebElement definitionList = getDriver().findElement(By.tagName("ol"));
        List<WebElement> 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();
            }
        };
    }
}

Switching to another page object

A new method, switchToPage() has been added to PageObject class to make it convenient to return a new PageObject after navigation from within a method of a PageObject class. For example,

@DefaultUrl("http://mail.acme.com/login.html")
public class EmailLoginPage extends PageObject {

    ...
    public void forgotPassword() {
        ...
        forgotPassword.click();
        ForgotPasswordPage forgotPasswordPage = this.switchToPage(ForgotPasswordPage.class);
        forgotPasswordPage.open();
        ...
    }
    ...
}

Other minor enhancements and bug fixes

  • Selenium version updated to 2.31.0.
  • Added containsOnlyText and shouldContainOnlyText methods to WebElementFacade. These methods are similar to containsText/shouldContainText methods but check for exact match.
  • Modified shouldContainText method in WebElementFacade so that error message shows both the expected text, and the text found in the element.
  • Fixed a bug in the error message of the method WebElementFacade.shouldNotContainText.
  • Now you can both activate and deactivate native events for Firefox by setting the thucydides.native.events property to true or false.
  • Thucydides-141: Fixed a bug due to which when trying to open a page with slash in the end of url, browser tried to open page without slash.


Viewing all articles
Browse latest Browse all 31

Trending Articles