NMKP
NMKP

Reputation: 799

is there any Alternative method for trigger in capybara?

I tried the following code:

page.find("#{element_name}").trigger(:mouseover)        

I'm getting the error:

Capybara::NotSupportedByDriverError (Capybara::NotSupportedByDriverError)

I am using selenium web-driver.

According to the following URL trigger is not implemented in selenium web-driver: Unable to trigger mouse event in Capybara test

Is there any alternative to method to perform mouse hover an element instead of using trigger in capybara?

Upvotes: 4

Views: 2849

Answers (1)

skalee
skalee

Reputation: 12695

page.execute_script(some_javascript), in particular some_javascript = "$(selector).trigger(event)". This will work on all drivers which are js-capable. Note that page.evaluate_script(some_javascript) could work too, but it's not guaranteed and discouraged (use evaluate_script only when script returns primitives).

I mean: execute client-side scripts which does what you want (trigger events).

Upvotes: 6

Related Questions