gridium 1.1.15 → 1.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/element_extensions.rb +38 -33
  3. data/lib/page.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be781c1acdb27e8949a3c4b705c15056a47c840e
4
- data.tar.gz: 9a8423051ea2983a6f76f46540359ba89d50365d
3
+ metadata.gz: c3cd34ee0c8012768432f48c83e1ad9d690f3ac7
4
+ data.tar.gz: eaa3429b997c786c47d9080e8ce0c249e6480987
5
5
  SHA512:
6
- metadata.gz: 3feeaf5b3da720bb7cb62c20c065581a440c391b111701111f7cac61b665b3f6fee7d8781d4f692f596d019ce698aa731d86eb28d032873d69a29a9f990c4f2c
7
- data.tar.gz: b01d84a824885a4fd950c435b91cb72b3ff9951a786004e609e3f71f6d45c140731448cd05a4c4f4e2a45dfd8071cd8d29c957020cd945a6cf866e1d70190ebf
6
+ metadata.gz: 054c8e990bc956d6e99041835edf9fb7c1da9fe952bff759afe4993a67634dc4b0f5478a042ccdd6d2dd8658abfff92171af27d794ab3fd9427f752094e7a0f4
7
+ data.tar.gz: e48f724a66786952f620a2e7aae6a0db5f8cd9ff2db6c830c22254a4c3466656a653a8d76df66d8161b2044a828e54be67ad4c6921605667c2a0f254580ac80e
@@ -1,44 +1,49 @@
1
1
  include Gridium
2
2
 
3
3
  class Gridium::ElementExtensions
4
- def self.highlight(element)
5
- Log.debug("[GRIDIUM::ElementExtensions] Highlighting element...")
6
- original_border = Driver.execute_script("return arguments[0].style.border", element.element)
7
- original_background = Driver.execute_script("return arguments[0].style.backgroundColor", element.element)
8
- Driver.execute_script("arguments[0].style.border='3px solid lime'; return;", element.element)
9
- Driver.execute_script("arguments[0].style.backgroundColor='lime'; return;", element.element)
10
- sleep (Gridium.config.highlight_duration)
11
- Driver.execute_script("arguments[0].style.border='" + original_border + "'; return;", element.element)
12
- Driver.execute_script("arguments[0].style.backgroundColor='" + original_background + "'; return;", element.element)
13
- end
4
+ class << self
5
+ def highlight(element)
6
+ Log.debug("[GRIDIUM::ElementExtensions] Highlighting element...")
7
+ original_border = Driver.execute_script("return arguments[0].style.border", element.element)
8
+ original_background = Driver.execute_script("return arguments[0].style.backgroundColor", element.element)
9
+ Driver.execute_script("arguments[0].style.border='3px solid lime'; return;", element.element)
10
+ Driver.execute_script("arguments[0].style.backgroundColor='lime'; return;", element.element)
11
+ sleep (Gridium.config.highlight_duration)
12
+ Driver.execute_script("arguments[0].style.border='" + original_border + "'; return;", element.element)
13
+ Driver.execute_script("arguments[0].style.backgroundColor='" + original_background + "'; return;", element.element)
14
+ end
14
15
 
15
- def self.scroll_to(element)
16
- Log.debug("[GRIDIUM::ElementExtensions] Scrolling element into view...")
17
- Driver.execute_script("arguments[0].scrollIntoView(); return;", element.element)
18
- sleep 1
19
- end
16
+ def scroll_to(element)
17
+ Log.debug("[GRIDIUM::ElementExtensions] Scrolling element into view...")
18
+ Driver.execute_script("arguments[0].scrollIntoView(); return;", element.element)
19
+ sleep 1
20
+ end
20
21
 
21
- def self.hover_over(element)
22
- Driver.execute_script("var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseover\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); arguments[0].dispatchEvent(evObj);", element.element)
23
- sleep 2
24
- end
22
+ def hover_away(element)
23
+ Driver.execute_script("var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseout\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); arguments[0].dispatchEvent(evObj);", element.element)
24
+ sleep 1
25
+ end
25
26
 
26
- def self.hover_away(element)
27
- Driver.execute_script("var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent(\"mouseout\",true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); arguments[0].dispatchEvent(evObj);", element.element)
28
- sleep 1
29
- end
27
+ #
28
+ # Mouse over the requested element at coordinate (Default x:0, y:0)
29
+ # @param [Element] element
30
+ # @param [Integer] x - element x coordinate
31
+ # @param [Integer] y - element y coordinate
32
+ #
33
+ def mouse_over(element, x: 0, y: 0)
34
+ Driver.driver.action.move_to(element.element, x, y).perform
35
+ end
30
36
 
31
- def self.mouse_over(element)
32
- Driver.driver.mouse.move_to(element.element)
33
- end
37
+ alias_method :hover_over, :mouse_over
34
38
 
35
- def self.trigger_onblur(element)
36
- Driver.execute_script("arguments[0].focus(); arguments[0].blur(); return true", element.element)
37
- end
39
+ def trigger_onblur(element)
40
+ Driver.execute_script("arguments[0].focus(); arguments[0].blur(); return true", element.element)
41
+ end
38
42
 
39
- # Occasionaly selenium is unable to click on elements in the DOM which have some
40
- # interesting React goodies around the element.
41
- def self.jquery_click(element)
42
- Driver.execute_script("arguments[0].click().change();", element.element)
43
+ # Occasionaly selenium is unable to click on elements in the DOM which have some
44
+ # interesting React goodies around the element.
45
+ def jquery_click(element)
46
+ Driver.execute_script("arguments[0].click().change();", element.element)
47
+ end
43
48
  end
44
49
  end
@@ -58,7 +58,7 @@ module Gridium
58
58
  wait = Selenium::WebDriver::Wait.new(:timeout => timeout)
59
59
  begin
60
60
  if opts[:visible]
61
- element = wait.until { Element.new("Finding text '#{text}'", :xpath, "//*[text()='#{text}']").displayed? }
61
+ element = wait.until { Element.new("Finding text '#{text}'", :xpath, "//*[text()=\"#{text}\"]").displayed? }
62
62
  else
63
63
  element = wait.until { Driver.html.include? text }
64
64
  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: 1.1.15
4
+ version: 1.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler