-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: CSS hover #832
Comments
I have exactly the same problem with CSS menus using |
I think this will be tricky to get into the Capybara API, since it's not What I personally tend to do is something along the lines of page.execute_script("$('.element-that-would-be-shown-on-hover').css('display', So far it works well enough. |
@joliss is the policy that all parts of the capybara api must be supported by selenium? |
I don't think there is a policy per se, but so far we've tried to only add features if we can reasonably expect them to be supported across drivers (minus RackTest). Selenium is Capybara's primary JS driver at the moment, so that's what I'd look at primarily. Asking whether Selenium supports something is certainly a way to avoid features creeping in that turn out to be a pain to support cross-driver. |
@joliss I guess I disagree. There are already differences between what drivers support, and this seems fine to me so long as it's clear to the user that their driver does/doesn't support something. What seems more problematic is divergence between drivers. For example, capybara-webkit and poltergeist support several of the same things. Let's take resizing the window as an example. In capybara-webkit this is I have a rule that I won't allow Capybara to be monkey-patched in Poltergeist. This gives some indication to users about whether something is non-standard. So basically all non-standard stuff must be on So assuming Capybara doesn't standardise this feature, the only way to support it in poltergeist will be: page.driver.hover(page.find('#foo')) Which seems kind of a shame, really. |
I'm okay with adding features to Capybara which are not supported by Selenium. But in that case I would like to have tests for it within Capybara itself. Obviously they wouldn't run for any of the bundled drivers, but at least it would be specified. So if someone can provide a pull request for hover for example, which they have run against some driver, then I would be okay with adding that. |
Hey just wondering has anybody found a way to do a CSS hover using capybara (or poltergeist/phantomjs)? |
I think the problem is broader than hovering over an element. In the app that we are working on, we need to do that, move mouse to given coordinates on the page, resize the window, change scroll position... probably not a daily requirement for some, but currently using driver-specific features or injecting JavaScript to make stuff happen. Even if not day-to-day feature for most projects, it is not uncommon that you have to make your JS aware of stuff like cursor position, window size, scrollTop etc. Maybe you would consider adding just the nice API to Capybara itself, so the drivers can catch up and implement it independently. I would suggest "try our best" approach, with API similar to:
Maybe cursor and window objects would also have getters to find out current orientation, current cursor style, current window dimensions and scroll offsets - that would be useful for acceptance testing stuff like scrolling to given element or seeing if element behaves like a link, while being for example a span (cursor change). I probably can provide a pull request with stubs for such functionality, that then can be used by drivers to implement Capybara-compatible APIs. |
Go, go @twalpole! |
I cannot find a way to trigger a CSS hover event. That is, if a menu shows on hover, there's no way to click the items in that menu.
I've found #116, but that seems to be about a (nonexistent) JavaScript hover event. The suggestion -- to use a
mouseover
event -- works great for JavaScript event handlers, but not:hover
CSS styling.The Poltergeist driver folks think that there's merit to this, but they want to hear guidance from this project.
The text was updated successfully, but these errors were encountered: