hover and css #106

Closed
fringd opened this Issue Jul 11, 2012 · 14 comments

Comments

Projects
None yet
6 participants

fringd commented Jul 11, 2012

hover is pretty badly supported by capybara to begin with, but the usual work around is to dig into the driver and call something like element.trigger('mouseenter') or evaling some javascript through the driver...

unfortunately these work arounds will not work for css :hover based drop down menus, which are very common( especially in my app ;).

naively, and without understanding at all how phantom.js works, i'm thinking, "why can't i just get the coordinates for that element and move the mouse over it?" ideally node would have a method hover() which moves some phantom cursor over it, or at least convinces webkit that this has happened.

is this at all within the realm of possibility?

I'm trying to convert a test suite from Capybara-Headless-Webkit to Poltergeist and am running into the same problem. The only "solution" I've come up with is not to include the stylesheet <link> tag in the test environment.

It appears that mouseover might not be a supported event with PhantomJS http://code.google.com/p/phantomjs/wiki/Interface#sendEvent(type,_...)

Yeah, only javascript event can be trigger, css event :hover does not work.

Contributor

jonleighton commented Sep 1, 2012

I think this might be possible using page.sendEvent('mousemove', ...), but I haven't tried. I would be open to implementing it as a non-standard thing at the driver level, but it would also be great if someone has some time to open a discussion about an official API for this in Capybara itself.

What about using a hover event, or at least a mouseenter, so we don't have to calculate coordinates and pass them in?

Contributor

jonleighton commented Sep 3, 2012

I am also willing to implement a #hover API along the following lines:

page.find('#foo').hover

However, before adding this to Poltergeist I would want someone to get it officially supported in Capybara so we are not diverging.

(The rule is that page.driver.foo can be non-standard, but other stuff has to be specced by capybara.)

Contributor

jonleighton commented Sep 3, 2012

(When I say "willing", I mean "willing to review/merge code", rather than "willing to do the work" ;)

Oh, I understood :)

It looks like Capybara prefers trigger('mouseover'). Cf Capybara #387 and Capybara #116.

Contributor

jonleighton commented Sep 24, 2012

@jamesarosen it would be a good idea to open a ticket about this against capybara and get the opinion of the maintainers. AFAIK the #trigger API is a way to trigger DOM events, but what we're talking about is not triggering a DOM event - we want to literally simulate a mouse move over the element with all the relevant side-effects such as css :hover.

jamesarosen referenced this issue in teamcapybara/capybara Feb 20, 2013

Closed

Feature request: CSS hover #832

Capybara just implemented hover and window-resize: jnicklas/capybara#965

@jonleighton how can I help make this happen?

route was assigned Jul 18, 2013

Owner

route commented Jul 18, 2013

Closing this because of Jon's commit 6c52e69

route closed this Jul 18, 2013

🆒

samccone referenced this issue in mojotech/pioneer Jun 16, 2014

Closed

A widget should have a hover method. #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment