sapphire 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/lib/sapphire.rb +38 -37
  2. data/lib/sapphire/Adapters.rb +1 -0
  3. data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +190 -0
  4. data/lib/sapphire/DSL.rb +6 -6
  5. data/lib/sapphire/DSL/Browser/Accept.rb +9 -9
  6. data/lib/sapphire/DSL/Browser/AlertBox.rb +14 -19
  7. data/lib/sapphire/DSL/Browser/Browser.rb +17 -17
  8. data/lib/sapphire/DSL/Browser/By.rb +10 -10
  9. data/lib/sapphire/DSL/Browser/Check.rb +12 -12
  10. data/lib/sapphire/DSL/Browser/Clear.rb +12 -12
  11. data/lib/sapphire/DSL/Browser/Click.rb +12 -12
  12. data/lib/sapphire/DSL/Browser/Close.rb +12 -12
  13. data/lib/sapphire/DSL/Browser/Compare.rb +18 -18
  14. data/lib/sapphire/DSL/Browser/Complete.rb +15 -15
  15. data/lib/sapphire/DSL/Browser/CurrentUrl.rb +11 -11
  16. data/lib/sapphire/DSL/Browser/Day.rb +24 -24
  17. data/lib/sapphire/DSL/Browser/Differ.rb +18 -18
  18. data/lib/sapphire/DSL/Browser/Error.rb +26 -26
  19. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +45 -45
  20. data/lib/sapphire/DSL/Browser/Exists.rb +22 -22
  21. data/lib/sapphire/DSL/Browser/For.rb +10 -10
  22. data/lib/sapphire/DSL/Browser/Hide.rb +26 -26
  23. data/lib/sapphire/DSL/Browser/IsHidden.rb +10 -10
  24. data/lib/sapphire/DSL/Browser/IsVisible.rb +33 -33
  25. data/lib/sapphire/DSL/Browser/Keys/Enter.rb +10 -10
  26. data/lib/sapphire/DSL/Browser/Month.rb +24 -24
  27. data/lib/sapphire/DSL/Browser/MouseOver.rb +12 -12
  28. data/lib/sapphire/DSL/Browser/Navigate.rb +11 -11
  29. data/lib/sapphire/DSL/Browser/Popup.rb +2 -4
  30. data/lib/sapphire/DSL/Browser/Press.rb +10 -10
  31. data/lib/sapphire/DSL/Browser/Reload.rb +11 -11
  32. data/lib/sapphire/DSL/Browser/Set.rb +18 -18
  33. data/lib/sapphire/DSL/Browser/Should.rb +42 -42
  34. data/lib/sapphire/DSL/Browser/Show.rb +26 -26
  35. data/lib/sapphire/DSL/Browser/Start.rb +16 -16
  36. data/lib/sapphire/DSL/Browser/To.rb +10 -10
  37. data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
  38. data/lib/sapphire/DSL/Browser/Transition.rb +26 -26
  39. data/lib/sapphire/DSL/Browser/Uncheck.rb +12 -12
  40. data/lib/sapphire/DSL/Browser/With.rb +10 -10
  41. data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
  42. data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
  43. data/lib/sapphire/DSL/Configuration/Use.rb +15 -15
  44. data/lib/sapphire/DSL/Data/Exist.rb +27 -27
  45. data/lib/sapphire/DSL/Data/Find.rb +10 -10
  46. data/lib/sapphire/DSL/Data/GetPageField.rb +17 -17
  47. data/lib/sapphire/DSL/Data/Underscore.rb +8 -8
  48. data/lib/sapphire/DSL/Data/Validate.rb +26 -26
  49. data/lib/sapphire/DSL/Data/Verify.rb +10 -10
  50. data/lib/sapphire/DSL/Scenarios/Is.rb +9 -9
  51. data/lib/sapphire/DSL/Scenarios/Pending.rb +28 -28
  52. data/lib/sapphire/DSL/Scenarios/and.rb +25 -25
  53. data/lib/sapphire/DSL/Scenarios/background.rb +33 -33
  54. data/lib/sapphire/DSL/Scenarios/dsl.rb +59 -59
  55. data/lib/sapphire/DSL/Scenarios/finally.rb +33 -33
  56. data/lib/sapphire/DSL/Scenarios/given.rb +57 -57
  57. data/lib/sapphire/DSL/Scenarios/runner.rb +40 -40
  58. data/lib/sapphire/DSL/Scenarios/scenario.rb +53 -53
  59. data/lib/sapphire/DSL/Scenarios/then.rb +34 -34
  60. data/lib/sapphire/DSL/Scenarios/when.rb +47 -47
  61. data/lib/sapphire/Data.rb +1 -1
  62. data/lib/sapphire/DataAbstractions/Database.rb +57 -57
  63. data/lib/sapphire/DataAbstractions/Query.rb +19 -19
  64. data/lib/sapphire/JobAbstractions/Job.rb +32 -32
  65. data/lib/sapphire/Strategies.rb +1 -1
  66. data/lib/sapphire/TeamCity.rb +8 -8
  67. data/lib/sapphire/Testing.rb +2 -2
  68. data/lib/sapphire/Testing/Executable.rb +30 -30
  69. data/lib/sapphire/Testing/RakeTask.rb +108 -108
  70. data/lib/sapphire/Testing/ResultList.rb +18 -18
  71. data/lib/sapphire/Testing/ResultTree.rb +44 -44
  72. data/lib/sapphire/Testing/ScenarioResult.rb +36 -36
  73. data/lib/sapphire/Testing/TestResult.rb +21 -21
  74. data/lib/sapphire/Testing/TestRunnerAdapter.rb +69 -69
  75. data/lib/sapphire/Virtualization.rb +7 -7
  76. data/lib/sapphire/Web.rb +3 -6
  77. data/lib/sapphire/WebAbstractions/{Controls/Browsers → Browsers}/Chrome.rb +21 -21
  78. data/lib/sapphire/WebAbstractions/{Controls/Browsers → Browsers}/FireFox.rb +22 -22
  79. data/lib/sapphire/WebAbstractions/{Controls/Browsers → Browsers}/InternetExplorer.rb +21 -21
  80. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +59 -99
  81. data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +62 -62
  82. data/lib/sapphire/WebAbstractions/Controls/Button.rb +9 -9
  83. data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -28
  84. data/lib/sapphire/WebAbstractions/Controls/Date.rb +11 -11
  85. data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +26 -26
  86. data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
  87. data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -9
  88. data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
  89. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -18
  90. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -31
  91. data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
  92. data/lib/sapphire/version.rb +3 -3
  93. metadata +14 -13
  94. data/lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb +0 -91
