aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_test_case.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix doc of `ActionDispatch::SystemTestCase` [ci skip]yuuji.yaginuma2019-02-011-7/+7
| | | | | | * Fix broken format. * Need to specify driver to the first argument of `driven_by`. * `add_emulation` doesn't have `device` keyword. Ref: https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/chrome/options.rb#L142-L162
* Rename methods and update docsEileen Uchitelle2019-01-291-8/+12
| | | | | | | | | | | | | | 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.
* Implement a way to add browser capabilities:Edouard CHIN2019-01-291-2/+18
| | | | | | | | | | | | | | | | | | * 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 ```
* Remove upper bound on Capybaraeileencodes2018-04-101-1/+1
| | | | | | | There's no reason to block future versions of Capybara since we don't _know_ they are going to break. How will we know if we have a conservative option set? This change prevents us from blocking users who want to upgrade in the future.
* Allow Capybara 3.x (#32151)Thomas Walpole2018-03-051-1/+1
|
* Merge pull request #31713 from aellispierce/refactor-browser-optionsEileen M. Uchitelle2018-01-171-0/+1
|\ | | | | Move browser config to its own class
| * Move browser checking to its own classAshley Ellis Pierce2018-01-151-0/+1
| |
* | Add headless browser support in api docs [ci skip]Pierre Hedkvist2017-12-181-0/+3
|/
* Add headless firefox driver to System Testsbogdanvlviv2017-12-071-2/+6
|
* Add load hook for `ActionDispatch::SystemTestCase`yuuji.yaginuma2017-10-281-0/+2
| | | | | | | | This is useful to extend `SystemTestCase`. Also, since other test classes already have load hooks, should also be in `SystemTestCase`. Ref: 0510208dd1ff23baa619884c0abcae4d141fae53
* Require capybara 2.15 because we depend on the new puma integrationRafael Mendonça França2017-10-251-1/+1
|
* specify minimum capybara version for system testsJoe Francis2017-10-231-0/+2
| | | | | | Upgraded rails applications may have a Gemfile without a new enough capybara to run system tests. Setting a version here gives the user a more direct error message than they get otherwise. Resolves #30952
* [Action Pack] require => require_relativeAkira Matsuda2017-10-211-5/+5
| | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* Add headless chrome driver to System Testsyuuji.yaginuma2017-10-171-0/+2
|
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-0/+2
|\
| * SystemTestCase undef some IntegrationTest methods because it's confused to use.yalab2017-07-011-0/+2
| |
* | [Action Dispatch] require => require_relativeAkira Matsuda2017-07-011-4/+4
|/
* Tiny documentation fixes [ci skip]Robin Dupret2017-06-061-3/+3
|
* [ci skip] Fix typo in the system tests docsPrathamesh Sonpatki2017-06-031-1/+1
|
* SystemTesting::Driver can register capybara-webkit and poltergeistMario Alberto Chávez2017-06-021-2/+6
| | | | | | | | | | 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.
* Make `driven_by` overridableFumiaki MATSUSHIMA2017-03-291-6/+5
| | | | | | | | | | | | | | | | | | | | | | Sometimes we want to use rack_test partially instead of selenium for test speed: ```ruby class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: {url: "http://chrome:4444/wd/hub"} end class WithJavaScriptTest < ApplicationSystemTestCase end class WithoutJavaScriptTest < ApplicationSystemTestCase driven_by :rack_test end ``` In the abobe case, `WithoutJavaScriptTest` uses selenium because `SystemTestCase` calls superclass' driver on `#initialize` (`self.class.superclass.driver.use`). Using `class_attribute` can handle inherited `driven_by`.
* 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-2/+2
|\ \ | | | | | | Pass options to `driven_by`
| * | Pass options to `driven_by`Fumiaki MATSUSHIMA2017-03-131-2/+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 ```
* / Bump Capybara and include Minitest::Assertionseileencodes2017-03-171-0/+2
|/ | | | | | | | | | | | | | | | | | | | | Capybara was updated in teamcapybara/capybara#1841 to use Minitest style assertions so that system test output shows x number of assertions, x numbe of failures, etc. Before: ``` 6 runs, 0 assertions, 0 failures, 0 errors, 0 skips ``` After: ``` 6 runs, 7 assertions, 1 failures, 0 errors, 0 skips ``` This change bumps Capybara from 2.7.0 to 2.13.0 and includes the required minitest assertion file in the test case. :tada:
* Call system test driver per-instance rather than globallyeileencodes2017-03-091-5/+12
| | | | | | | | | | | | | | | | | | | | | | 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-091-10/+1
| | | | | | | 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.
* Change `SystemTestCase.driven_by` to use `setup`/`teardown` hooksLucas Mazza2017-02-241-2/+9
| | | | | | 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.
* Move documentation to the correct placeeileencodes2017-02-231-72/+72
| | | | | The documentation needs to be above the method to correctly document the method.
* Tiny documentation edits [ci skip]Robin Dupret2017-02-211-1/+1
|
* Fix some grammar in docs [ci skip]kenta-s2017-02-211-1/+1
|
* Clean up documentationeileencodes2017-02-201-9/+10
| | | | | There were some grammar issues and incorrect information in the system tests documentation.
* Rename system_test_helper -> application_system_test_caseeileencodes2017-02-201-19/+6
| | | | | | This renames the system test helper file to be application system test case to match what the rest of Rails does. In the future we should consider changing the test_helper to match.
* Fix default host in setup, move teardown to helper fileeileencodes2017-02-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Override integration test default host Integration tests automatically set the default host to 'http://example.com'. This works fine for integration tests because they are not real browser sessions, but doesn't work fine for system tests because they are real browser sessions. We can override this by setting the `host!` in `before_setup. The `Capybara.always_include_port` will allow the test to look at `127.0.0.1:port capybara picks` and properly redirect the test. Any application can override this by setting the `host!` in their system test helper. Generally though, applications are going to be using localhost. In this commit I also moved the setup and teardown into their own module for tidiness. * Move teardown settings into system test case These configuration options can be put into the system test case file instead of the generated system tests helper file. This is an implementation detail and therefore shouldn't be generated with the template.
* Move and rename system testseileencodes2017-02-201-0/+129
* Move system tests back into Action Pack * Rename `ActionSystemTest` to `ActionDispatch::SystemTestCase` * Remove private base module and only make file for public `SystemTestCase` class, name private module `SystemTesting` * Rename `ActionSystemTestCase` to `ApplicationSystemTestCase` * Update corresponding documentation and guides * Delete old `ActionSystemTest` files