Ruby-Selenium
A Ruby gem to help developers write test cases for a UI.
Create Action
def get_check_box_action(driver)
# Create your action
RadioButtonAction.new(driver)
end
def (driver)
# Create your action
CheckBoxAction.new(driver)
end
def get_input_action(driver)
# Create your action
InputAction.new(driver)
end
def get_select_action(driver)
# Create your action
SelectAction.new(driver)
end
def (driver)
# Create your action
ButtonAction.new(driver)
end
Create Test Case
def get_test_case(driver)
LegoTechSelenium::TestCase::Builder.new("My first test case", driver)
.add_action(get_input_action(driver))
.add_action(get_select_action(driver))
.add_action((driver))
.add_action(get_check_box_action(driver))
.add_action((driver))
.build
end
Create a Test Suite
def get_test_suite(driver)
LegoTechSelenium::TestSuite::Builder.new("My first test suite", driver)
.add_test_case(get_test_case(driver))
.build
end
And Off you go!
testSuite = get_test_suite(driver)
testSuite.run
Now supports Action validation
You can now validate that the field that you clicked has valid data within it by simply setting the :validate => true
flag within your Action.
If you don't want to then just don't set it.
How to install Chrome Driver on Mac OSX
In order to control Chrome you will need to install the Chrome Driver please follow these steps. https://www.swtestacademy.com/install-chrome-driver-on-mac/
Note once the driver is installed run it manually once in order to allow the system to trust it. If you do not do thisd then the system will not trust it and then it will not open
How to install dependencies
- Make sure Ruby is installed
ruby -v
should return the current version of the language on your computer - Install bundler using
gem install bundler
to allow you to build the project - Make sure all of your new dependencies are within the Gemfile
- Run
bundle install --path vendor/bundle
How to build a release
- Make sure Ruby is installed
ruby -v
should return the current version of the language on your computer - Install bundler using
gem install bundler
to allow you to build the project - Building is as simple as
gem build legoTech.gemspec
How to publish
- Make sure Ruby is installed
ruby -v
should return the current version of the language on your computer - Make sure you have a built gem
- Using the gem command run the following
gem push [YOUR_GEM_NAME].gem
How to include within project
Using Bundler
- Install bundler
- Create a Gemfile
- Locate all the gem here
- Include the version that you wish to use within the Gemfile
- Add
selenium-webdriver
as a dependency to the Gemfile - Run
bundle install
- Create a ruby file called
example.rb
- At the top write
require "legoTech_gem"
- Run the following command
bundle exec ruby example.rb
Using pure Gem
- Make sure Ruby is installed
- Run
gem install legoTech_gem
- Create a ruby file
- At the top write
require "legoTech_gem"
- Run the file and all your dependencies should be there
Run the Example
You can run the example script which would provide you with a nice and simple example of how the script works.
- Install Selenium
- Install Chrome Driver (shown above)
- Install Ruby
- Within the
e2e
folder runruby main.rb
Before Result:
After Result:
Author
Profile Links
Notes
Please respect the naming definition as taken from here: https://github.com/airbnb/ruby#naming
Comments and tags must respect the naming from: https://rubydoc.info/gems/yard/file/docs/Tags.md
Ruby Types are defined here: https://www.geeksforgeeks.org/ruby-data-types/
Note: https://stackoverflow.com/questions/28506769/failed-to-require-a-local-gem/28507368#28507368