Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.

click() requires multiple calls to fire event with IEDriver #3623

Closed
lukeis opened this issue Mar 3, 2016 · 11 comments
Closed

click() requires multiple calls to fire event with IEDriver #3623

lukeis opened this issue Mar 3, 2016 · 11 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3623

Selenium version: 2.20
OS: Win7 x64
Browser: IE
Browser version: 9.0.8112.16.421 (Update vers: 9.0.5)

What steps will reproduce the problem?
1. Use simple html page provided.
2. Locate either div or a element via xpath (use whatever, I'm using xpath here)
3. Call native click method. Nothing happens on either a or div until you call click
a second time.

Using python script:
div = d.find_elements_by_xpath('//div')[0] # Gets a single div
div.click() # Should fire the alert - nothing happens
div.click() # Now the alert displays

What is the expected output? What do you see instead?
It is expected that the first call to click() fires the alert.

This behavior is reproduced elsewhere in much more complicated pages but the basic
behavior boils down to requiring multiple clicks.

In some cases the number of clicks required to fire the event seems to correspond to
the number of jsFunctions referenced in an onclick event.

For example:
<a onclick="func1(); func2(); this.form.submit()">
generally requires 3 calls to click() to submit the form


*** Is there anyway I can have access to the click events in webdriver? If I could
I could possibly try to workaround these issue in my own API by parsing the onclick
string and calling click() the number of times I find the ';' character or something
similar.

I don't see anything currently that offers access to the events attached to a webdriver
element. get_attribute('click'|'onclick') doesn't give me anything at all.

Reported by sean.grider on 2012-03-27 16:03:04


- _Attachment: [test.html](https://storage.googleapis.com/google-code-attachments/selenium/issue-3623/comment-0/test.html)_
@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Tested again on a virtual machine running WinXP 32bit with IE8, same behavior.

Reported by sean.grider on 2012-03-27 16:15:17

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I just ran your test script, using the .NET bindings, against the page you provided,
against IE9 on Windows 7 (x64), and was able to see the alert, using only a single
click on the element. The problem you describe simply isn't globally broken for every
configuration. Are you running your script all at once, or are you attempting to use
the Python REPL?

Reported by james.h.evans.jr on 2012-03-27 23:03:52

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am using python and it doesn't matter for me whether I run it all at once
or interactively

multiple calls to fire event with IEDriver

you provided, against IE9 on Windows 7 (x64), and was able to see the
alert, using only a single click on the element. The problem you describe
simply isn't globally broken for every configuration. Are you running your
script all at once, or are you attempting to use the Python REPL?

Reported by sean.grider on 2012-03-27 23:27:02

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

If it makes any difference, I have Protected Mode enabled for all my internet zones
in IE.

Reported by sean.grider on 2012-03-28 14:19:19

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am simply unable to reproduce this issue in my environment. Is IE the foreground window
throughout the entirety of your code?

Reported by james.h.evans.jr on 2012-04-13 11:41:46

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have observed a similar behaviour with IE9. Sometimes a click on a button doesn't
work. The other time a click on a button works but a click on an anchor doesn't work.
And also sometimes i can reproduce the problem with the provided test.html. But unfortunately
it is not 100% reproduceable. Maybe it's a timing issue? 
Is there an opportunity to generate a detailed log file like for firefox with webdriver.log.file?

Selenium version: 2.21
OS: Win7 Pro x64 (German)
Browser: IE
Browser version: 9.0.8112.16421 (Update vers: 9.0.6)

Reported by m42tin on 2012-04-23 19:19:54

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2012-05-04 19:08:45

  • Labels added: Component-WebDriver, Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I also experience randomly unreliable clicking in IE with this piece of code:
--
driver.findElement(By.id(buttonId)).click();
--
The same code works fine in Firefox.

One additional thing that I noticed is that when clicking fails, I can see that the
button actually gets the focus, but was never clicked. Also I think this isn't a problem
with buttons but clicking in general, although I'm not entirely sure I'm right on this
because of the randomness of this issue.

I've searched the web for a solution and apparently this issue dates probably from
January 2011 at least. I've seen a workaround about using sendKeys("\n") instead of
click(), but I think this would submit the form, which I don't want. I tried sendKeys("
") instead considering this, but the same issue appears to occur. I've also seen another
workaround about forcing a focus with sendKeys("") and sleep the thread for a while
before calling click(), which would explain why calling click() multiple times eventually
works as originally reported, but that would slow down execution time significantly
and bloat up my code.

And finally, to answer comment #5: IE stays in the background during testing for me,
not the foreground.

Hope this helps!

--

Selenium: 2.24.1 with IEDriver 2.24.2
OS: Windows Vista x64
Browser: Internet Explorer 9 32-bit

Reported by smashster on 2012-07-10 22:12:11

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Made new ticket for issue 4229 related for selenium 2.23

Reported by sean.grider on 2012-07-10 22:36:56

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2013-02-24 21:26:39

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

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

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 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