diff --git a/doc/RUNNING_TESTS.md b/doc/RUNNING_TESTS.md index fe8e0011a7b9..c15e61629c44 100644 --- a/doc/RUNNING_TESTS.md +++ b/doc/RUNNING_TESTS.md @@ -33,6 +33,17 @@ cucumber features: # Example: cuken Adding an issue link cuken() { bundle exec rake "cucumber:all[-n '$*']"; } +To activate selenium as test driver to test javascript on web pages, you can add +@javascript above the scenario like the following example shows: + + @javascript + Scenario: Testing something with Javascript + When I ... + +You can always start a debugger using the step "And I start debugging". +If you need Firebug and Firepath while debugging a scenario, just replace +@javascript with @firebug. + ## RSpec diff --git a/features/support/firebug-1.11.4.xpi b/features/support/firebug-1.11.4.xpi new file mode 100644 index 000000000000..8237ddbe2146 Binary files /dev/null and b/features/support/firebug-1.11.4.xpi differ diff --git a/features/support/firepath-0.9.7-fx.xpi b/features/support/firepath-0.9.7-fx.xpi new file mode 100755 index 000000000000..6fe2182b8125 Binary files /dev/null and b/features/support/firepath-0.9.7-fx.xpi differ diff --git a/features/support/selenium_with_firebug.rb b/features/support/selenium_with_firebug.rb new file mode 100644 index 000000000000..68ca93c7b9b5 --- /dev/null +++ b/features/support/selenium_with_firebug.rb @@ -0,0 +1,28 @@ +Capybara.register_driver :selenium_with_firebug do |app| + Capybara::Selenium::Driver + profile = Selenium::WebDriver::Firefox::Profile.new + profile.add_extension(File.expand_path("../firebug-1.11.4.xpi", __FILE__)) + profile.add_extension(File.expand_path("../firepath-0.9.7-fx.xpi", __FILE__)) + + # Prevent "Welcome!" tab + profile["extensions.firebug.currentVersion"] = "999" + + # Enable for all sites. + profile["extensions.firebug.allPagesActivation"] = "on" + + # Enable all features. + ['console', 'net', 'script'].each do |feature| + profile["extensions.firebug.#{feature}.enableSites"] = true + end + + profile['intl.accept_languages'] = 'en,en-us' + + Capybara::Selenium::Driver.new(app, + :browser => :firefox, + :profile => profile) +end + +Before '@firebug' do + Capybara.current_driver = :selenium_with_firebug +end +