Created
December 6, 2011 19:56
-
-
Save seeflanigan/1439685 to your computer and use it in GitHub Desktop.
Element no longer connected to DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Found by Dima Kovalenko | |
| Selenium specs which call "wait for element to be visible" fail on an "Element no longer connected to DOM" error. | |
| The problem occurs when the div appears briefly, then goes away. If the loop exits after the div is already off the screen, the call to "wait for element to be visible times out, and causes the spec to fail. | |
| This issue can be elusive, only failing intermittently because sometimes the loop exits quickly enough to avoid producing the error. The fact that the div is displayed then hidden was the key to identifying and solving this bug in our test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- a/features/support/env.rb | |
| +++ b/features/support/env.rb | |
| @@ -345,12 +345,15 @@ module Ajax | |
| def wait_until_updated_element_is_visible(css_selector) | |
| page.should have_css(css_selector) | |
| - page.wait_until do | |
| + page.wait_until 20 do | |
| + visible = nil | |
| if all(css_selector).empty? | |
| - false | |
| + visible = false | |
| else | |
| - all(css_selector).first.visible? | |
| + visible = all(css_selector).first.visible? | |
| end | |
| + puts "waiting.." | |
| + visible | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
slightly less ugly diff
diff --git a/features/support/env.rb b/features/support/env.rb
index 54f753f..809b8d1 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -346,10 +346,11 @@ module Ajax
def wait_until_updated_element_is_visible(css_selector)
page.should have_css(css_selector)
page.wait_until do
end
end