waitForSelected

Wait for an option or radio/checkbox element (selected by css selector) for the provided amount of milliseconds to be (un)selected or (un)checked. If multiple elements get queryied by given selector, it returns true (or false if reverse flag is set) if at least one element is (un)selected.

Usage

1
browser.waitForSelected(selector[,ms][,reverse]);

Parameters

Param Type Details
selector String element to wait for
ms
optional
Number time in ms (default: 500)
reverse
optional
Boolean if true it waits for the opposite (default: false)

Example

index.html
1
2
3
4
5
6
7
8
9
10
<select>
<option value="1" id="option1">1</option>
<option value="2" id="option2" selected="selected">2</option>
<option value="3" id="option3">3</option>
</select>
<script type="text/javascript">
setTimeout(function () {
document.getElementById('option1').selected = true;
}, 2000);
</script>
waitForSelectedExample.js
1
2
3
4
5
6
7
it('should detect when an option is selected', function () {
browser.waitForSelected('#option1', 3000);

// same as
elem = $('#option1');
elem.waitForSelected(3000)
});

Uses