small medium large xlarge

05 Jun 2016, 13:05
Alexandru-Gabriel Dragoi (2 posts)

I was making the setup for running the tests against the user interface( Part 2, Chapter 8).

There is a race condition there, because checking the cash slot contents and the account balance on one side, and updating these two resources by the web client on the other side, are running in parallel.

Unlike the code in the book, I use a selenium ChromeDriver and the winner in this race condition is the test step that checks the cash slot contents. Because the contents are checked before they are updated, the scenario fails.

Using the code in the book (with a selenium FirefoxDriver) the winner is the code that updates the two resources (cash slot contents and the account balance) as a result of client http request. If I run it multiple times, the result is the same: scenario passes every time, although I shall not hold my breath.

05 Jun 2016, 19:15
Alexandru-Gabriel Dragoi (2 posts)

Fixed by waiting for the next page in CashSlotSteps:

    @Then("^\\$(\\d+) should be dispensed$")
    public void $ShouldBeDispensed(int dollars) throws InterruptedException {
        WebDriverWait wait = new WebDriverWait(helper.getWebDriver(), 1);

        assertEquals("Incorrect amount dispensed -",
                dollars, helper.getCashSlot().contents());

The withdrawBody element is from the html page that is sent back to the client in WithdrawalServlet, as a response to withdrawing some money.

You must be logged in to comment