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

Support for firing arbitrary events in selenium-webdriver (ruby) feature request #1671

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

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 1671

Selenium supports sending arbitrary events to Dom nodes using the command fireEvent,
but the selenium web driver does not support this as far as I can tell. Though it does
support sending key events.

  it "should allow triggering of custom JS events" do
    pending "cannot figure out how to do this with selenium" if @session.mode == :selenium
    @session.visit('/with_js')
    @session.find(:css, '#with_focus_event').trigger(:focus)
    @session.should have_css('#focus_event_triggered')
  end

My motivation here is to get the trigger() method working for capybara so I can send
events like 'focus' to form controls.

Reported by jebarker on 2011-05-18 02:18:35

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

It's a deliberate decision to not include this feature in WebDriver, since it's usually
a hack to work around synthesized events not behaving properly. We'd rather eliminate
this need by providing great support for native events, so we'll continue improving
that going forward. A user would never fire a focus event, they would click the form
control. That's what your tests should be doing as well.

If you really need to trigger a synthesized event, you can still implement that in
JavaScript and use Driver#execute_script (which is what e.g. watir-webdriver does:
https://github.com/jarib/watir-webdriver/blob/master/lib/watir-webdriver/elements/element.rb#L136).
Though beware that people who use this in their code are up for some surprises when
WebDriver's native event support improves (e.g. the events would fire twice).




Reported by jari.bakken on 2011-05-18 23:17:14

  • Status changed: WontFix

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Fair cop, I think I've been going about the problem the wrong way, sorry to trouble.

Reported by jebarker on 2011-05-19 00:34:54

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

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

  • Labels added: Restrict-AddIssueComment-Commit

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