web4cucumber 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73cd68b1548d1653412dac11675eff0e1f47c50c
4
- data.tar.gz: 3be0f48e3462862711fa4d473ea9fe6d1141d47e
3
+ metadata.gz: 09f2ae8b4f38c4ce225c93a487a25e6c30d2dd6c
4
+ data.tar.gz: 5099fd51931bc779bd8fac847b47791036b28995
5
5
  SHA512:
6
- metadata.gz: bdf0b758d5dfc32be4d32c44104b7f5ddea281cfdf06cdc01234ad3d5b82b4c8306676f2be907cea3f93d2e2c6e5d78ef0f4041b30b57c3eee71f15f640fcf1c
7
- data.tar.gz: 032a4a7c1bd560fdd6da51d61abebbb9d035a4cf1f9949ff3c7603df23b4126e58e776c7f89590b29d2df3c5b4099629c48ec1399fa544b60df6cde51c1d6ed9
6
+ metadata.gz: 58b42e5b1452ba7bf297b4f393719529c6231e2da1b3b511c454e8474666ec23e1fb469c763d352ed9bc73f8c7bd86b4333f026a864248c0bdc3c68f3a88515a
7
+ data.tar.gz: 20f5be395473dc40e1f0b8d26d71772a7fd85a894dea7d58d3695c31fad4bd63bb10118bbfb28c95e6f924ed9c0d2caaed04ae404e2d051e52e7f9fd6196c4d7
data/lib/web4cucumber.rb CHANGED
@@ -118,7 +118,10 @@ class Web4Cucumber
118
118
  end
119
119
 
120
120
  def run_action(key, options)
121
- @result = {:result=>true, :failed_positive_checkpoints=>[], :failed_negative_checkpoints=>[], :errors => []}
121
+ @result = {:result=>true,
122
+ :failed_positive_checkpoints=>[],
123
+ :failed_negative_checkpoints=>[],
124
+ :errors => []}
122
125
  @@rules.freeze
123
126
  rules = Marshal.load(Marshal.dump(@@rules))
124
127
  action_rules = rules[key.to_sym]
@@ -196,16 +199,17 @@ class Web4Cucumber
196
199
  if page_rules.has_key? :expected_fields
197
200
  page_rules[:expected_fields].each_pair { |name, prop|
198
201
  # Beginning of page fields
199
- # The following allows you to put <value> as a selector value
202
+ # You can use anyone of provided options as a part of selector
203
+ # string. For example
200
204
  # :select_item:
201
205
  # :selector:
202
- # :text: 'Some text <value>'
203
- # and then pass the value in options
204
- prop[:selector].each do |propkey, propval|
205
- if propval.match Regexp.new("<value>")
206
- prop[:selector][propkey] = propval.gsub('<value>', options[name])
206
+ # :text: 'Some text <passme>'
207
+ # Do not forget to pass :passme key with value in options hash
208
+ options.keys.each do |optkey|
209
+ if prop[:selector].values[0].include? "<#{optkey}>"
210
+ prop[:selector].values[0].gsub!("<#{optkey}>", options[optkey])
207
211
  end
208
- end
212
+ end
209
213
  possible_elements = {
210
214
  # There could be more than one element with the same
211
215
  # properties and only one would be visible. As an example:
@@ -263,7 +267,7 @@ class Web4Cucumber
263
267
  end
264
268
  end
265
269
  if not element
266
- if not prop[:may_absent]
270
+ if not prop[:may_absent] and not page_rules.has_key? :may_absent
267
271
  @result[:result] = false
268
272
  @result[:errors] << "Unable to find element #{name.to_s} by the following #{prop[:selector].keys[0].to_s}: #{prop[:selector].values[0]}"
269
273
  end
@@ -371,12 +375,22 @@ class Web4Cucumber
371
375
  end
372
376
  button.click
373
377
  rescue Exception => e
374
- @result[:result]=false
375
- @result[:errors] << e.message
376
- screenshot_save
378
+ unless page_rules.has_key? :may_absent
379
+ @result[:result]=false
380
+ @result[:errors] << e.message
381
+ screenshot_save
382
+ end
377
383
  end
378
384
  elsif page_rules[:commit].has_key?(:type) and page_rules[:commit][:type] == 'alert'
379
- @@b.alert.ok
385
+ begin
386
+ @@b.alert.ok
387
+ rescue Exception => e
388
+ unless page_rules.has_key? :may_absent
389
+ @result[:result]=false
390
+ @result[:errors] << e.message
391
+ screenshot_save
392
+ end
393
+ end
380
394
  else
381
395
  raise "Please provide selector for #{page} page commit"
382
396
  end
@@ -418,7 +432,7 @@ class Web4Cucumber
418
432
  The initialize method needs to know at least the base_url you want to test against and the :rules_path - path
419
433
  to the folder where you store your yaml files with action descriptions. Other keys are optional"
420
434
  end
421
- if options.keys & obligatory_options == obligatory_options
435
+ if (options.keys & obligatory_options).sort == obligatory_options.sort
422
436
  @@base_url = options[:base_url]
423
437
  @@rules_path = options[:rules_path]
424
438
  @@logger = options[:logger]
@@ -453,6 +467,7 @@ class Web4Cucumber
453
467
  proxy = ENV["http_proxy"].scan(/[\w\.\d\_\-]+\:\d+/)[0] # to get rid of the heading "http://" that breaks the profile
454
468
  firefox_profile.proxy = chrome_profile.proxy = Selenium::WebDriver::Proxy.new({:http => proxy, :ssl => proxy})
455
469
  firefox_profile['network.proxy.no_proxies_on'] = "localhost, 127.0.0.1"
470
+ chrome_switches = %w[--proxy-bypass-list=127.0.0.1]
456
471
  ENV['no_proxy'] = '127.0.0.1'
457
472
  end
458
473
  client = Selenium::WebDriver::Remote::Http::Default.new
@@ -460,7 +475,7 @@ class Web4Cucumber
460
475
  if browser == :firefox
461
476
  @@b = Watir::Browser.new browser, :profile => firefox_profile, :http_client=>client
462
477
  elsif browser == :chrome
463
- @@b = Watir::Browser.new browser, desired_capabilities: chrome_profile
478
+ @@b = Watir::Browser.new browser, desired_capabilities: chrome_profile, switches: chrome_switches
464
479
  else
465
480
  raise "Not implemented yet"
466
481
  end
@@ -723,4 +738,25 @@ class Web4Cucumber
723
738
  def action_rules(action)
724
739
  return @@rules[action.to_sym]
725
740
  end
741
+
742
+ def checkbox_check(element, negate)
743
+ result = {:result => true,
744
+ :failed_positive_checkpoints => [],
745
+ :errors => []
746
+ }
747
+ begin
748
+ if negate
749
+ @@b.checkbox(element).clear
750
+ else
751
+ @@b.checkbox(element).set
752
+ end
753
+ rescue => e
754
+ result[:result] = false
755
+ result[:failed_positive_checkpoints] << element
756
+ result[:errors] << e.message
757
+ end
758
+ return result
759
+ end
760
+
726
761
  end
762
+
@@ -1,3 +1,3 @@
1
1
  module Web4Cucumber
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Fayans
@@ -102,6 +102,12 @@ files:
102
102
  - examples/testproject/lib/web/login.yaml
103
103
  - lib/web4cucumber.rb
104
104
  - lib/web4cucumber/version.rb
105
+ - pkg/web4cucumber-0.0.1.gem
106
+ - pkg/web4cucumber-0.0.2.gem
107
+ - pkg/web4cucumber-0.0.3.gem
108
+ - pkg/web4cucumber-0.0.4.gem
109
+ - pkg/web4cucumber-0.0.5.gem
110
+ - pkg/web4cucumber-0.0.6.gem
105
111
  - web4cucumber.gemspec
106
112
  homepage: https://github.com/ofayans/web4cuke
107
113
  licenses: