cs-webautomator 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65a0e138de2d9b33644e8d8e5ed83eced70014ec
4
- data.tar.gz: a25b7ed66dbf09e9dfce3df7115e97149b92f8fb
3
+ metadata.gz: 74e7a731683e759d9bf74f8ca3b1a7ccf437c774
4
+ data.tar.gz: e0e20b93f4093665f8d18def462a749b287672ab
5
5
  SHA512:
6
- metadata.gz: cb4353b9f5fa8f92b412e68490f16cee415266b8f06dd4f21a9d68ea38dcc9deca0219cb8e564e4102eb4cd3c12a8beb3fab3f74f75b2718abbbd047b24374b0
7
- data.tar.gz: 200c23c966fc089f5802cb2baeec964a6b557d68a4890f84704cea3b0a01d99258569488bfe4141ea3e184a9311999cfde502a8dc620e066131d6b89473a44af
6
+ metadata.gz: 9b30226ac893e581dd89c3529c8d77d51238dfebe49c3014d1263f788d6f68f0d41d2ab183b91812e39d0cb9a118bccf42e930581b270ef5736ef24d15989302
7
+ data.tar.gz: a62156bae4e03f3cbe66d56d04eb7dfa74eaaff82d1ee34cc91cb13645f339e5e5c4ef7c334db87d5d574fff1a99e4155aeceb501c31c06d85da4cdec11379e7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cs-webautomator (0.1.0)
4
+ cs-webautomator (0.1.6)
5
5
  bundler (>= 1.7)
6
6
  gherkin (= 2.12.2)
7
7
  i18n (>= 0.6.11)
data/README.md CHANGED
@@ -1,62 +1,99 @@
1
1
  # CS::WEBAUTOMATOR
2
2
 
3
- ## Instalação
3
+ A simple gem to generate web automation project with:
4
4
 
5
- Executar:
5
+ > Cucumber [(link)](https://cucumber.io/)
6
+
7
+ > Capybara [(link)](https://github.com/jnicklas/capybara)
8
+
9
+ > SitePrism [(link)](https://github.com/natritmeyer/site_prism)
10
+
11
+ > Selenium Webdriver [(link)](http://www.seleniumhq.org/)
12
+
13
+ The structure is based on three layers: features, steps and pages.
14
+
15
+ 1. Features: Contains all the features of the project;
16
+ 2. Steps: Contains all the steps implementations;
17
+ 3. Pages: Contains all the pages in the website. A page must contain the declaration of all the elements of the page and the declaration of its actions.
18
+
19
+ ## Instalation
20
+
21
+ Install it as:
6
22
 
7
23
  $ gem install cs-webautomator
8
24
 
9
- ## Uso
25
+ ## Usage
10
26
 
11
- No terminal, para acessar o help:
27
+ In the terminal, type for help:
12
28
 
13
29
  ```
14
30
  cs-webautomator
15
31
  cs-webautomator generate
16
32
  ```
17
33
 
18
- Ver a versão da gem:
34
+ To see the gem version type:
19
35
 
20
36
  ```
21
37
  cs-webautomator version
22
38
  ```
23
39
 
24
- Gerar o projeto:
40
+ To generate a project type:
25
41
 
26
42
  ```
27
- cs-webautomator new Projeto
43
+ cs-webautomator new ProjectName
28
44
  ```
29
45
 
30
- Esse comando vai criar uma pasta com o nome Projeto no diretório corrente e criar os arquivos padrões. Projeto gerado em português por default.
31
-
32
- Para gerar em inglês, por exemplo, utilize:
46
+ This command will create a folder named ProjectName in the current directory and will create all the needed files. This gem support localizations. To create a localized project, in Portuguese, type:
33
47
 
34
48
  ```
35
- cs-webautomator new Projeto --lang=en
49
+ cs-webautomator new ProjectName --lang=pt
36
50
  ```
51
+ > The default language is English ('en'). The elements of Gherkin such as Given, When, Then, And, Scenario will be translated to all Gherkin supported languages, but this gem has just a few translation files (see that in folder: `lib/cs/webautomator/locales`).
52
+
53
+ > **CS-WEBAUTOMATOR doesn't support your mother language?** No problem. Fork it, create your yml translation file, uses the en.yml file as a template. Translate it and make a pull request. There are only 15 lines to be translated, this will take no time.
37
54
 
38
- **Os comandos generate funcionam dentro da raiz do projeto**.
55
+ > **Want to know how to name your translation yml file?** See the Gherkin supported languages [here](https://github.com/cucumber/gherkin/blob/master/lib/gherkin/i18n.json) for reference.
39
56
 
40
- ####Features
57
+ Once the project is created, open its folder (`cd ProjectName`) and run `bundle install`
58
+
59
+ There are three generators that are responsible to create the templates for Features, Step definitions and Pages.
60
+
61
+ **The generators commands ONLY WORK in the ROOT FOLDER of the project.**
62
+
63
+ #### Features
41
64
 
42
65
  ```
43
- cs-webautomator generate feature NomeFeature
66
+ cs-webautomator generate feature FeatureName
44
67
  ```
68
+ The feature generator will create a feature and its files. So this command will create the FeatureName.feature file inside the folder `features/specifications`, the file FeatureName_steps.rb inside the folder `features/step_definitions`, the files FeatureName_page.rb inside the folder `features/pages`.
45
69
 
46
- Esse comando vai criar um arquivo NomeFeature.feature dentro de `features/specifications`, NomeFeature_steps.rb dentro de `features/step_definitions` e FeatureName_page.rb dentro de `features/pages`.
47
-
48
- ####Steps
70
+ #### Steps
49
71
 
50
72
  ```
51
- cs-webautomator generate step NomeStep
73
+ cs-webautomator generate step StepName
52
74
  ```
53
- Esse comando vai criar um arquivo NomeStep_steps.rb na pasta `features/step_definitions`
75
+ The step generator will create a step file named StepName_steps.rb in the folder `features/step_definitions`
54
76
 
55
77
 
56
- ####Pages
78
+ #### Pages
57
79
 
58
80
  ```
59
81
  cs-webautomator generate page PageName
60
82
  ```
61
83
 
62
- Esse comando vai criar um arquivo NomeStep_page.rb na pasta `features/pages`
84
+ The screen generator will create both Platform dependent screens in the folder `features/pages`
85
+
86
+ ## TODO
87
+
88
+ 1. Run tests in Remote Server
89
+ 2. Run tests in Internet Explorer and Safari
90
+ 3. Create base methods (click, set, etc) to use with elements
91
+
92
+
93
+ ## Contributing
94
+
95
+ 1. Fork it ( https://github.com/samycici/cs-webautomator/fork )
96
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
97
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
98
+ 4. Push to the branch (`git push origin my-new-feature`)
99
+ 5. Create a new Pull Request
data/bin/cs-webautomator CHANGED
@@ -19,7 +19,7 @@ module CS
19
19
  desc 'feature [RESOURCE_NAME]', 'Generates a feature'
20
20
  option :lang,
21
21
  banner: 'any of the gherkin supported languages',
22
- default: :pt
22
+ default: :en
23
23
  def feature(name)
24
24
  I18n.config.default_locale = options[:lang]
25
25
  in_root_project_folder?
@@ -32,7 +32,7 @@ module CS
32
32
  desc 'step [RESOURCE_NAME]', 'Generates a step'
33
33
  option :lang,
34
34
  banner: 'any of the gherkin supported languages',
35
- default: :pt
35
+ default: :en
36
36
  def step(name)
37
37
  I18n.config.default_locale = options[:lang]
38
38
  in_root_project_folder?
@@ -43,7 +43,7 @@ module CS
43
43
  'Generates pages'
44
44
  option :lang,
45
45
  banner: 'any of the gherkin supported languages',
46
- default: :pt
46
+ default: :en
47
47
  def page(name)
48
48
  I18n.config.default_locale = options[:lang]
49
49
  in_root_project_folder?
@@ -80,7 +80,7 @@ module CS
80
80
  'Capybara, SitePrism, Selenium and Cucumber'
81
81
  option :lang,
82
82
  banner: 'any of the gherkin supported languages',
83
- default: :pt
83
+ default: :en
84
84
  def new(name)
85
85
  I18n.config.default_locale = options[:lang]
86
86
  # Thor will be responsible to look for identical
@@ -1,5 +1,5 @@
1
1
  module CS
2
2
  module WEBAUTOMATOR
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
4
4
  end
5
5
  end
@@ -1,96 +1,90 @@
1
- ## Configurando o ambiente ##
1
+ ## Getting Started ##
2
2
 
3
- ### Instalar rbenv ###
4
- Execute o seguinte comando:
3
+ ### Installing rbenv ###
4
+ Run this:
5
5
  ```shell
6
6
  brew install rbenv
7
7
  ```
8
8
 
9
- Inclua no ~/.bash_profile:
9
+ Add to ~/.bash_profile:
10
10
  ```shell
11
11
  eval "$(rbenv init -)"
12
12
  ```
13
13
 
14
- Listar as versões disponíveis:
14
+ List all available versions:
15
15
  ```shell
16
16
  rbenv install -l
17
17
  ```
18
18
 
19
- Instalar uma versão:
19
+ Install a Ruby version:
20
20
  ```shell
21
21
  rbenv install 2.3.1
22
22
  ```
23
23
 
24
- ### Ativar rbenv 2.3.1 ###
25
- Navegar para pasta desejada e executar o seguinte comando:
24
+ Sets a local application-specific Ruby 2.3.1:
26
25
  ```shell
27
26
  rbenv local 2.3.1
28
27
  ```
29
28
 
30
- ### Instalando o bundler ###
31
- Navegar para pasta desejada e executar o seguinte comando:
29
+ ### Installing bundler ###
30
+ Run this:
32
31
  ```shell
33
32
  gem install bundler
34
33
  ```
35
34
 
36
- ### Instalando as gems ###
37
- Execute o seguinte comando dentro da raiz do projeto:
35
+ ### Installing gems ###
36
+ Run this:
38
37
  ```shell
39
38
  bundle install
40
39
  ```
41
40
 
42
- ### Drivers necessários: ###
43
- Instalar [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/) e [phantomjs](http://phantomjs.org/) e adicionar ao PATH
41
+ ### Drivers: ###
42
+ Install [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/) and [phantomjs](http://phantomjs.org/).
43
+ Remenber include in the PATH.
44
44
 
45
- ### Executando os testes em DEV usando Chrome###
46
- Execute o seguinte comando dentro da raiz do projeto:
45
+ ### Run tests in DEV with Chrome###
46
+ Run this in the tests folder:
47
47
  ```shell
48
48
  bundle exec cucumber
49
49
  ```
50
50
 
51
- ### Executando os testes em DEV usando Firefox###
52
- Execute o seguinte comando dentro da raiz do projeto:
51
+ ### Run tests in DEV with Firefox###
52
+ Run this in the tests folder:
53
53
  ```shell
54
54
  bundle exec cucumber -p firefox -p dev
55
55
  ```
56
56
 
57
- ### Executando os testes em DEV usando Poltergeist###
58
- Execute o seguinte comando dentro da raiz do projeto:
57
+ ### Run tests in DEV with Poltergeist###
58
+ Run this in the tests folder:
59
59
  ```shell
60
60
  bundle exec cucumber -p poltergeist -p dev
61
61
  ```
62
62
 
63
- ### Executando os testes em HMG usando Chrome###
64
- Execute o seguinte comando dentro da raiz do projeto:
63
+ ### Run tests in HMG with Chrome###
64
+ Run this in the tests folder:
65
65
  ```shell
66
66
  bundle exec cucumber -p chrome -p hmg
67
67
  ```
68
68
 
69
- ### Executando os testes em HMG usando Firefox###
70
- Execute o seguinte comando dentro da raiz do projeto:
69
+ ### Run tests in HMG with Firefox###
70
+ Run this in the tests folder:
71
71
  ```shell
72
72
  bundle exec cucumber -p firefox -p hmg
73
73
  ```
74
- ### Executando os testes em HMG usando Poltergeist###
75
- Execute o seguinte comando dentro da raiz do projeto:
74
+ ### Run tests in HMG with Poltergeist###
75
+ Run this in the tests folder:
76
76
  ```shell
77
77
  bundle exec cucumber -p poltergeist -p hmg
78
78
  ```
79
79
 
80
- ### Gerando relatório HTML###
81
- Execute o seguinte comando dentro da raiz do projeto:
80
+ ### HTML Report###
81
+ Run this in the tests folder:
82
82
  ```shell
83
83
  bundle exec cucumber -p html_report
84
84
  ```
85
85
 
86
- ### Executando tags###
87
- Execute o seguinte comando dentro da raiz do projeto:
86
+ ### Run with tags###
87
+ Run this in the tests folder:
88
88
  ```shell
89
89
  bundle exec cucumber --tags @run
90
90
  ```
91
-
92
- ### Rodados specs de TDD###
93
- Execute o seguinte comando dentro de TDD:
94
- ```shell
95
- bundle exec rspec
96
- ```
@@ -7,11 +7,19 @@ require 'yaml'
7
7
  require 'capybara/poltergeist'
8
8
 
9
9
  BROWSER = ENV['BROWSER']
10
- AMBIENTE = ENV['AMBIENTE']
10
+ ENVIRONMENT_TYPE = ENV['ENVIRONMENT_TYPE']
11
11
 
12
+ ## register driver according with browser chosen
12
13
  Capybara.register_driver :selenium do |app|
13
14
  if BROWSER.eql?('chrome')
14
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
15
+ Capybara::Selenium::Driver.new(app,
16
+ :browser => :chrome,
17
+ :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(
18
+ 'chromeOptions' => {
19
+ 'args' => [ "--start-maximized" ]
20
+ }
21
+ )
22
+ )
15
23
  elsif BROWSER.eql?('firefox')
16
24
  Capybara::Selenium::Driver.new(app, :browser => :firefox)
17
25
  elsif BROWSER.eql?('internet_explorer')
@@ -1,22 +1,32 @@
1
1
  Before do |feature|
2
- CONFIG = YAML.load_file(File.dirname(__FILE__) + "/config/#{AMBIENTE}.yaml")
2
+ ## variable which loads the data file according to the environment
3
+ CONFIG = YAML.load_file(File.dirname(__FILE__) + "/config/#{ENVIRONMENT_TYPE}.yaml")
4
+
5
+ ## configure the chosen browser
3
6
  Capybara.configure do |config|
4
7
  config.default_driver = :selenium
5
8
  end
9
+
10
+ ## set default max wait and maximize browser
6
11
  Capybara.default_max_wait_time = 20
12
+ Capybara.current_session.driver.browser.manage.window.maximize
7
13
  end
8
14
 
9
15
  After do |scenario|
16
+
17
+ ## take screenshot if scenario fail
10
18
  if scenario.failed?
11
- diretorio = 'screenshots'
12
- arquivo = "#{diretorio}/#{scenario.name}.png"
13
- Dir.mkdir(diretorio) unless File.exist?(diretorio)
19
+ folder = 'screenshots'
20
+ file = "#{folder}/#{scenario.name}.png"
21
+ Dir.mkdir(folder) unless File.exist?(folder)
14
22
  if BROWSER.eql?('poltergeist')
15
- Capybara.page.save_screenshot(arquivo)
23
+ Capybara.page.save_screenshot(file)
16
24
  else
17
- Capybara.page.driver.browser.save_screenshot(arquivo)
25
+ Capybara.page.driver.browser.save_screenshot(file)
18
26
  end
19
27
  end
28
+
29
+ ## if the browser is different from poltergeist, kills instance
20
30
  unless BROWSER.eql?('poltergeist')
21
31
  Capybara.current_session.driver.quit
22
32
  end
@@ -1,5 +1,6 @@
1
1
  require 'rspec/expectations'
2
2
 
3
+ ## matcher to validate if all elements in list are equals
3
4
  RSpec::Matchers.define :all_list_elements_eq do |expected|
4
5
  match do |actual|
5
6
  actual.each do |i|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cs-webautomator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samanta Cicilia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler