I am testing an application with a dynamic popup menu across the top
of the page, and some static html links embedded in the centre of the
page.
I have a bizarre problem where I am trying to click on a central,
static link. It can be located successfully (ie I have a valid
WebElement reference). However when I try to click the element (eg
myLinkElement.click() ), the dynamic menu pops up and gets in the way,
and a link on the menu gets clicked instead.
Its as if WebDriver has located the target element and remembered its
x,y coordinates on the screen. When I call the click method, an
invisible cursor moves across the screen and over the menu -
triggering the mouseover event of the menu. The now-visible menu div
is then covering the target link, and gets selected instead.
I am using FirefoxDriver (0.9.7376) with Firefox 3.6.
Is my webdriver haunted, or is there a more rational explanation?
Is this a known issue and is there a workaround?
Thanks,
Matt
If this works, could you file a bug at
https://code.google.com/p/selenium/issues/entry about your problem?
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>
>
I've done a quick test disabling native events, but unfortunately it
breaks my test case earlier on, so I can't see if it addresses the
issue.
I'll try to put together a specific test case with html that
illustrates the problem.
Without native events, I couldn't do a hover, which I found I needed
to drive the menu. Without a hover, the menu items I am interested in
remain hidden, and therefore unclickable.
Ideally, I don't want to be using hover as it relies on
RenderedWebElement, so wouldn't be supported by all WebDriver
implementations, but I didn't find a better alternative. Is there a
way to click hidden elements?
Cheers,
Matt
On Mar 26, 2:06 am, Daniel Wagner-Hall <dawag...@gmail.com> wrote:
> If you have native events enabled (default for Firefox on Windows, I
> believe), then this makes sense, because the logic for "clicking" is
> "move mouse from where it is to the co-ords of the element, then click
> there". I don't think WebDriver provides a way of setting the mouse
> to an arbitrary position, so the best workaround I can offer for now
> is to create your own FirefoxProfile, call
> profile.setEnableNativeEvents(false), and pass this profile to the
> FirefoxDriver on construction. This should then work as you'd expect.
>
> If this works, could you file a bug athttps://code.google.com/p/selenium/issues/entryabout your problem?
RenderedWebElement is a bit of a misnomer - in reality all WebElements
are RenderedWebElements, the distinction in the interfaces is vastly
irrelevant.
I can't think of a better way to implement hovering than using native
events, but someone else may be able to... I think the best workaround
then would be to hover over an element which is guaranteed never to be
where the menu will be before trying to click your link, which is a
horrible horrible hack, but would do the job...
WebDriver's aim is to emulate the user, so things the user can't do
can't be done (e.g. clicking hidden elements).