Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara/Selenium test for jquery autocomplete not working if Firefox is not made active

I'm running into an issue with the following code in a capybara test (covering a jquery autocomplete select)

page.evaluate_script %Q{ $('.ui-menu-item a:contains("#{target}")').trigger("mouseenter").click(); }

When Firefox is made active while the test is running, the test passes. When it remains inactive the test fails. This appears to be documented in this issue but I am wondering if anyone has found a work around.

I'm on OS X 10.6.7 and have tried FF 4 and 3.6.10

Thanks in advance!

like image 496
novemberkilo Avatar asked Dec 03 '25 06:12

novemberkilo


2 Answers

As an alternative way I'm using the capybara-webkit gem instead of selenium together with the headless gem and that works great for me.

like image 183
pagid Avatar answered Dec 05 '25 08:12

pagid


Since you're on a mac, you can work around this by using applescript to force firefox to the front. Add the following line to your ruby code wherever you need firefox to be on top:

`osascript -e \"tell application \\\"Firefox\\\" to activate\"`

Taken from here: https://gist.github.com/2427601

like image 30
Nat Ritmeyer Avatar answered Dec 05 '25 08:12

Nat Ritmeyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!