web4cucumber 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ ### Introduction
1
2
  The main filosophy behind this project is:
2
3
  Separate the data from the logic as much as you possibly can. Have you had to
3
4
  go through a tremendous ruby module with hundreds of methods which click
@@ -49,10 +50,10 @@ actions to be performed in Web UI of your product in simple yaml-formatted
49
50
  files. This approach allows you to separate the application data (html
50
51
  properties of page elements) from test logic.
51
52
 
52
- How to use this?
53
+ ### How to use this?
53
54
 
54
- - Add `gem 'Web4Cucumber'` to you Gemfile and run `bundle install`
55
- - In your project in one of your lib/*.rb files add `require "Web4Cucumber"` and inherit your own class from Web4Cucumber one, like this:
55
+ - Add `gem 'web4cucumber'` to you Gemfile and run `bundle install`
56
+ - In your project in one of your lib/*.rb files add `require "web4cucumber"` and inherit your own class from Web4Cucumber one, like this:
56
57
  ```
57
58
  class Web < Web4Cucumber
58
59
  def initialize(options)
@@ -62,7 +63,7 @@ class Web < Web4Cucumber
62
63
  end
63
64
  ```
64
65
 
65
- - In your features/support/env.rb in Before hook instatiate your beautiful class:
66
+ - In your features/support/env.rb in Before hook instantiate your beautiful class:
66
67
  ```
67
68
  options = {
68
69
  :base_url => "http://base_url_of_your_project",
@@ -70,7 +71,7 @@ end
70
71
  :rules_path => "path_to_the_folder_with_your_yaml_files",
71
72
  :logger => @logger
72
73
  # You need to pass an object that will do the logging for you. I believe you have it implemented.
73
- # If not, please take a look in the examples/testproject folder.
74
+ # If not, please take a look at the examples/testproject/lib/logger.rb.
74
75
  }
75
76
  @web = Web.new(options)
76
77
 
@@ -179,6 +180,7 @@ pp @result
179
180
  ```
180
181
  If something went wrong and the webdriver was unable to find some checkpoints or other fields described in the yaml file, then the @result[:result] would be changed to *false* and @result[:failed_positive_checkpoints] array will be populated with the elements that were not found, @result[:failed_negative_checkpoints] - with elements you described in *negative_checkpoints* and @result[:errors] - with exception messages. Also, a *screenshots* folder will be created in your working directory, containing browser screenshot of the page that caught an error.
181
182
 
183
+ ### Yaml file structure
182
184
  Now we have to master yaml file creation in details.
183
185
  The structure of yaml files supported by Web4Cucumber library is quite flexible. You could store page descriptions separately from action descriptions, or you could store all your actions in one files, only make sure each action has a precide list of corresponding pages in exactly the same order that they appear during action execution. Besides list of pages only one keyword is supported under an action:
184
186
  *final_checkpoints*. This is a list of elements whose presence we expect once the action is finished.
@@ -136,10 +136,6 @@ class Web4Cucumber
136
136
  @result[:errors] << "Execution stopped at page #{page}"
137
137
  return @result
138
138
  end
139
- # sometimes also it is pretty handy to be able to stick the debugger at
140
- # some point to have a human control over the webdriver instance. Then
141
- # in the same way stick the :debug_at keyword with the page name as a value
142
- # into the options hash. The webdriver is available via @@b clas variable
143
139
  page_rules = rules[page.to_sym]
144
140
  unless page_rules
145
141
  @@logger.warn("The page #{page} not found in #{key} yaml file, maybe you have wrong yaml format...")
@@ -185,6 +181,10 @@ class Web4Cucumber
185
181
  sleep page_rules[:sleep]
186
182
  end
187
183
  driver = check_iframe(page_rules) # substitute browser operating with main html
184
+ # sometimes also it is pretty handy to be able to stick the debugger at
185
+ # some point to have a human control over the webdriver instance. Then
186
+ # in the same way stick the :debug_at keyword with the page name as a value
187
+ # into the options hash. The webdriver is available via @@b clas variable
188
188
  if options.has_key?(:debug_at) and options[:stop_at] == page
189
189
  require "byebug"
190
190
  byebug
@@ -283,14 +283,21 @@ class Web4Cucumber
283
283
  elsif ['textfield', 'text_field', 'text_area', 'textarea'].include? prop[:type]
284
284
  element.clear
285
285
  if options.has_key? name.to_sym
286
- options[name.to_sym].each_char do |c|
287
- element.append c
286
+ if options.has_key? :characterwise
287
+ options[name.to_sym].each_char do |c|
288
+ element.append c
289
+ end
290
+ else
291
+ element.send_keys options[name.to_sym]
288
292
  end
293
+
289
294
  elsif prop.has_key? :def_value
290
295
  element.send_keys prop[:def_value]
291
296
  else
292
297
  @@logger.error("Please provide the value for this element: #{prop}")
293
298
  end
299
+ else
300
+ element.click
294
301
  end
295
302
  rescue => e
296
303
  screenshot_save
@@ -1,3 +1,3 @@
1
1
  module Web4Cucumber
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.authors = ["Oleg Fayans"]
13
13
  s.email = ["ofajans@gmail.com"]
14
14
  s.homepage = "https://github.com/ofayans/web4cuke"
15
- s.license = "GPLv3"
15
+ s.license = "LGPL"
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.require_paths = ["lib"]
18
18
  s.required_ruby_version = '~> 2.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web4cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Fayans
@@ -105,7 +105,7 @@ files:
105
105
  - web4cucumber.gemspec
106
106
  homepage: https://github.com/ofayans/web4cuke
107
107
  licenses:
108
- - GPLv3
108
+ - LGPL
109
109
  metadata: {}
110
110
  post_install_message:
111
111
  rdoc_options: []