Comments (5)
ok, I discovered that adding:
page.find(*selector_for(locator)).should_not be_nil
doesn't prevent the problem (reliably) but a sleep(1) inside the with_scope block does. So this is some kind of timing issue.
from capybara-webkit.
I think this is a "problem" with selenium-webdriver too. Basically, using within
causes the driver to try to find the scope's element immediately whereas page.find uses a timeout mechanism to wait for the element to appear. This causes confusion when you have something like
visit("/foo")
within("#foo") do
page.find(".bar").click
# or
page.should have_css(".bar")
end
If the page is still loading by the time the within
runs and #foo
has not rendered yet, you'll get trouble. If you do this on the other hand, it should work:
visit("/foo")
page.should have_css("#foo .bar")
because have_css will use a timeout to wait for the selector to be found.
So, though within
can be helpful with DRYness, sometimes it's better to do something like:
visit("/foo")
root_selector = "#foo"
page.find("#{root_selector} .bar").click
page.find("#{root_selector} .baz").click
# ... and so on.
or
visit("/foo")
# wait for #foo...
page.should have_css("#foo")
within("#foo") do
page.find(".bar").click
# or
page.should have_css(".bar")
end
from capybara-webkit.
I've checked the within. Currently this is working as expected so I'm going to close this out. If you have any additional issues feel free to reopen.
from capybara-webkit.
For reference: I had a similar problem with a within block in a page that had some javascript dynamically reloading part of the page. The within scope no longer existed and I think that was the cause of my error: "NOT_SUPPORTED_ERR: DOM Exception 9: The implementation did not support the requested type of object or operation.".
Adding a sleep in there seemed to be all I needed to make sure that the page had finished reloading before I continued to interact with it. I additionally made sure that the sleep happened before my within
block.
from capybara-webkit.
I encountered same problem today, and by removing with_in
block it worked... It didn't cause the tests to fail.
from capybara-webkit.
Related Issues (20)
- Issue rendering modal (SweetAlert) in CapybaraWebkit HOT 5
- Unable to find css because it redirects to /login HOT 1
- Status code 0 when injecting javascript file to be loaded over HTTPS HOT 1
- Capybara::Webkit::Browser.command becomes out of sync reading @connection responses, causing JSON::ParserError HOT 1
- Deprecation warning on normalize_whitespace with capybara >= 3.0 HOT 15
- EOFError: end of file reached on qt 5.9? HOT 3
- Follow 308 redirects HOT 8
- I am getting error when bootstrap from Window to Linux machine HOT 1
- Failing to install on mac OS 10.13.6 HOT 7
- Capybara-webkit +qt5.5 fails with X Code 10 HOT 31
- Capybara README remark clarification HOT 1
- Failing to build 1.15 on Alpine while 1.14 builds fine HOT 2
- fatal: reference is not a tree: 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 HOT 2
- ~
- Unable to maximize the window HOT 3
- Consider adding flexbox troubleshooting to README
- Upgrading Capybara to latest version makes Gitlab CI fail
- -v
- Capybara::Webkit::ConnectionError: webkit_server failed to start.
- No longer maintained? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capybara-webkit.