WebMinion
WebMinion is a metadata-driven browser automation library. Instead of writing a custom bot with lots of code, you can write a JSON configuration and give it to WebMinion to run instead. You can use webdrivers like Mechanize, Capybara/Selenium and Capybara/PhantomJS.
NOTE The public API is currently unstable and subject to change.
Installation
Add this line to your application's Gemfile:
gem 'web_minion'
And then execute:
$ bundle
Or install it yourself as:
$ gem install web_minion
Usage
web_minion = WebMinion::Flow.build_via_json(File.read("./test/test_json/test_json_one.json"))
web_minion.perform
Sample Flow
Here's a sample login flow:
{
"config": {
driver: "mechanize",
},
"flow": {
"name": "Login Flow",
"actions": [
{
"name": "Login",
"key": "load_login_page",
"starting": true,
"steps":
[
{
"name": "Go to accounts login page",
"target": "https://example.com/login",
"method": "go"
},
{
"name": "Get login form",
"method": "get_form",
"target": {
"name": "login"
}
},
{
"name": "Fill in email",
"method": "fill_in_input",
"retain_element": true,
"target": {
"id": "email"
},
"value": "PUT USERNAME HERE"
},
{
"name": "Fill in password",
"method": "fill_in_input",
"retain_element": true,
"target": {
"id": "password"
},
"value": "PUT PASSWORD HERE"
},
{
"name": "Submit login",
"method": "submit"
},
{
"name": "Verify logged in page",
"is_validator": true,
"method": "body_includes",
"value": "Welcome Back"
}
]
}
]
}
}
WebMinion Drivers
By default, WebMinion will load it's Mechanize drivers. If you want to use Capybara, you will need to do the following:
require "web_minion/drivers/capybara"
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jibeinc/web_minion. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.