Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doamaral/ruby-rspec-selenium-capybara
Trying out basic setup and features for UI testing using Capybara
https://github.com/doamaral/ruby-rspec-selenium-capybara
capybara rspec ruby selenium
Last synced: 19 days ago
JSON representation
Trying out basic setup and features for UI testing using Capybara
- Host: GitHub
- URL: https://github.com/doamaral/ruby-rspec-selenium-capybara
- Owner: doamaral
- Created: 2019-11-21T19:59:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-10-20T03:38:48.000Z (over 2 years ago)
- Last Synced: 2024-11-15T10:36:32.996Z (3 months ago)
- Topics: capybara, rspec, ruby, selenium
- Language: Ruby
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ruby-rspec-selenium-capybara
Incrementing test project with Capybara. Although Capybara is not required to automate ui tests, it has a great DSL that might boost our experience scripting automate tests.
## Initial project structure
- Same basic steps from the [`ruby-rspec-selenium` Project](https://github.com/doamaral/ruby-rspec-selenium) until the `Writing first test script` Step
- Add `gem 'capybara', '~> 3.29'` to the Gemfile
- Run `bundle install` command to install all your gems
- Add `require 'capybara/rspec'` and `config.include Capybara::DSL` to the `spec_helper.rb` file
- Add basic Browser configurations through `Capybara.configure do |config|````ruby
Capybara.configure do |config|
config.default_driver = :selenium #Firefox default driver, it's also possible to use :selenium_chrome and :selenium_chrome_headless
config.default_max_wait_time = 5 #implicit wait
config.app_host = "http://the-internet.herokuapp.com"
end
```Obs: [More possible configs](https://www.rubydoc.info/github/jnicklas/capybara/Capybara.configure)
## Using Capybara's DSL
[capybara cheat sheet](https://gist.github.com/zhengjia/428105)
- Navigation is done using `visit ""`
- [Actions](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Actions):
- `fill_in [locator], with: "value"`: locator can be the name, id, test_id attribute, placeholder, or label text
- `click_on [locator]` or `click_button [locator]`
- `choose [locator]`
- `check [locator]`
- `select "Option", from: [locator]`
- [Finders](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Finders):
- `find`
- `find_link`
- `find_button`
- [Querying](https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Matchers):
- `page.has_selector?('table tr')`
- `page.has_selector?(:xpath, './/table/tr')`
- `page.has_xpath?('.//table/tr')`
- `page.has_css?('table tr.foo')`
- `page.has_content?('foo')`