Easy-automation is a project mainly written in Ruby, it's free.
Friendly Automation Testing Framework
Friendly Automation Testing Framework, tired of update every single test when developers change an XPath, id, class, etc? This is for you.
This framework uses common patterns to make maintainability easy and scalable tests. It's divided in:
We will implement kind of MVC pattern for automation testing, separating xpath's information, data for tests and the runner.
+---------+ +----------------------+
| Pages |<------| EasyAutomation::Page |
+---------+ +----------------------+
| +----------+
| | Elements |
v +----------+
+---------+ +----------+ +-------------+
| Suite |<----->| Runner |<----->| Selenium RC |
+---------+ +----------+ +-------------+
^ +--------+
| /| Data |
| / +--------+
+---------+ +----------------------+
| Tests |<------| EasyAutomation::Test |
+---------+ +----------------------+
Instead of work with actions => elements, we can use element => actions Normally: Selenium.click('id:btn') Selenium.enter('id:input_text', 'Text')
With this framework: page.btn.click page.input_text.enter('Text')
You have a lot of actions to use with your page elements, click, text, enter, etc.
More Reference: http://selenium.rubyforge.org/rdoc/classes/Selenium/
You can change any behaviour using EasyAutomation::Runner.config helper, options: EasyAutomation::Runner.configure do |config|
config.url = "http://www.google.com"
config.browser = "*safari" # "*firefox", "*chrome"
config.selenium_port = 4444
config.selenium_timeout = 1000
#if specified, it won't start selenium RC and will attempt to connect to remote selenium server
config.selenium_host = "localhost"
# Hooks
config.before :all do
puts 'Starting Tests'
end
config.after :all do
puts 'Tests finished, halting'
end
config.before :each_test do
# Do something
end
config.after :each_test do
# Do something
end
config.before :each_suite do
# Do something
end
config.after :each_suite do
# Do something
end
end
You can modify the behaviour via command line arguments, it's very useful when you want to run the same tests against different url, browser, etc, for example: bundle exec ruby example.rb --url=http://google.com This will run the example provided against http://google.com instead of http://www.google.com defined on the configure block, another example:
bundle exec ruby example.rb --url=http://images.google.com --browser=*safari
This will run example tests against images.google.com using safari browser
Bundler: echo "gem 'easy-automation' " >> Gemfile bundle install
Gems: gem install easy-automation
Structure:
/runner_demo.rb
test/
main_page_test.rb
data/
mainpagetest.yml
pages/
main_page.rb
elements/
mainpage.yml
main_page.rb class MainPage < EasyAutomation::Page def login_field @browser.text_field(:id, @elements.login) end def password_field @browser.text_field(:id, @elements.password) end end
mainpage.yml login: xpath=id('login') password: xpath=id('password')
main_page_test.rb class MainPageTest < EasyAutomation::Test def initialize test_name, path = 'data' super(test_name, path) end
def login_failed_test
main_page = MainPage.new(@browser, 'elements')
main_page.login_field.type @data.email
main_page.password_field.type @data.password
assert_true main_page.include?"wrong email/password combination with: #{@data.email}"
end
end
mainpagetest.yml login_failed_test: email: [email protected] password: pasguord
runner_demo.rb require 'rubygems' require 'easy-automation' Dir["#{File.dirname(FILE)}//.rb"].each { |f| require f }
EasyAutomation::Runner.configure do |config|
config.url = "http://www.google.com"
config.browser = "*safari"
config.before :all do
puts 'Starting Tests'
end
config.after :all do
puts 'Tests finished, halting'
end
end
demo_suite = EasyAutomation::Suite.new('Demo')
demo_suite.add(MainPageTest)
EasyAutomation::Runner.run demo_suite
Find some working code under examples folder, to see it search exmple on action, execute: cd examples/search bundle exec ruby example.rb
Order may matter
git checkout -b my_branch
)git commit -am "Fixing your bugs"
)git push origin my_branch
)Crowd Interactive is a Ruby and Rails consultancy firm powered by a team of enthusiast engineers who love programming. We turn your ideas into web applications, and we like challenging projects. We also have a lot of experience in retail, so it doesn't matter if your idea is about something you'd like to sell, we can surely help you.