| <!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>screenshot_test.html</title> | |
| <script src="../test/test_bootstrap.js"></script> | |
| <script> | |
| goog.require('webdriver.Builder'); | |
| goog.require('webdriver.testing.asserts'); | |
| goog.require('webdriver.testing.jsunit'); | |
| </script> | |
| <iframe src="ajaxy_page.html" width="100%" height="300px"></iframe> | |
| <script> | |
| function testTakingScreenshots() { | |
| var driver = new webdriver.Builder().build(); | |
| driver.switchTo().frame(0); | |
| var typer = driver.findElement(By.name('typer')); | |
| typer.sendKeys('bob'); | |
| assertThat(typer.getAttribute('value'), equals('bob')); | |
| driver.findElement(By.id('red')).click(); | |
| var screenshot1 = G_testRunner.takeScreenshot(driver, 'before-update'); | |
| driver.findElement(By.name('submit')).click(); | |
| driver.manage().timeouts().setScriptTimeout(15 * 1000); | |
| driver.executeAsyncScript( | |
| 'window.registerListener(arguments[arguments.length - 1]);'), | |
| G_testRunner.takeScreenshot(driver, 'post-update'). | |
| then(function(screenshot2) { | |
| screenshot1.then(function(screenshot1) { | |
| assertNotEquals('The two screenshots should differ!', | |
| screenshot1, screenshot2); | |
| }); | |
| }); | |
| } | |
| </script> |