Giter Club home page Giter Club logo

Comments (5)

lastobelus avatar lastobelus commented on June 22, 2024

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.

agibralter avatar agibralter commented on June 22, 2024

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.

halogenandtoast avatar halogenandtoast commented on June 22, 2024

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.

mattconnolly avatar mattconnolly commented on June 22, 2024

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.

kinopyo avatar kinopyo commented on June 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.