gridium 0.1.13 → 0.1.14

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: 6fec07d25a93f098b5f9884acddaf67e9a9ccaed
4
- data.tar.gz: 5a154126fe615efef0a449a076d1df2d71dbcb60
3
+ metadata.gz: d7f8f12e48945bbc10f2440aa12963fc0e6bf6b9
4
+ data.tar.gz: 9cbbb726e13c56f5bd99c4d4adad213eff7e93e0
5
5
  SHA512:
6
- metadata.gz: 4b116efab19c1c28cb8aa91a77657a491b45dbc015026a503de771092fe1ab4577c985d0672a66e53214f19276b251250e1bcf0a33e2c568647e72e416b8d6f4
7
- data.tar.gz: 1e9167032c94306bddfe38a6ae1725d570f68235e73beaa30f0e23cbf383773c4452b600ef8bfd61ab848ca9997124ed64db33d8dbb11685b8a84ca86748956f
6
+ metadata.gz: cb5291417e0fdfc52eefe30891677d63834043fbe65944b24d663b3d3c69b9a40131f04fab065e8d22bbef47bbcf8795a02ea320f0ea00297577b1d47efa41aa
7
+ data.tar.gz: 08715dc6b3c5b902cbba1eb865da0102876db1325947f75eea853de42fcab7fa3b003b37ea2a73f884c856a5f514a2b8d4a8807614ca9c51385e73d324343ca1
data/gridium.gemspec CHANGED
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
33
 
34
34
  spec.add_runtime_dependency "selenium-webdriver", "~> 2.50.0"
35
- spec.add_runtime_dependency "oily_png", "~> 1.1", ">= 1.1.2"
35
+ spec.add_runtime_dependency "oily_png", "~> 1.2"
36
36
 
37
37
  end
data/lib/element.rb CHANGED
@@ -9,6 +9,7 @@ class Element
9
9
  @name = name
10
10
  @by = by
11
11
  @locator = locator
12
+ @element_screenshot = nil #used to store the path of element screenshots for comparison
12
13
 
13
14
  # wrapped driver
14
15
  @driver = Driver.driver
@@ -239,9 +240,48 @@ class Element
239
240
  image2 = image1.to_image
240
241
  element_screenshot_path = File.join($current_run_dir, "#{name}__#{timestamp}.png")
241
242
  image2.save(element_screenshot_path)
243
+ @element_screenshot = element_screenshot_path
242
244
  SpecData.screenshots_captured.push("#{name}__#{timestamp}.png")
243
245
  end
244
246
 
247
+ def compare_element_screenshot(base_image_path)
248
+ #Returns TRUE if there are no differences, FALSE if there are
249
+ begin
250
+ Log.debug("Doing Image Comparison...")
251
+ images = [
252
+ ChunkyPNG::Image.from_file(base_image_path),
253
+ ChunkyPNG::Image.from_file(@element_screenshot)
254
+ ]
255
+ #used to store image x,y diff
256
+ diff = []
257
+ Log.debug("Loaded Images into array...")
258
+ images.first.height.times do |y|
259
+ images.first.row(y).each_with_index do |pixel, x|
260
+ diff << [x,y] unless pixel == images.last[x,y]
261
+ end
262
+ end
263
+
264
+ Log.debug("Pixels total: #{images.first.pixels.length}")
265
+ Log.debug("Pixels changed: #{diff.length}")
266
+ Log.debug("Pixels changed: #{(diff.length.to_f / images.first.pixels.length) * 100}%")
267
+
268
+ x, y = diff.map{|xy| xy[0]}, diff.map{|xy| xy[1]}
269
+
270
+ if x.any? && y.any?
271
+ name = self.name.gsub(' ', '_')
272
+ #timestamp = Time.now.strftime("%Y_%m_%d__%H_%M_%S")
273
+ element_screenshot_path = File.join($current_run_dir, "#{name}__diff_.png")
274
+ images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color(0,255,0))
275
+ images.last.save(element_screenshot_path)
276
+ return false
277
+ else
278
+ return true
279
+ end
280
+ rescue Exception => e
281
+ Log.error("There was a problem comparing element images. #{e.to_s}")
282
+ end
283
+ end
284
+
245
285
  def method_missing(method_sym, *arguments, &block)
246
286
  Log.debug("called #{method_sym} on element #{@locator} by #{@by_type}")
247
287
  if @element.respond_to?(method_sym)
@@ -1,3 +1,3 @@
1
1
  module Gridium
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-11 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,20 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.1'
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: 1.1.2
75
+ version: '1.2'
79
76
  type: :runtime
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
80
  - - "~>"
84
81
  - !ruby/object:Gem::Version
85
- version: '1.1'
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: 1.1.2
82
+ version: '1.2'
89
83
  description: Gridium makes integrating ruby and Selenium a breeze. This is not for
90
84
  novice automation engineers. Novices should checkout Capybara. However, if you're
91
85
  comfortable with Selenium, and have used Capybara but find it not working well give