Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

WebElement.click() sometimes misbehaves (webdriver 2.43 x Firefox 32) #7902

Closed
lukeis opened this issue Mar 4, 2016 · 9 comments
Closed

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 7902


What steps will reproduce the problem?
1. python code below
2.
3.

What is the expected output? What do you see instead?

click should expose "tab", but it actually goes to some other page
it works using javascript to click
it works if nativeEvents disabled


Selenium version: 2.43
OS: Windows 7
Browser: Firefox
Browser version: 32.0


another failure mode is for click to have no effect; often a second call will work
-- don't have public-url example for that, but either above workaround avoids misbehavior


# ===== CODE =====

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

def trial(use_javascript=False,
          nativeEvents=True):

    caps = dict(DesiredCapabilities.FIREFOX,
                # without native events, it works
                nativeEvents=nativeEvents)
    drv = webdriver.Remote("http://localhost:4444/wd/hub", caps)

    try:
        loc = "https://pappadeaux-semiprod.cashstar.com/gift-card/buy/"
        drv.get(loc)

        # clicking this element should expose tab on this page
        # - as it does outside webdriver
        button = drv.find_element_by_id("printathome-delivery")

        if use_javascript:
            # with javascript click, it works
            drv.execute_script("arguments[0].click();", button)
        else:
            # on FF 32 and selenium 2.43, webdriver click goes awry
            button.click()

        # broken behavior goes to some other page
        assert drv.current_url == loc, "Page should not change"

    finally:
        drv.quit()    

print '== FAILS with element.click =='
trial()

print '== WORKAROUND with javascript =='
trial(use_javascript=True)

print '== WORKAROUND disabling native events =='
trial(nativeEvents=False)


Reported by dmmccrae on 2014-09-15 17:51:52

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I have same thing. I think its a bug. P.S FF31 works fine try to downgrade your FF version
until better solution release.

Reported by anton@buuteeq.com on 2014-09-15 19:43:22

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2014-09-16 09:34:08

  • Labels added: Browser-Firefox

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I am facing the same issue with Click. I am having to call the click method twice to
make the webelement respond to the event. I have even tried to downgrade Firefox to
v.31. However, that was no go either.
On downgrading both selenium and FF to previous versions the scripts are working fine.

Reported by leouragan on 2014-09-17 06:10:50

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

The root cause of misclick is the sticky bar on the top of the page. When Selenium scrolls
to the target element it appears behind the sticky bar that accepts the click instead
of the target element.

To change scrolling behavior you can use 'elementScrollBehavior' capability:

    caps = dict(DesiredCapabilities.FIREFOX,
                # without native events, it works
                nativeEvents=nativeEvents,
                elementScrollBehavior = 1)

(0 means "autoscroll to the top of the page", 1 means "autoscroll to the bottom")

Or use synthesized events.

Reported by barancev on 2014-09-17 07:12:04

  • Status changed: WorkingAsIntended

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

If this is "working as intended" why does it work for other browsers (like Chrome, PhantomJS),
and previous Webdriver/Firdefox versions ?

If the element is really impossible to click, I would expect an "Element is not clickable
at point" exception.

If you put a breakpoint in the test code, you will see that the element _is_ visible,
yet it still gets the incorrect behavior.


Reported by dmmccrae on 2014-09-17 10:47:21

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Chromedriver scrolls to the bottom by default. And you'll have problems with chrome
if you create a bottom stickybar (whereas Firefox will succeed in this case).

IE fails this test with native events enabled.

Reported by barancev on 2014-09-17 11:15:20

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Chrome works with this example regardless of elementScrollBehavior setting
(its not clear whether ChromeDriver has a way to change that setting)

Is it expected that this behavior changed from earlier versions of Firefox/Webdriver,
where we did not experience this misbehavior?

I understand that floating elements present a challenge.

However, I think that if webdriver is unable to click on the requested element, that
it should raise an "Element is not clickable at point" exception, rather than clicking
on something else. 

Disabling nativeEvents is an acceptable workaround for us.

Reported by dmmccrae on 2014-09-17 17:02:19

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I am facing similar to this issue (clicking misbehave , elements floating to left)

In my case , when i click on button then the whole div gets floated in to left and
element gets hidden  .

WebDriver version - 2.44
Firefox           - 33, 32, 31

Even though same functionality working fine in chrome browser , but it does not work
in Firefox .
This issue is very much strange .

Reported by perwez123 on 2014-12-03 14:45:41

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:24:32

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant