Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ To run the project, follow these steps:

## Generals

- In the folder `features/step_definitions` create files who define steps for each feature.
- In file `env.rb` define environment vars.
- In file `hooks.rb` define actions after/before each feature/scenario/tag.
- In file `helpers.rb` create modules and methods that you think can be used for many steps/features.
- Create files `.feature` in folder `features` and use descriptive names.
- Run rubocop with `bundle exec rubocop features`
The automation projects use a feature -> step_definition -> views structure.
- Create `.feature` files in the `/features` folder to describe the scenario that is being tested with its steps.
- Create `.rb` files in the `/features/step_definition` folder to describe the process within each step.
- Create `.rb` files in the `views` folder to define modules and methods to provide the step_definition.

The `env.rb` file does the set up for the proyect.
- It loads all the files and modules.
- It creates the driver instance, which is needed to test the application.

In the `hooks.rb` file you can define actions to be executed after/before each feature/scenario/tag.

While the `views` files are meant to be specific for each feature, you can define more generic methods to use all across the apllication in the `helpers.rb` file.


## Documentation

Expand Down
8 changes: 1 addition & 7 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,26 @@
require 'selenium-cucumber'
require 'selenium-webdriver'

# load all files and modules
relative_paths = ['/views/*.rb', '/services/*.rb']

full_paths = relative_paths.map { |relative_path| Dir.pwd << relative_path }

full_paths.each do |path|
Dir[path].sort.each do |f|
module_name = f.split('/').last.split('.')[0].capitalize
# to upper camel case
module_name = module_name.gsub(/_(\w)/) { Regexp.last_match(1).upcase }
require f
include Kernel.const_get(module_name)
end
end

# Store command line arguments

platform ||= get_env('platform')
browser ||= get_env('browser')
app_path ||= get_env('app_path')
$is_headless ||= get_env('headless')

# check for valid parameters
validate_parameters platform, browser, app_path

# If platform is android or ios create driver instance for mobile browser
if %w[android iOS].include? platform
browser = 'Browser' if browser == 'native'
device_name, os_version = get_device_info if platform == 'android'
Expand All @@ -48,7 +42,7 @@
puts e.message
Process.exit(0)
end
else # else create driver instance for desktop browser
else
begin
chromedriver_path = File.join(File.absolute_path(''),"chromedriver")
Selenium::WebDriver::Chrome.driver_path = chromedriver_path
Expand Down