jquery - $ is not defined error in Selenium test -
I am trying to test the jQuery auto-complete test in a Rail 3.2 application using Selenium. After the one I created, there is a fill_autocomplete
helpful method that looks like this:
Def fill_autocomplete (area, option = {}) with the FILL_IN field, Option [: with] Page.execute_script% Q {$ ('## {field}'). Trigger ('focus')} page Execute_script% Q {$ ('## {field}'). Trigger ('keydown')}
When I run RSpec, I get this error: fill_autocomplete 'crop', with: 'm' selenium :: WebDriver
Failure / Error:: Error: Javascript error: $ is not defined
The problem is the line page. Execute_script% Q {$ ('## {field}'). Trigger ('Focus')}
spec_helper.rb
ENV ["RAILS_ENV"] || = 'Test' is required File .expand_path ("../../conf / environment", __FILE__) Requires' rspec / rails' 'rspec / autorun' is required 'coveralls '' Simplecov 'requires' capybara' Warden :: Test :: Helpers include SimpleCov .configure add_filter 'spec /' end coverlets.wear! ('Rail') Dir [Rails.root.join ("sp ec / support / ** / * .rb")]. Each {| F | | Configure the required f} RSPC. Config | Config.fixture_path = "# {:: Rails.root} / Imagery / fixtures" config.use_transactional_fixtures = trueconfig.infer_base_class_for_anonymous_controllers = false config.order = "random" wills config.include :: TestHelpers ,: type = & gt; : Controller config.extend controller macro ,: type = & gt; : End of Controller
dev / test group of Gemfile
Group: Development, testing gem 'haml-rails' Mani 'RSPEC-Rail', '~ & gt; 2.12.1 'Gem' webrat 'gem' Capibara ',' ~ & gt; 2.4.1 'Gem' Selenium-WebDriver ',' ~ & gt; 2.42.0 'Mani' factory _Gel_Rales ',' ~ & gt; 4.0 'Gem' cover 'is required: false end
I have tried to downgrade RSPC, Capifybras, and Selenium-WebDriver. I tried to use capebara-webkit instead of selenium, no benefit at all.
I'm working under the assumption that for the Capybara 'keydown' in the event and that jQuery auto-complete hook FILL_IN
this event does not trigger on its own. is this correct?
Any solutions or solutions are welcome Thanks!
Thanks for the advice of Arran, I realized that there is an error anywhere in JQuery before JQuery can be defined
Comments
Post a Comment