sapphire 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +190 -190
  2. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +34 -45
  3. data/lib/sapphire/DSL/Browser/Extensions/Class.rb +29 -0
  4. data/lib/sapphire/DSL/Browser/Extensions/Hash.rb +11 -0
  5. data/lib/sapphire/DSL/Browser/Extensions/Numeric.rb +7 -0
  6. data/lib/sapphire/DSL/Browser/Extensions/Symbol.rb +37 -0
  7. data/lib/sapphire/DSL/Browser/{By.rb → Fluff/By.rb} +10 -10
  8. data/lib/sapphire/DSL/Browser/{To.rb → Fluff/To.rb} +10 -10
  9. data/lib/sapphire/DSL/Browser/{With.rb → Fluff/With.rb} +10 -10
  10. data/lib/sapphire/DSL/Browser/For.rb +10 -10
  11. data/lib/sapphire/DSL/Browser/{AlertBox.rb → Nouns/AlertBox.rb} +14 -14
  12. data/lib/sapphire/DSL/Browser/{Browser.rb → Nouns/Browser.rb} +17 -17
  13. data/lib/sapphire/DSL/Browser/{Day.rb → Nouns/Day.rb} +24 -24
  14. data/lib/sapphire/DSL/Browser/{Keys → Nouns}/Enter.rb +10 -10
  15. data/lib/sapphire/DSL/Browser/{Month.rb → Nouns/Month.rb} +24 -24
  16. data/lib/sapphire/DSL/Browser/{Popup.rb → Nouns/Popup.rb} +0 -0
  17. data/lib/sapphire/DSL/Browser/Should.rb +42 -42
  18. data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
  19. data/lib/sapphire/DSL/Browser/{Accept.rb → Verbs/Accept.rb} +9 -9
  20. data/lib/sapphire/DSL/Browser/Verbs/Check.rb +11 -0
  21. data/lib/sapphire/DSL/Browser/{IsHidden.rb → Verbs/Clear.rb} +9 -10
  22. data/lib/sapphire/DSL/Browser/Verbs/Click.rb +11 -0
  23. data/lib/sapphire/DSL/Browser/{Close.rb → Verbs/Close.rb} +11 -12
  24. data/lib/sapphire/DSL/Browser/{Compare.rb → Verbs/Compare.rb} +18 -18
  25. data/lib/sapphire/DSL/Browser/Verbs/Complete.rb +10 -0
  26. data/lib/sapphire/DSL/Browser/{Differ.rb → Verbs/Differ.rb} +18 -18
  27. data/lib/sapphire/DSL/Browser/{Disable.rb → Verbs/Disable.rb} +0 -0
  28. data/lib/sapphire/DSL/Browser/{Error.rb → Verbs/Error.rb} +25 -26
  29. data/lib/sapphire/DSL/Browser/{Exists.rb → Verbs/Exists.rb} +22 -22
  30. data/lib/sapphire/DSL/Browser/{Hide.rb → Verbs/Hide.rb} +25 -26
  31. data/lib/sapphire/DSL/Browser/Verbs/MouseOver.rb +11 -0
  32. data/lib/sapphire/DSL/Browser/{Navigate.rb → Verbs/Navigate.rb} +11 -11
  33. data/lib/sapphire/DSL/Browser/{Press.rb → Verbs/Press.rb} +8 -10
  34. data/lib/sapphire/DSL/Browser/{Reload.rb → Verbs/Reload.rb} +11 -11
  35. data/lib/sapphire/DSL/Browser/Verbs/Set.rb +10 -0
  36. data/lib/sapphire/DSL/Browser/{Show.rb → Verbs/Show.rb} +25 -26
  37. data/lib/sapphire/DSL/Browser/{Start.rb → Verbs/Start.rb} +16 -16
  38. data/lib/sapphire/DSL/Browser/{Switch.rb → Verbs/Switch.rb} +0 -0
  39. data/lib/sapphire/DSL/Browser/{Transition.rb → Verbs/Transition.rb} +25 -26
  40. data/lib/sapphire/DSL/Browser/Verbs/Uncheck.rb +11 -0
  41. data/lib/sapphire/DSL/Browser/{Virtually.rb → Verbs/Virtually.rb} +0 -0
  42. data/lib/sapphire/DSL/Browser/{Wait.rb → Verbs/Wait.rb} +2 -2
  43. data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
  44. data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
  45. data/lib/sapphire/DSL/Configuration/Use.rb +15 -15
  46. data/lib/sapphire/DSL/Data/Exist.rb +27 -27
  47. data/lib/sapphire/DSL/Data/Find.rb +10 -10
  48. data/lib/sapphire/DSL/Data/GetPageField.rb +17 -17
  49. data/lib/sapphire/DSL/Data/Underscore.rb +8 -8
  50. data/lib/sapphire/DSL/Data/Validate.rb +26 -26
  51. data/lib/sapphire/DSL/Data/Verify.rb +10 -10
  52. data/lib/sapphire/DSL/Scenarios/Is.rb +9 -9
  53. data/lib/sapphire/DSL/Scenarios/Pending.rb +28 -28
  54. data/lib/sapphire/DSL/Scenarios/and.rb +25 -25
  55. data/lib/sapphire/DSL/Scenarios/background.rb +33 -33
  56. data/lib/sapphire/DSL/Scenarios/dsl.rb +59 -59
  57. data/lib/sapphire/DSL/Scenarios/finally.rb +33 -33
  58. data/lib/sapphire/DSL/Scenarios/given.rb +57 -57
  59. data/lib/sapphire/DSL/Scenarios/runner.rb +40 -40
  60. data/lib/sapphire/DSL/Scenarios/scenario.rb +53 -53
  61. data/lib/sapphire/DSL/Scenarios/then.rb +34 -34
  62. data/lib/sapphire/DSL/Scenarios/when.rb +47 -47
  63. data/lib/sapphire/DSL.rb +10 -6
  64. data/lib/sapphire/Data.rb +1 -1
  65. data/lib/sapphire/DataAbstractions/Database.rb +57 -57
  66. data/lib/sapphire/DataAbstractions/Query.rb +19 -19
  67. data/lib/sapphire/JobAbstractions/Job.rb +32 -32
  68. data/lib/sapphire/Strategies/ClassStrategy.rb +1 -1
  69. data/lib/sapphire/Strategies/Strategy.rb +1 -2
  70. data/lib/sapphire/Strategies.rb +1 -1
  71. data/lib/sapphire/TeamCity.rb +8 -8
  72. data/lib/sapphire/Testing/Executable.rb +30 -30
  73. data/lib/sapphire/Testing/RakeTask.rb +108 -108
  74. data/lib/sapphire/Testing/ResultList.rb +18 -18
  75. data/lib/sapphire/Testing/ResultTree.rb +44 -44
  76. data/lib/sapphire/Testing/ScenarioResult.rb +36 -36
  77. data/lib/sapphire/Testing/TestResult.rb +21 -21
  78. data/lib/sapphire/Testing/TestRunnerAdapter.rb +69 -69
  79. data/lib/sapphire/Testing.rb +2 -2
  80. data/lib/sapphire/Virtualization.rb +7 -7
  81. data/lib/sapphire/Web.rb +2 -2
  82. data/lib/sapphire/WebAbstractions/Browsers/Chrome.rb +21 -21
  83. data/lib/sapphire/WebAbstractions/Browsers/FireFox.rb +22 -22
  84. data/lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb +21 -21
  85. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +58 -59
  86. data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +61 -62
  87. data/lib/sapphire/WebAbstractions/Controls/Button.rb +7 -9
  88. data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -28
  89. data/lib/sapphire/WebAbstractions/Controls/Date.rb +11 -11
  90. data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +26 -26
  91. data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
  92. data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -9
  93. data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
  94. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -18
  95. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -31
  96. data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
  97. data/lib/sapphire/version.rb +3 -3
  98. data/lib/sapphire.rb +38 -38
  99. metadata +46 -45
  100. data/lib/sapphire/DSL/Browser/Check.rb +0 -12
  101. data/lib/sapphire/DSL/Browser/Clear.rb +0 -13
  102. data/lib/sapphire/DSL/Browser/Click.rb +0 -12
  103. data/lib/sapphire/DSL/Browser/Complete.rb +0 -15
  104. data/lib/sapphire/DSL/Browser/CurrentUrl.rb +0 -11
  105. data/lib/sapphire/DSL/Browser/IsVisible.rb +0 -33
  106. data/lib/sapphire/DSL/Browser/MouseOver.rb +0 -12
  107. data/lib/sapphire/DSL/Browser/Set.rb +0 -18
  108. data/lib/sapphire/DSL/Browser/Uncheck.rb +0 -12
@@ -1,19 +1,19 @@
1
- module Sapphire
2
- module Testing
3
- class ResultsList
4
-
5
- attr_reader :myId
6
- attr_reader :text
7
- attr_reader :children
8
-
9
- def initialize(text, results, id)
10
- @myId = id
11
- @text = text
12
- @children = results
13
- @expanded = true
14
- @count = results.length
15
- end
16
-
17
- end
18
- end
1
+ module Sapphire
2
+ module Testing
3
+ class ResultsList
4
+
5
+ attr_reader :myId
6
+ attr_reader :text
7
+ attr_reader :children
8
+
9
+ def initialize(text, results, id)
10
+ @myId = id
11
+ @text = text
12
+ @children = results
13
+ @expanded = true
14
+ @count = results.length
15
+ end
16
+
17
+ end
18
+ end
19
19
  end
@@ -1,44 +1,44 @@
1
- module Sapphire
2
- module Testing
3
- class ResultTree
4
-
5
- attr_accessor :results
6
- attr_accessor :type
7
- attr_accessor :text
8
- attr_accessor :messages
9
- attr_accessor :stack
10
- attr_accessor :time
11
- attr_accessor :parent
12
- attr_accessor :item
13
-
14
- def initialize(text, result)
15
-
16
- @type = 'pass'
17
- @time = 0
18
-
19
- if(result != nil)
20
- self.type = result.type
21
- @iconCls = "accept" if result.type == "pass"
22
- @iconCls = "delete" if result.type == "fail"
23
- @iconCls = "error" if result.type == "pending"
24
- @time = result.execution_time
25
- @expanded = true
26
- @messages = result.messages
27
- @stack = result.stack
28
- end
29
- @text = text
30
- @results = []
31
- @leaf = true
32
-
33
- end
34
-
35
- def AddChild(node)
36
- node.parent = self
37
- @results << node
38
- @leaf = false
39
- end
40
-
41
- end
42
- end
43
- end
44
-
1
+ module Sapphire
2
+ module Testing
3
+ class ResultTree
4
+
5
+ attr_accessor :results
6
+ attr_accessor :type
7
+ attr_accessor :text
8
+ attr_accessor :messages
9
+ attr_accessor :stack
10
+ attr_accessor :time
11
+ attr_accessor :parent
12
+ attr_accessor :item
13
+
14
+ def initialize(text, result)
15
+
16
+ @type = 'pass'
17
+ @time = 0
18
+
19
+ if(result != nil)
20
+ self.type = result.type
21
+ @iconCls = "accept" if result.type == "pass"
22
+ @iconCls = "delete" if result.type == "fail"
23
+ @iconCls = "error" if result.type == "pending"
24
+ @time = result.execution_time
25
+ @expanded = true
26
+ @messages = result.messages
27
+ @stack = result.stack
28
+ end
29
+ @text = text
30
+ @results = []
31
+ @leaf = true
32
+
33
+ end
34
+
35
+ def AddChild(node)
36
+ node.parent = self
37
+ @results << node
38
+ @leaf = false
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+
@@ -1,36 +1,36 @@
1
- module Sapphire
2
- module Testing
3
- class ScenarioResult
4
-
5
- attr_reader :results
6
- attr_accessor :myId
7
- attr_reader :type
8
- attr_reader :time
9
- attr_reader :parent
10
-
11
- def initialize(text)
12
- @text = text
13
- @results = []
14
- @leaf = true
15
- @myId = -1
16
- @type = 'pass'
17
- @time = 0
18
- end
19
-
20
- def AddChild(result)
21
- result.parent = self
22
- @results << result
23
- @time += result.time
24
- end
25
-
26
- def set_id(id)
27
- @myId = id
28
- end
29
-
30
- def set_type(type)
31
- @type = type
32
- end
33
-
34
- end
35
- end
36
- end
1
+ module Sapphire
2
+ module Testing
3
+ class ScenarioResult
4
+
5
+ attr_reader :results
6
+ attr_accessor :myId
7
+ attr_reader :type
8
+ attr_reader :time
9
+ attr_reader :parent
10
+
11
+ def initialize(text)
12
+ @text = text
13
+ @results = []
14
+ @leaf = true
15
+ @myId = -1
16
+ @type = 'pass'
17
+ @time = 0
18
+ end
19
+
20
+ def AddChild(result)
21
+ result.parent = self
22
+ @results << result
23
+ @time += result.time
24
+ end
25
+
26
+ def set_id(id)
27
+ @myId = id
28
+ end
29
+
30
+ def set_type(type)
31
+ @type = type
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -1,22 +1,22 @@
1
- module Sapphire
2
- module Testing
3
- class TestResult
4
-
5
- attr_reader :execution_time
6
- attr_reader :message
7
- attr_reader :item
8
- attr_reader :type
9
- attr_reader :stack
10
- attr_reader :messages
11
-
12
- def initialize(type, item, message, stack, execution_time)
13
- @item = item
14
- @execution_time = execution_time
15
- @messages = message
16
- @stack = stack
17
- @type = type
18
- end
19
-
20
- end
21
- end
1
+ module Sapphire
2
+ module Testing
3
+ class TestResult
4
+
5
+ attr_reader :execution_time
6
+ attr_reader :message
7
+ attr_reader :item
8
+ attr_reader :type
9
+ attr_reader :stack
10
+ attr_reader :messages
11
+
12
+ def initialize(type, item, message, stack, execution_time)
13
+ @item = item
14
+ @execution_time = execution_time
15
+ @messages = message
16
+ @stack = stack
17
+ @type = type
18
+ end
19
+
20
+ end
21
+ end
22
22
  end
@@ -1,69 +1,69 @@
1
- module Sapphire
2
- module Testing
3
- module TestRunnerAdapter
4
-
5
- def execute(reporter)
6
- reporter.ScenarioStart self
7
-
8
- self.backgrounds.each do |b|
9
-
10
- b.execute reporter
11
-
12
- b.and.each do |g_a|
13
-
14
- g_a.execute reporter
15
-
16
- end
17
-
18
- end
19
-
20
- self.givens.each do |g|
21
- g.when.each do |w|
22
-
23
- g.execute reporter
24
-
25
- g.and.each do |g_a|
26
-
27
- g_a.execute reporter
28
-
29
- end
30
-
31
- w.execute reporter
32
-
33
- w.and.each do |w_a|
34
-
35
- w_a.execute reporter
36
-
37
- end
38
-
39
- w.then.each do |t|
40
-
41
- t.execute reporter
42
-
43
- t.and.each do |t_a|
44
-
45
- t_a.execute reporter
46
-
47
- end
48
-
49
- end
50
-
51
- end
52
-
53
- if(g.finally)
54
-
55
- g.finally.execute reporter
56
-
57
- end
58
-
59
- end
60
-
61
- reporter.ScenarioComplete self
62
-
63
- end
64
- end
65
- end
66
- end
67
-
68
-
69
-
1
+ module Sapphire
2
+ module Testing
3
+ module TestRunnerAdapter
4
+
5
+ def execute(reporter)
6
+ reporter.ScenarioStart self
7
+
8
+ self.backgrounds.each do |b|
9
+
10
+ b.execute reporter
11
+
12
+ b.and.each do |g_a|
13
+
14
+ g_a.execute reporter
15
+
16
+ end
17
+
18
+ end
19
+
20
+ self.givens.each do |g|
21
+ g.when.each do |w|
22
+
23
+ g.execute reporter
24
+
25
+ g.and.each do |g_a|
26
+
27
+ g_a.execute reporter
28
+
29
+ end
30
+
31
+ w.execute reporter
32
+
33
+ w.and.each do |w_a|
34
+
35
+ w_a.execute reporter
36
+
37
+ end
38
+
39
+ w.then.each do |t|
40
+
41
+ t.execute reporter
42
+
43
+ t.and.each do |t_a|
44
+
45
+ t_a.execute reporter
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ if(g.finally)
54
+
55
+ g.finally.execute reporter
56
+
57
+ end
58
+
59
+ end
60
+
61
+ reporter.ScenarioComplete self
62
+
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+
69
+
@@ -1,2 +1,2 @@
1
- require File.expand_path(File.dirname(__FILE__) +'/Testing/Reporter.rb', __FILE__)
2
- Dir[File.dirname(__FILE__) + '/Testing/*.rb'].each {|file| require file }
1
+ require File.expand_path(File.dirname(__FILE__) +'/Testing/Reporter.rb', __FILE__)
2
+ Dir[File.dirname(__FILE__) + '/Testing/*.rb'].each {|file| require file }
@@ -1,8 +1,8 @@
1
- require File.expand_path(File.dirname(__FILE__) +'/UI/Functions.rb', File.dirname(__FILE__)) if Platform::OS == :win32
2
- require File.expand_path(File.dirname(__FILE__) +'/UI/VirtualUI.rb', File.dirname(__FILE__)) if Platform::OS == :win32
3
-
4
- module Sapphire
5
- module UI
6
-
7
- end
1
+ require File.expand_path(File.dirname(__FILE__) +'/UI/Functions.rb', File.dirname(__FILE__)) if Platform::OS == :win32
2
+ require File.expand_path(File.dirname(__FILE__) +'/UI/VirtualUI.rb', File.dirname(__FILE__)) if Platform::OS == :win32
3
+
4
+ module Sapphire
5
+ module UI
6
+
7
+ end
8
8
  end