@@ -1,10 +1,10 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def IsHidden(args)
5
-
6
- end
7
- end
8
- end
9
- end
10
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def IsHidden(args)
5
+
6
+ end
7
+ end
8
+ end
9
+ end
10
+
@@ -1,33 +1,33 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def IsVisible(args)
5
- @page.fields.each do |field|
6
- field.keys.each do |field_key|
7
- if(field_key == args)
8
- begin
9
- x = field[field_key].Find
10
- if(x)
11
- begin
12
- wait = Selenium::WebDriver::Wait.new(:timeout => 30)
13
- result = wait.until { y = x.displayed?
14
- y unless y == false
15
- }
16
- return result
17
- rescue
18
- return false
19
- end
20
- end
21
- rescue
22
- return false
23
- end
24
- end
25
- end
26
- end
27
-
28
- raise "cannot find control matching " + args.to_s + " for page " + @page.to_s
29
- end
30
- end
31
- end
32
- end
33
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def IsVisible(args)
5
+ @page.fields.each do |field|
6
+ field.keys.each do |field_key|
7
+ if(field_key == args)
8
+ begin
9
+ x = field[field_key].Find
10
+ if(x)
11
+ begin
12
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30)
13
+ result = wait.until { y = x.displayed?
14
+ y unless y == false
15
+ }
16
+ return result
17
+ rescue
18
+ return false
19
+ end
20
+ end
21
+ rescue
22
+ return false
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ raise "cannot find control matching " + args.to_s + " for page " + @page.to_s
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- class Enter
5
- def Press
6
- $browser.action.send_keys("\n").perform()
7
- end
8
- end
9
- end
10
- end
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ class Enter
5
+ def Press
6
+ $browser.Type("\n")
7
+ end
8
+ end
9
+ end
10
+ end
11
11
  end
@@ -1,24 +1,24 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Month(value, compare1, compare2)
5
- Month.new(value, compare1, compare2)
6
- end
7
-
8
- class Month
9
-
10
- def initialize(value, compare1, compare2)
11
- @value = value
12
- @compare1 = compare1
13
- @compare2 = compare2
14
- end
15
-
16
- def Differ()
17
- return (@compare1 >> @value) == @compare2
18
- end
19
-
20
- end
21
- end
22
- end
23
- end
24
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Month(value, compare1, compare2)
5
+ Month.new(value, compare1, compare2)
6
+ end
7
+
8
+ class Month
9
+
10
+ def initialize(value, compare1, compare2)
11
+ @value = value
12
+ @compare1 = compare1
13
+ @compare2 = compare2
14
+ end
15
+
16
+ def Differ()
17
+ return (@compare1 >> @value) == @compare2
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -1,12 +1,12 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def MouseOver(*args)
5
- ExecuteAgainstControl(args) do |control, arg|
6
- control.MouseOver
7
- end
8
- end
9
- end
10
- end
11
- end
12
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def MouseOver(*args)
5
+ ExecuteAgainstControl(args) do |control, arg|
6
+ control.MouseOver
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Navigate(page)
5
- @page = @browser.NavigateTo(page)
6
- @page.Init
7
- end
8
- end
9
- end
10
- end
11
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Navigate(page)
5
+ @page = @browser.NavigateTo(page)
6
+ @page.Init
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -3,13 +3,11 @@ module Sapphire
3
3
  module Browser
