How can I run Capybara functionality in Rake task?
for example: visit('http://google.com')
Thank you!
As an added bonus, capelets you set how you want to run your rake task locally and remotely (no more bundle exec rake), just add this to your config/deploy.rbfile: # Configure Cape to execute Rake via Bundler, both locally and remotely.
Use the capistrano-rakegem Just install the gem without messing with custom capistrano recipes and execute desired rake tasks on remote servers like this: cap production invoke:rake TASK=my:rake_task
Rake enables you to define a set of tasks and the dependencies between them in a file, and then have the right thing happen when you run any given task. The combination of convenience and flexibility that Rake provides has made it the standard method of job automation for Ruby projects.
To run your first Capybara test on BrowserStack, follow the steps below: You can visit BrowserStack Automate Dashboard and see your test there. Protip: You can use our capability builder and select from a wide range of custom capabilities that BrowserStack supports.
Try something like this in the task:
require 'capybara'
require 'capybara/dsl'
Capybara.current_driver = :selenium
Browser = Class.new { include Capybara::DSL }
page = Browser.new.page
page.visit("http://www.google.com")
puts(page.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With