data/lib/sapphire/Web.rb CHANGED
@@ -1,3 +1,3 @@
1
- Dir[File.dirname(__FILE__) + '/WebAbstractions/Controls/Base/*.rb'].each {|file| require file }
2
- Dir[File.dirname(__FILE__) + '/WebAbstractions/Controls/*.rb'].each {|file| require file }
1
+ Dir[File.dirname(__FILE__) + '/WebAbstractions/Controls/Base/*.rb'].each {|file| require file }
2
+ Dir[File.dirname(__FILE__) + '/WebAbstractions/Controls/*.rb'].each {|file| require file }
3
3
  Dir[File.dirname(__FILE__) + '/WebAbstractions/Browsers/*.rb'].each {|file| require file }
@@ -1,21 +1,21 @@
1
- module Sapphire
2
- module WebAbstractions
3
- def Chrome(url)
4
- ChromeBrowser.new
5
- end
6
-
7
- class ChromeBrowser
8
- include RubySeleniumWebDriver
9
-
10
- attr_reader :browser
11
-
12
- def initialize()
13
- @browser = self.Create :chrome
14
- super @browser
15
- $browser = self
16
- end
17
- end
18
- end
19
- end
20
-
21
-
1
+ module Sapphire
2
+ module WebAbstractions
3
+ def Chrome(url)
4
+ ChromeBrowser.new
5
+ end
6
+
7
+ class ChromeBrowser
8
+ include RubySeleniumWebDriver
9
+
10
+ attr_reader :browser
11
+
12
+ def initialize()
13
+ @browser = self.Create :chrome
14
+ super @browser
15
+ $browser = self
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+
@@ -1,22 +1,22 @@
1
- module Sapphire
2
- module WebAbstractions
3
- class FireFoxBrowser
4
- include RubySeleniumWebDriver
5
-
6
- attr_reader :browser
7
-
8
- def initialize()
9
- @browser = self.Create :firefox
10
- super(@browser)
11
- $browser = self
12
- end
13
-
14
- end
15
-
16
- def FireFox(url)
17
- FireFoxBrowser.new
18
- end
19
- end
20
- end
21
-
22
-
1
+ module Sapphire
2
+ module WebAbstractions
3
+ class FireFoxBrowser
4
+ include RubySeleniumWebDriver
5
+
6
+ attr_reader :browser
7
+
8
+ def initialize()
9
+ @browser = self.Create :firefox
10
+ super(@browser)
11
+ $browser = self
12
+ end
13
+
14
+ end
15
+
16
+ def FireFox(url)
17
+ FireFoxBrowser.new
18
+ end
19
+ end
20
+ end
21
+
22
+
@@ -1,21 +1,21 @@
1
- module Sapphire
2
- module WebAbstractions
3
- def InternetExplorer(url)
4
- driver = InternetExplorerBrowser.new
5
- driver
6
- end
7
-
8
- class InternetExplorerBrowser
9
- include RubySeleniumWebDriver
10
-
11
- attr_reader :browser
12
-
13
- def initialize
14
- @browser = self.Create :ie
15
- super(@browser)
16
- $browser = self
17
- end
18
- end
19
- end
20
- end
21
-
1
+ module Sapphire
2
+ module WebAbstractions
3
+ def InternetExplorer(url)
4
+ driver = InternetExplorerBrowser.new
5
+ driver
6
+ end
7
+
8
+ class InternetExplorerBrowser
9
+ include RubySeleniumWebDriver
10
+
11
+ attr_reader :browser
12
+
13
+ def initialize
14
+ @browser = self.Create :ie
15
+ super(@browser)
16
+ $browser = self
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -1,59 +1,58 @@
1
- module Sapphire
2
- module WebAbstractions
3
- class Control
4
- def initialize(browser, hash)
5
- @browser = browser
6
- @hash = hash
7
- end
8
-
9
- def Find
10
- @browser.FindItem(@hash)
11
- end
12
-
13
- def FindAll
14
- @browser.FindAllItems(@hash)
15
- end
16
-
17
- def FindWithoutWait
18
- @browser.FindElement @hash[0].keys.first, @hash[0].fetch(@hash[0].keys.first)
19
- end
20
-
21
- def Text
22
- text = self.Find
23
- text.text
24
- end
25
-
26
- def Click
27
- control = self.Find
28
- control.click
29
- end
30
-
31
- def MouseOver
32
- if @hash.is_a? Hash
33
- if(@hash.has_key?(:id))
34
- @browser.ExecuteScript("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
35
- elsif (@hash.has_key?(:name))
36
- @browser.ExecuteScript("document.getElementByName('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
37
- elsif (@hash.has_key?(:xpath))
38
- @browser.ExecuteScript("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
39
- end
40
- elsif @hash.is_a? Array
41
- if(@hash[0].has_key?(:id))
42
- @browser.ExecuteScript("document.getElementById('"+ @hash[0].fetch(:id) +"').style.visibility = 'visible'; ")
43
- elsif (@hash[0].has_key?(:name))
44
- @browser.ExecuteScript("document.getElementByName('"+ @hash[0].fetch(:name) +"').style.visibility = 'visible'; ")
45
- elsif (@hash[0].has_key?(:xpath))
46
- @browser.ExecuteScript("document.evaluate( '" + @hash[0].fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
47
- end
48
- end
49
-
50
- sleep(1)
51
- end
52
-
53
- def Equals(value)
54
- Evaluation.new(self.Text, value)
55
- end
56
- end
57
- end
58
- end
59
-
1
+ module Sapphire
2
+ module WebAbstractions
3
+ class Control
4
+ def initialize(hash)
5
+ @hash = hash
6
+ end
7
+
8
+ def Find
9
+ $browser.FindItem(@hash)
10
+ end
11
+
12
+ def FindAll
13
+ $browser.FindAllItems(@hash)
14
+ end
15
+
16
+ def FindWithoutWait
17
+ $browser.FindElement @hash[0].keys.first, @hash[0].fetch(@hash[0].keys.first)
18
+ end
19
+
20
+ def Text
21
+ text = self.Find
22
+ text.text
23
+ end
24
+
25
+ def Click
26
+ control = self.Find
27
+ control.click
28
+ end
29
+
30
+ def MouseOver
31
+ if @hash.is_a? Hash
32
+ if(@hash.has_key?(:id))
33
+ $browser.ExecuteScript("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
34
+ elsif (@hash.has_key?(:name))
35
+ $browser.ExecuteScript("document.getElementByName('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
36
+ elsif (@hash.has_key?(:xpath))
37
+ $browser.ExecuteScript("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
38
+ end
39
+ elsif @hash.is_a? Array
40
+ if(@hash[0].has_key?(:id))
41
+ $browser.ExecuteScript("document.getElementById('"+ @hash[0].fetch(:id) +"').style.visibility = 'visible'; ")
42
+ elsif (@hash[0].has_key?(:name))
43
+ $browser.ExecuteScript("document.getElementByName('"+ @hash[0].fetch(:name) +"').style.visibility = 'visible'; ")
44
+ elsif (@hash[0].has_key?(:xpath))
45
+ $browser.ExecuteScript("document.evaluate( '" + @hash[0].fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
46
+ end
47
+ end
48
+
49
+ sleep(1)
50
+ end
51
+
52
+ def Equals(value)
53
+ Evaluation.new(self.Text, value)
54
+ end
55
+ end
56
+ end
57
+ end
58
+