Skip to content

March 9, 2013

3

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

by rahulj51

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.
About these ads
3 Comments Post a comment
  1. Mar 13 2013

    Is it just me or thucydides has selenium 2.29 as a dependency instead of selenium 2.31?

    Reply
  2. Mar 13 2013

    Sorry, my bad. I’m trying to use it with “arquillian-drone-bom” which was overriding the selenium version.

    Reply
  3. Natali
    Mar 18 2013

    Hello!

    Thank You for your great work!

    I have one question about Thucydides reports.

    During the test, I output some important information into log file or in Console for better control of the test run

    For example: In one test I need assert, that String length is no longer, that 300 symbols

    In log file I print (with system.out.println): “String length is 300 symbols”. But I need output this information also in my Thucydides reports.

    Or, I output in the log file, that table contains 30 rows (with each step this number increase). In report I have screenshot for this table, but I also need information about it length .

    And etc.

    I looking for any method for output log information into report, but I couldn’t find it. Can You help me with this problem

    Thank You in advance

    Natali

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

Follow

Get every new post delivered to your Inbox.

Join 2,767 other followers

%d bloggers like this: