1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | 'use strict';
|
19 |
|
20 | var fail = require('assert').fail;
|
21 |
|
22 | var Browser = require('..').Browser,
|
23 | By = require('..').By,
|
24 | error = require('..').error,
|
25 | until = require('..').until,
|
26 | assert = require('../testing/assert'),
|
27 | test = require('../lib/test'),
|
28 | Pages = test.Pages;
|
29 |
|
30 |
|
31 | test.suite(function(env) {
|
32 | var driver;
|
33 | test.before(function*() { driver = yield env.builder().build(); });
|
34 | test.after(function() { return driver.quit(); });
|
35 |
|
36 |
|
37 | test.ignore(env.browsers(Browser.SAFARI)).
|
38 | it(
|
39 | 'dynamically removing elements from the DOM trigger a ' +
|
40 | 'StaleElementReferenceError',
|
41 | function*() {
|
42 | yield driver.get(Pages.javascriptPage);
|
43 |
|
44 | var toBeDeleted = yield driver.findElement(By.id('deleted'));
|
45 | yield assert(toBeDeleted.getTagName()).isEqualTo('p');
|
46 |
|
47 | yield driver.findElement(By.id('delete')).click();
|
48 | yield driver.wait(until.stalenessOf(toBeDeleted), 5000);
|
49 | });
|
50 |
|
51 | test.it('an element found in a different frame is stale', function*() {
|
52 | yield driver.get(Pages.missedJsReferencePage);
|
53 |
|
54 | var frame = yield driver.findElement(By.css('iframe[name="inner"]'));
|
55 | yield driver.switchTo().frame(frame);
|
56 |
|
57 | var el = yield driver.findElement(By.id('oneline'));
|
58 | yield driver.switchTo().defaultContent();
|
59 | return el.getText().then(fail, function(e) {
|
60 | assert(e).instanceOf(error.StaleElementReferenceError);
|
61 | });
|
62 | });
|
63 | });
|