diff --git a/README.md b/README.md index 9ad07b6..483de6c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/features/support/env.rb b/features/support/env.rb index 8f372a6..207f93f 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -2,7 +2,6 @@ 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 } @@ -10,24 +9,19 @@ 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' @@ -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