blob: 0167ddf5dc03268aa934304b5021aec065247f0a [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright 2011 Software Freedom Conservancy. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<title>implicit_wait_test.html</title>
<script src="../test/test_bootstrap.js"></script>
<script>
goog.require('webdriver.Builder');
goog.require('webdriver.testing.jsunit');
function addFoo() {
var div = document.createElement('DIV');
div.id = 'foo_div';
div.innerHTML = 'FOO!';
setTimeout(function() {
document.body.appendChild(div);
}, 1000);
}
</script>
<input id="addFoo" type="button" value="Add foo!" onclick="addFoo();"/>
<script>
function testImplicitWaiting() {
var driver = new webdriver.Builder().build();
driver.manage().timeouts().implicitlyWait(0);
assertFooIsNotThereYet();
// For IE9, the click generated by the IE driver sometimes triggers
// a "No such interface supported" error. The error is not generated in
// any of our event loops, so we can't catch it - it goes straight to
// the global error handler causing the test to fail.
// This error only seems to happen with this test, and only on some IE9
// installs. Since we're not testing clicking in this test, avoid the
// error by clicking the element through JS.
driver.call(function() {
var button = document.getElementById('addFoo');
button.click();
});
assertFooIsNotThereYet();
driver.manage().timeouts().implicitlyWait(3000);
driver.isElementPresent({id: 'foo_div'}).addCallback(
goog.partial(assertTrue, 'foo_div should be present now'));
function assertFooIsNotThereYet() {
driver.isElementPresent({id: 'foo_div'}).addCallback(
goog.partial(assertFalse, 'foo_div is not present yet'));
}
}
</script>