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

Thucydides version 0.9.235 Released

$
0
0

A new version of Thucydides is out (version 0.9.235), with bug fixes and new features!

Bug fixes

The bug fixes include:

  • THUCYDIDES-226 and THUCYDIDES-224: You can now pass arbitrarily complex chrome switches in the ‘chrome.switches’ property, containing spaces, commas etc, e.g.
    –user-agent=Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B)AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 MobileSafari/535.19
  • THUCYDIDES-215 – Provided drivers can take screenshots
  • THUCYDIDES-225 – The webdriver.timeouts.implicitlywait system property now works to configure the timeout value of a PageObject.
  • THUCYDIDES-223 – You can now pass absolute path values in the thucydides.driver.capabilities system property.
  • Session data and step libraries are cleared between unit tests: A bug in previous versions of Thucydides meant that session data (accessed via the Thucydides.getCurrentSession() method) and step libraries were preserved between session states. This could occasionally cause problems, so session data is now cleared between each test in both JUnit and JBehave. This can be deactivated by setting the ‘thucydides.maintain.session’ property to true. Step libraries are now always reinitialized between scenarios or tests.

    THUCYDIDES-215 deserves some more detail. You can add your own custom WebDriver provider by implementing the DriverSource interface. First, you need to set up the following system properties (e.g. in your ‘thucydides.properties’ file):

    webdriver.driver = provided
    webdriver.provided.type = mydriver
    webdriver.provided.mydriver = com.acme.MyPhantomJSDriver
    thucydides.driver.capabilities = mydriver

    Previously, it was hard to configure Thucydides to take screenshots using provided drivers. Now, you implement the DriverSource interface (as before), but with the new takesScreenshots() method:

    public class MyPhantomJSDriver implements DriverSource {
    
        @Override
        public WebDriver newDriver() {
            try {
                DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
    
                // doesn't work :(
                capabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
    
                return new PhantomJSDriver(ResolvingPhantomJSDriverService.createDefaultService(),
                        capabilities);
            }
            catch (IOException e) {
                throw new Error(e);
            }
        }     
    
    	@Override
        public boolean takesScreenshots() {
            return true;
        }
    }

    This driver will now take screenshots normally.

    New Features

    And two cool new features:

    Custom messages for WebElementFacade assertions

    Normally, to check the state of a WebElementFacade, you do something like this:

    @FindBy(css=".whatever")
    WebElementFacade myfield;
    ...
    myField.shouldBeVisible();

    But in this case, the error message was always the same. Now you can also do this:

    myField.expect("My field should be visible").shouldBeVisible();

    This will work for any of the "should"-style methods (shouldBeVisible, shouldContainText, etc.).

    Clever reuse of screenshots

    In previous versions, Thucydides recorded a different set of screenshots for each test run. This could lead to a lot of screenshots and the need for very large disks. Now, if screenshots are identical (i.e. if they have the same MD5 digest), the same file will be used.



Viewing all articles
Browse latest Browse all 31

Trending Articles