4
4
  class Popup
5
5
  def Close
6
- $browser.switch_to.window($browser.window_handles.last)
7
- $browser.close
8
- $browser.switch_to.window($browser.window_handles[0])
6
+ $browser.ClosePopup
9
7
  end
10
8
 
11
9
  def Switch
12
- $browser.switch_to.window($browser.window_handles.last)
10
+ $browser.SwitchToPopup
13
11
  end
14
12
  end
15
13
  end
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
-
5
- def Press(item)
6
- item.new().Press
7
- end
8
-
9
- end
10
- end
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+
5
+ def Press(item)
6
+ item.new().Press
7
+ end
8
+
9
+ end
10
+ end
11
11
  end
@@ -1,11 +1,11 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Reload(item)
5
- @browser.Reload
6
- Should Show item
7
- end
8
- end
9
- end
10
- end
11
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Reload(item)
5
+ @browser.Reload
6
+ Should Show item
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -1,18 +1,18 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Set(hash)
5
- if(hash.keys.first == AlertBox)
6
- text = hash[item.keys.first]
7
- klass = hash.keys.first.new
8
- klass.Set text
9
- else
10
- ExecuteHashAgainstControl(hash, @page) do |control, arg|
11
- control.Set arg
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
18
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Set(hash)
5
+ if(hash.keys.first == AlertBox)
6
+ text = hash[item.keys.first]
7
+ klass = hash.keys.first.new
8
+ klass.Set text
9
+ else
10
+ ExecuteHashAgainstControl(hash, @page) do |control, arg|
11
+ control.Set arg
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -1,42 +1,42 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Should(item)
5
- results = item.execute()
6
-
7
- if results.is_a? Hash
8
- @page = results[:page] if results[:page] != nil
9
- value = results[:value]
10
- modifier = results[:modifier]
11
-
12
- if value.is_a? Hash
13
- @page = value[:page] if value[:page] != nil
14
- sub_value = value[:value]
15
- modifier.Evaluate(sub_value)
16
- return
17
- end
18
- modifier.Evaluate(value)
19
-
20
- return
21
- end
22
-
23
- if(results.is_a? Evaluation)
24
- if(results.left != results.right)
25
- messages = []
26
-
27
- messages << "expected: (nil)" if results.left == nil
28
- messages << "expected: " + results.left.to_s if results.left != nil
29
- messages << "got: (nil)" if results.right == nil
30
- messages << "got: " + results.right.to_s if results.right != nil
31
-
32
- raise ExpectationException.new(messages)
33
- end
34
- return
35
- end
36
-
37
- raise "Cannot act upon result " + results.to_s + " for page " + @page.to_s
38
- end
39
- end
40
- end
41
- end
42
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Should(item)
5
+ results = item.execute()
6
+
7
+ if results.is_a? Hash
8
+ @page = results[:page] if results[:page] != nil
9
+ value = results[:value]
10
+ modifier = results[:modifier]
11
+
12
+ if value.is_a? Hash
13
+ @page = value[:page] if value[:page] != nil
14
+ sub_value = value[:value]
15
+ modifier.Evaluate(sub_value)
16
+ return
17
+ end
18
+ modifier.Evaluate(value)
19
+
20
+ return
21
+ end
22
+
23
+ if(results.is_a? Evaluation)
24
+ if(results.left != results.right)
25
+ messages = []
26
+
27
+ messages << "expected: (nil)" if results.left == nil
28
+ messages << "expected: " + results.left.to_s if results.left != nil
29
+ messages << "got: (nil)" if results.right == nil
30
+ messages << "got: " + results.right.to_s if results.right != nil
31
+
32
+ raise ExpectationException.new(messages)
33
+ end
34
+ return
35
+ end
36
+
37
+ raise "Cannot act upon result " + results.to_s + " for page " + @page.to_s
38
+ end
39
+ end
40
+ end
41
+ end
42
+
@@ -1,26 +1,26 @@
1
- module Sapphire
2
- module DSL
3
- module Browser
4
- def Show(item)
5
- NullModifier.new(Show.new(item, @page, @browser))
6
- end
7
-
8
- class Show
9
- def initialize(item, page, browser)
10
- @item = item
11
- @page = page
12
- @browser = browser
13
- end
14
-
15
- def ModifyWith(item)
16
- @modifier = item
17
- end
18
-
19
- def execute
20
- return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page, @browser).Show(@item, @modifier), :modifier => @modifier }
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
1
+ module Sapphire
2
+ module DSL
3
+ module Browser
4
+ def Show(item)
5
+ NullModifier.new(Show.new(item, @page, @browser))
6
+ end
7
+
8
+ class Show
9
+ def initialize(item, page, browser)
10
+ @item = item
11
+ @page = page
12
+ @browser = browser
13
+ end
14
+
15
+ def ModifyWith(item)
16
+ @modifier = item
17
+ end
18
+
19
+ def execute
20
+ return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page, @browser).Show(@item, @modifier), :modifier => @modifier }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+