tags:

views:

111

answers:

1

I have a div that contains a slideshow. ( http://film.robinhoodtax.org/issues/education )

I am using Selenium to test it. So far I have been using the HTML/Selenium script below to validate that the slideshow is actually working. But my assertEval is failing.

How can I correctly detect the slideshow and make sure it is moving?.

You can see I've approached this by storing the HTML and waiting then trying again but it isn't working.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case"&gt;
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/issues/education</td>
    <td></td>
</tr>
<tr>
    <td>waitForPageToLoad</td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td>assertElementPresent</td>
    <td>css=div[id='views-nivo-slider-ImagesGallery-block_1']</td>
    <td></td>
</tr>
<tr>
    <td>storeHtmlSource</td>
    <td>css=div[id='views-nivo-slider-ImagesGallery-block_1']</td>
    <td>first</td>
</tr>
<tr>
    <td>pause</td>
    <td>3000</td>
    <td></td>
</tr>
<tr>
    <td>storeHtmlSource</td>
    <td>css=div[id='views-nivo-slider-ImagesGallery-block_1']</td>
    <td>second</td>
</tr>
<tr>
    <td>assertEval</td>
    <td>${first} == ${second}</td>
    <td>second</td>
</tr>

</tbody></table>
</body>
</html>
+2  A: 

Looking at the site under test, you could check the active page of the slideshow using the following:

verifyText | css=a.nivo-control.active | 0
waitForText | css=a.nivo-control.active | 1
waitForText | css=a.nivo-control.active | 2
waitForText | css=a.nivo-control.active | 3
waitForText | css=a.nivo-control.active | 4
waitForText | css=a.nivo-control.active | 5
waitForText | css=a.nivo-control.active | 6
waitForText | css=a.nivo-control.active | 7
waitForText | css=a.nivo-control.active | 0

This will wait until the active 'page' changes through each available slide, and then check that it loops back to the first slide. This is better than an a pause, as this way you only wait as long as it take for the slide to change.

Dave Hunt
This fixes my problem fantastically. Thank you!
Stewart Robinson
You're welcome. I had a quick look into checking that the image changes, you can get the current background image using `storeEval | this.findEffectiveStyleProperty(this.browserbot.findElement("id=views-nivo-slider-ImagesGallery-block_1"), "backgroundImage") | backgroundImage` but in order to check it you'll need to wait until the transitions complete.
Dave Hunt
For transitions, you could wait for the opacity of any `css=.nivo-slice` is less than 1, then wait for the opacity to be equal to 1. That would indicate a transition has started and ended.
Dave Hunt