aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_testing
Commit message (Collapse)AuthorAgeFilesLines
* Stop setting a default Capybara app hostGeorge Claghorn2019-07-241-7/+4
| | | It's intended not to be set if Capybara starts the app server itself. Base Rails-generated URLs off of Capybara.current_session.server_url instead.
* Fix Browser#preload for older SeleniumJohn Hawthorn2019-07-041-2/+12
| | | | | | | Older versions of selenium had driver_path on ::Selenium::WebDriver::Chrome directly, not on Service. This avoids errors on those old versions and will preload properly if webdrivers is installed.
* Preload browser driver_path for system testingJohn Hawthorn2019-07-032-0/+15
| | | | | | | | | | | The webdrivers gem configures Selenium::WebDriver::Service.driver_path as a proc which updates the web drivers and returns their path. This commit introduces SystemTesting::Browser#preload, which runs this proc early. This ensures that webdrivers update is run before forking for parallel testing, but doesn't explicitly tie us to that gem (and I think anything configured as driver_path probably makes sense to eager-load).
* Permit running jobs in system testsGeorge Claghorn2019-05-162-27/+0
| | | | | Inherit from ActiveSupport::TestCase instead of ActionDispatch::IntegrationTest. Active Job automatically mixes its test helper into the latter, forcibly setting the test queue adapter before Capybara starts its app server. As a bonus, we no longer need to remove the parts of the ActionDispatch::IntegrationTest API we don’t want to expose.
* Make system tests take failed screenshots in `before_teardown` hookRichard Macklin2019-04-201-5/+7
| | | | | | | | | | | | Previously we were calling the `take_failed_screenshot` method in an `after_teardown` hook. However, this means that other teardown hooks have to be executed before we take the screenshot. Since there can be dynamic updates to the page after the assertion fails and before we take a screenshot, it seems desirable to minimize that gap as much as possible. Taking the screenshot in a `before_teardown` rather than an `after_teardown` helps with that, and has a side benefit of allowing us to remove the nested `ensure` commented on here: https://github.com/rails/rails/pull/34411#discussion_r232819478
* truncate screenshot filenames to avoid errorJosi McClellan2019-04-181-1/+2
|
* Update terminal-to-html inline images url in ScreenshotHelperbetterzega2019-02-051-1/+1
|
* selenium-webdriver is not always required for system testingRyuta Kamizono2019-01-301-4/+2
| | | | | | But `NameError: uninitialized constant ActionDispatch::SystemTesting::Browser::Selenium` is pretty confused. I've little improved missing constant error to `NameError: uninitialized constant Selenium`.
* Fix system testing failureRyuta Kamizono2019-01-301-8/+11
| | | | https://travis-ci.org/rails/rails/jobs/486155626#L1317-L1335
* Rename methods and update docsEileen Uchitelle2019-01-292-11/+11
| | | | | | | | | | | | | | This is a minor update to the named methods for the following: - s/desired_capabilities/capabilities - s/driver_options/capabilities Since they are all the same thing we should keep the name the same throughout the feature. Updated docs to match / be a little bit clearer Also updated the Gemfile for selenium-webdriver.
* driver_option -> driver_optionsEdouard CHIN2019-01-292-7/+7
|
* Implement a way to add browser capabilities:Edouard CHIN2019-01-292-8/+22
| | | | | | | | | | | | | | | | | | * There is currently no way to define specific browser capabilities since our SystemTest driver override the `option` key [Ref](https://github.com/rails/rails/blob/a07d0680787ced3c04b362fa7a238c918211ac70/actionpack/lib/action_dispatch/system_testing/driver.rb#L35) This option key is used internally by selenium to add custom capabilities on the browser. Depending on the Browser, some option are allowed to be passed inside a hash, the driver takes care of setting whatever you passed on the driver option. An example [here](https://github.com/rails/rails/blob/a07d0680787ced3c04b362fa7a238c918211ac70/actionpack/lib/action_dispatch/system_testing/driver.rb#L35) where you are allowed to pass args such as `--no-sandbox` etc However this behavior was only meant for backward compatibility and as you can see it's deprecated. The non-deprecated behavior is to create a `<Driver>::Option` object containing all the capabilities we want. This is what we [currently do](https://github.com/rails/rails/blob/a07d0680787ced3c04b362fa7a238c918211ac70/actionpack/lib/action_dispatch/system_testing/browser.rb#L34-L36) when chrome or firefox are in headless mode. This PR allows to pass a block when calling `driven_by`, the block will be pased a `<Driver>::Option` instance. You can modify this object the way you want by adding any capabilities. The option object will be then passed to selenium. ```ruby driven_by :selenium, using: :chrome do |driver_option| driver_option.add_argument('--no-sandbox') driver_option.add_emulation(device: 'iphone 4') end ```
* Reset sessions on failed system test screenshotMaxim Perepelitsa2018-11-131-2/+5
| | | | | Reset Capybara sessions if `take_failed_screenshot` raise exception in system test `after_teardown`.
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Use strict_encode64 instead of gsub newline for ScreenshotHelperBart de Water2018-04-231-1/+1
|
* Only disable headless chrome gpu on WindowsStefan Wrobel2018-04-071-1/+1
| | | Per Chromium team this has not been necessary on other platforms for quite some time: https://bugs.chromium.org/p/chromium/issues/detail?id=737678#c1
* Fix system tests transactions not closed between examplesSergey Tarasov2018-03-191-0/+1
|
* Uses the absolute path for system test screenshotsZamith2018-02-271-1/+1
| | | | | | | | | | | | | Why: * When getting an error that generates a screenshot it would be helpful to be able to ctrl+click it to quickly open it in the browser, which does not work with relative paths This change addresses the need by: * Changing `image_path` to disregard the relative path and use the absolute one instead
* Move browser checking to its own classAshley Ellis Pierce2018-01-152-26/+52
|
* Change the system tests to set Puma as default server only when the user ↵Guillermo Iguaran2017-12-091-1/+1
| | | | haven't specified manually another server.
* Add headless firefox driver to System Testsbogdanvlviv2017-12-071-1/+12
|
* Make screenshots default to "simple" formateileencodes2017-11-291-10/+6
| | | | | | | | | Not everyone uses iTerm2 and whereas Terminal.app on a mac just ignores that and outputs the path, other terminals like those on Ubuntu do not. A friendlier default is one that works by default. Closes #31159 Closes #30957
* Explicitly pass window handle to `resize_window_to`yuuji.yaginuma2017-11-061-1/+1
| | | | | | | | | | | Unlike `resize_window`, `resize_window_to` has three arguments. https://github.com/thoughtbot/capybara-webkit/blob/d63c3c8e3ae844f0c59359532a6dcb50f4a64d0a/lib/capybara/webkit/driver.rb#L135-L143 Therefore, if pass only width and height just like `resize_window`, `ArgumentError`will be raised. To prevent this, explicitly pass window handler. Follow up of #31046
* Fix Capybara::Webkit::Driver#resize_window deprecation warningNihad Abbasov2017-11-041-1/+1
| | | | | >[DEPRECATION] Capybara::Webkit::Driver#resize_window is deprecated. Please use Capybara::Window#resize_to instead.
* Puma Rack handler is required by CapybaraGuillermo Iguaran2017-10-281-2/+0
| | | See: https://github.com/teamcapybara/capybara/blob/7d693f068c44f6a460336da70fb6e9e5f94f3db9/lib/capybara.rb#L450
* Add headless chrome driver to System Testsyuuji.yaginuma2017-10-171-1/+17
|
* Exception message for SystemTestCase#get etc..yalab2017-10-081-1/+1
|
* Use the default Capybara registered puma server configurationThomas Walpole2017-09-181-13/+1
|
* Retrive screenshot in relative path of current directoryyuuji.yaginuma2017-08-271-5/+9
| | | | | | | | | | In Rails engine `Rails.root `returns the path of the dummy application. Therefore, there is no `tmp` directly where the test is running, so can not get the screenshot. For this reason, instead of directly specifying tmp, retrive screenshot by relative path from the current directory. Fixes #30405
* Fix `can't modify frozen String` error in `display_image`yuuji.yaginuma2017-08-261-1/+1
| | | | | | | | | | Without this, `display_image` raises an error as follwing: ``` RuntimeError: can't modify frozen String rails/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:72:in `display_image' rails/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb:40:in `block (2 levels) in <class:ScreenshotHelperTest>' ```
* Update links to use https link instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|
* Use ssl in guide and comment [ci skip]Yoshiyuki Hirano2017-08-191-1/+1
|
* Use frozen string literal in actionpack/Kir Shatrov2017-07-295-0/+10
|
* Don't call register on custom driverseileencodes2017-07-081-3/+3
| | | | | | | | | | | | | It's possible for developers toadd a custom driver and then call it using `driven_by`. Because we were only skipping `register` for `:rack_test` that meant any custom driver would attempt to be registered as well. The three listed here are special because Rails registers them with special options. If you're registering your own custom driver then you don't want to separately register that driver. Fixes #29688
* SystemTestCase undef some IntegrationTest methods because it's confused to use.yalab2017-07-011-0/+24
|
* Add an option to silence puma in system tests.Sam Phippen2017-06-241-1/+12
| | | | | | | | | | | | This is motivated by our usage of system test in RSpec. Puma lazily boots the first time a system test is used, but this causes some unfortunate output to appear in the middle of the user's green dots. An example of this can be seen in @derekprior's comment [here](https://github.com/rspec/rspec-rails/pull/1813#issuecomment-309252314). There are alternatives in RSpec where we attempt to intercept the puma boot and prevent the output from being made there, but that would involve some monkey patching. This seems like a cleaner solution.
* SystemTesting::Driver can register capybara-webkit and poltergeistMario Alberto Chávez2017-06-021-5/+24
| | | | | | | | | | drivers. When using `driver_by` with capybara-webkit or poltergeist, SystemTesting::Driver will register the driver while passing `screen_size` and `options` parameteres. `options` could contain any option supported by the underlying driver.
* Set `Capybara.app_host` through `host!`Fumiaki MATSUSHIMA2017-04-021-1/+6
| | | | | | | | | | | | | | | | | | | | | `visit "/"` will visit always "http://127.0.0.1" even when we call `host!`: ```ruby class SomeTest < ApplicationSystemTest def setup host! "http://example.com" end def test_visit visit root_url # => visit "http://example.com/" visit "/" # => visit "http://127.0.0.1/" end end ``` Because Capybara assumes that host is same as the server if we don't set `Capybara.app_host`: https://github.com/teamcapybara/capybara/blob/866c975076f92b5d064ee8998be638dd213f0724/lib/capybara/session.rb#L239
* Merge pull request #28394 from shime/docs-action-dispatchXavier Noria2017-03-221-1/+1
|\ | | | | [docs] fix ActionDispatch documentation
| * [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-131-1/+1
| |
* | Merge pull request #28341 from mtsmfm/pass-options-to-driven-byRafael França2017-03-171-1/+2
|\ \ | | | | | | Pass options to `driven_by`
| * | Pass options to `driven_by`Fumiaki MATSUSHIMA2017-03-131-1/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Capybara drivers can handle some options such like `url`. ### before ``` # test/test_helper.rb Capybara.register_driver :remote_chrome do |app| Capybara::Selenium::Driver.new(app, browser: :chrome, url: "http://example.com/wd/hub") end # test/application_system_test_case.rb class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :remote_chrome end ``` ### after ``` # test/application_system_test_case.rb class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: {url: "http://chrome:4444/wd/hub"} end ```
* / Dont always display inline screenshots in system testing (#28133)Renaud Chaput2017-03-111-5/+34
|/ | | | | | | | | 3 output types are supported: - simple: only display the screenshot path - artifact: display the screenshot in the terminal, using the artifact protocol (supported by some CI) - inline (default): display the screenshot in the terminal, inline (supported by some terminals) You can force the output type by setting the `RAILS_SYSTEM_TESTING_SCREENSHOT` environment variable
* Call system test driver per-instance rather than globallyeileencodes2017-03-092-6/+1
| | | | | | | | | | | | | | | | | | | | | | Previously the system test subclasses would call `driven_by` when the app booted and not again when the test was initialized which resulted in the driver from whichever class was called last to be used in tests. In rails/rails#28144 the `driven_by` method was changed to run `use` on setup and `reset` on teardown. While this was a viable fix this really pointed to the problem that system test `driven_by` was a global setting, rather than a per-class setting. To alieviate this problem calling the driver should be done on an instance level, rather than on the global level. I added an `initialize` method to `SystemTestCase` which will call `use` on the superclass driver. Running the server has been moved to `start_application` so that it only needs to be called once on boot and no options from `driven_by` were being passed to it. This required a largish rewrite of the tests. Each test needs to utilize the subclass so that it can properly test the drivers. `ActionDispatch::SystemTestCase` shouldn't be called directly anymore.
* Refactor system test driver/browsereileencodes2017-03-092-30/+23
| | | | | | | Since using a browser is only for selenium it doesn't really make sense to have a separate class for handling it there. This brings a lot of the if/else out of the main SystemTestCase class and into the Driver class so we can abstract away all that extra work.
* Do not take screenshot if driver does not support screenshotyuuji.yaginuma2017-03-041-1/+5
| | | | | | | | | | | | | `Capybara::RackTest::Driver` does not support taking screenshots. If call `#save_screenshot` on `Capybara::RackTest::Driver` will raise the error. ```ruby Error: UsersTest#test_visiting_the_index: Capybara::NotSupportedByDriverError: Capybara::Driver::Base#save_screenshot ``` To prevent errors, if driver does not support screenshot, do not call it.
* Fix random failure on system test with ajaxFumiaki MATSUSHIMA2017-03-031-1/+1
| | | | | | | | If application has ajax, browser may begin request after rollback. `teardown_fixtures` will be called after `super` on `after_teardown` so we must call `Capybara.reset_sessions!` before `super` https://github.com/rails/rails/blob/b61a56541aecd7ac685d4f19d943177a3f1b465a/activerecord/lib/active_record/fixtures.rb#L857
* Take failed screenshot before reset driveryuuji.yaginuma2017-02-281-1/+1
| | | | | | | Now reset the driver before take failed screenshot since #28144. However, I think that failed screenshot should be take with the driver actually used in the test. So, fixed to take screenshot before reset driver.
* Change `SystemTestCase.driven_by` to use `setup`/`teardown` hooksLucas Mazza2017-02-242-13/+12
| | | | | | Previously, `driven_by` would change the Capybara configuration when the test case is loaded, and having multiple test classes with different `driven_by` configs would fail as the last loaded would be effective.
* Do not take screenshot when test skippedyuuji.yaginuma2017-02-231-2/+6
|