sapphire 0.6.7 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire.rb +3 -2
- data/lib/sapphire/Adapters/Selenium/RubySeleniumWebDriver.rb +43 -27
- data/lib/sapphire/Configuration/AppConfig.rb +1 -1
- data/lib/sapphire/DSL.rb +6 -1
- data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +6 -20
- data/lib/sapphire/DSL/Browser/Fluff/Be.rb +10 -0
- data/lib/sapphire/DSL/Browser/Fluff/By.rb +2 -2
- data/lib/sapphire/DSL/Browser/Fluff/Have.rb +10 -0
- data/lib/sapphire/DSL/Browser/Fluff/To.rb +2 -2
- data/lib/sapphire/DSL/Browser/For.rb +9 -10
- data/lib/sapphire/DSL/Browser/Nouns/Browser.rb +2 -2
- data/lib/sapphire/DSL/Browser/Nouns/Day.rb +42 -24
- data/lib/sapphire/DSL/Browser/Nouns/Enter.rb +1 -1
- data/lib/sapphire/DSL/Browser/Nouns/Month.rb +42 -24
- data/lib/sapphire/DSL/Browser/Nouns/Popup.rb +2 -2
- data/lib/sapphire/DSL/Browser/Nouns/Second.rb +42 -0
- data/lib/sapphire/DSL/Browser/Should.rb +1 -46
- data/lib/sapphire/DSL/Browser/Verbs/Accept.rb +1 -2
- data/lib/sapphire/DSL/Browser/Verbs/Check.rb +0 -1
- data/lib/sapphire/DSL/Browser/Verbs/Click.rb +0 -1
- data/lib/sapphire/DSL/Browser/Verbs/Compare.rb +5 -5
- data/lib/sapphire/DSL/Browser/Verbs/Complete.rb +2 -2
- data/lib/sapphire/DSL/Browser/Verbs/Disable.rb +1 -1
- data/lib/sapphire/DSL/Browser/Verbs/Exists.rb +6 -11
- data/lib/sapphire/DSL/Browser/Verbs/{Close.rb → Exit.rb} +0 -0
- data/lib/sapphire/DSL/Browser/Verbs/Has.rb +9 -0
- data/lib/sapphire/DSL/Browser/Verbs/MouseOver.rb +0 -1
- data/lib/sapphire/DSL/Browser/Verbs/Navigate.rb +1 -2
- data/lib/sapphire/DSL/Browser/Verbs/On.rb +19 -0
- data/lib/sapphire/DSL/Browser/Verbs/Press.rb +1 -1
- data/lib/sapphire/DSL/Browser/Verbs/Reload.rb +1 -1
- data/lib/sapphire/DSL/Browser/Verbs/Remove.rb +22 -0
- data/lib/sapphire/DSL/Browser/Verbs/Set.rb +1 -1
- data/lib/sapphire/DSL/Browser/Verbs/Start.rb +14 -16
- data/lib/sapphire/DSL/Browser/Verbs/Uncheck.rb +0 -1
- data/lib/sapphire/DSL/Comparisons/CheckedComparison.rb +17 -0
- data/lib/sapphire/DSL/Comparisons/Comparison.rb +34 -0
- data/lib/sapphire/DSL/Comparisons/ContainsComparison.rb +17 -0
- data/lib/sapphire/DSL/Comparisons/DifferComparison.rb +17 -0
- data/lib/sapphire/DSL/Comparisons/EqualsComparison.rb +16 -0
- data/lib/sapphire/DSL/Comparisons/NotComparison.rb +21 -0
- data/lib/sapphire/DSL/Comparisons/SelectedComparison.rb +17 -0
- data/lib/sapphire/DSL/Comparisons/StartsWithComparison.rb +17 -0
- data/lib/sapphire/DSL/Comparisons/VisibleComparison.rb +17 -0
- data/lib/sapphire/DSL/Configuration/Use.rb +3 -0
- data/lib/sapphire/DSL/Data/GetPageField.rb +4 -8
- data/lib/sapphire/DSL/Evaluations/Evaluation.rb +46 -0
- data/lib/sapphire/DSL/Evaluations/FieldNotDefinedEvaluation.rb +21 -0
- data/lib/sapphire/DSL/Evaluations/FieldNotFoundEvaluation.rb +21 -0
- data/lib/sapphire/DSL/Evaluators/AltText.rb +17 -0
- data/lib/sapphire/DSL/Evaluators/Checked.rb +17 -0
- data/lib/sapphire/DSL/Evaluators/Contain.rb +10 -0
- data/lib/sapphire/DSL/Evaluators/Count.rb +9 -0
- data/lib/sapphire/DSL/Evaluators/Differ.rb +10 -0
- data/lib/sapphire/DSL/Evaluators/Evaluator.rb +22 -0
- data/lib/sapphire/DSL/Evaluators/Exist.rb +9 -0
- data/lib/sapphire/DSL/Evaluators/In.rb +10 -0
- data/lib/sapphire/DSL/Evaluators/Selected.rb +10 -0
- data/lib/sapphire/DSL/Evaluators/Show.rb +10 -0
- data/lib/sapphire/DSL/Evaluators/Source.rb +17 -0
- data/lib/sapphire/DSL/Evaluators/Transition.rb +10 -0
- data/lib/sapphire/DSL/Evaluators/Validate.rb +8 -0
- data/lib/sapphire/DSL/Events/Causes.rb +3 -0
- data/lib/sapphire/DSL/Events/Event.rb +19 -0
- data/lib/sapphire/DSL/Events/Expect.rb +19 -0
- data/lib/sapphire/DSL/Scenarios/then.rb +1 -1
- data/lib/sapphire/DSL/Scenarios/when.rb +1 -1
- data/lib/sapphire/DSL/TestPlans/FileHandler.rb +7 -2
- data/lib/sapphire/DSL/TestPlans/PathHandler.rb +2 -1
- data/lib/sapphire/DataAbstractions/NonQuery.rb +2 -1
- data/lib/sapphire/DataAbstractions/Query.rb +2 -1
- data/lib/sapphire/Extensions.rb +1 -0
- data/lib/sapphire/{DSL/Browser/Extensions → Extensions}/Class.rb +10 -0
- data/lib/sapphire/Extensions/Hash.rb +85 -0
- data/lib/sapphire/{DSL/Browser/Extensions → Extensions}/Numeric.rb +6 -6
- data/lib/sapphire/Extensions/Object.rb +9 -0
- data/lib/sapphire/{DSL/Browser/Extensions → Extensions}/String.rb +4 -0
- data/lib/sapphire/Extensions/Symbol.rb +105 -0
- data/lib/sapphire/Sessions/Parameter.rb +36 -0
- data/lib/sapphire/Sessions/Storage.rb +17 -0
- data/lib/sapphire/UI/Functions.rb +2 -1
- data/lib/sapphire/UI/ProcessBuilder.rb +174 -0
- data/lib/sapphire/Virtualization.rb +1 -1
- data/lib/sapphire/WebAbstractions/Browsers/Chrome.rb +22 -21
- data/lib/sapphire/WebAbstractions/Browsers/FireFox.rb +24 -22
- data/lib/sapphire/WebAbstractions/Browsers/InternetExplorer.rb +22 -21
- data/lib/sapphire/WebAbstractions/Controls/AlertBox.rb +21 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +32 -14
- data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +74 -65
- data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +29 -28
- data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +59 -26
- data/lib/sapphire/WebAbstractions/Controls/Image.rb +10 -0
- data/lib/sapphire/WebAbstractions/Controls/List.rb +45 -4
- data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +29 -18
- data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +9 -8
- data/lib/sapphire/WebAbstractions/Controls/Title.rb +1 -1
- data/lib/sapphire/version.rb +1 -1
- metadata +55 -39
- data/lib/sapphire/Configuration/SapphireConfig.rb +0 -33
- data/lib/sapphire/DSL/Browser/Extensions/Hash.rb +0 -11
- data/lib/sapphire/DSL/Browser/Extensions/Symbol.rb +0 -37
- data/lib/sapphire/DSL/Browser/Not.rb +0 -39
- data/lib/sapphire/DSL/Browser/Nouns/AlertBox.rb +0 -15
- data/lib/sapphire/DSL/Browser/Verbs/Attempt.rb +0 -14
- data/lib/sapphire/DSL/Browser/Verbs/Contain.rb +0 -25
- data/lib/sapphire/DSL/Browser/Verbs/Count.rb +0 -24
- data/lib/sapphire/DSL/Browser/Verbs/Differ.rb +0 -19
- data/lib/sapphire/DSL/Browser/Verbs/Error.rb +0 -25
- data/lib/sapphire/DSL/Browser/Verbs/Hide.rb +0 -25
- data/lib/sapphire/DSL/Browser/Verbs/Show.rb +0 -25
- data/lib/sapphire/DSL/Browser/Verbs/Transition.rb +0 -25
- data/lib/sapphire/DSL/Data/Exist.rb +0 -26
- data/lib/sapphire/DSL/Data/Validate.rb +0 -25
- data/lib/sapphire/Strategies.rb +0 -2
- data/lib/sapphire/Strategies/ClassStrategy.rb +0 -13
- data/lib/sapphire/Strategies/ContainsEvaluation.rb +0 -16
- data/lib/sapphire/Strategies/ContainsNullModifier.rb +0 -34
- data/lib/sapphire/Strategies/DefaultStrategy.rb +0 -17
- data/lib/sapphire/Strategies/Evaluation.rb +0 -16
- data/lib/sapphire/Strategies/HashStrategy.rb +0 -72
- data/lib/sapphire/Strategies/NullModifier.rb +0 -34
- data/lib/sapphire/Strategies/Strategy.rb +0 -11
- data/lib/sapphire/Strategies/SymbolStrategy.rb +0 -59
- data/lib/sapphire/WebAbstractions/Controls/TableCell.rb +0 -10
@@ -1,33 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module Configuration
|
3
|
-
class SapphireConfig
|
4
|
-
|
5
|
-
attr_reader :wait_time
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@@config = {}
|
9
|
-
|
10
|
-
Add Symbol => SymbolStrategy
|
11
|
-
Add Class => ClassStrategy
|
12
|
-
Add Hash => HashStrategy
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.Current
|
16
|
-
@@instance ||= SapphireConfig.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def Add(hash)
|
20
|
-
@@config = @@config.merge(hash)
|
21
|
-
end
|
22
|
-
|
23
|
-
def GetBy(symbol)
|
24
|
-
if(@@config.has_key? symbol)
|
25
|
-
return @@config[symbol]
|
26
|
-
end
|
27
|
-
|
28
|
-
return DefaultStrategy
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
class Symbol
|
2
|
-
|
3
|
-
def With(options = {})
|
4
|
-
@page = options.fetch(:page) if options.has_key? :page
|
5
|
-
end
|
6
|
-
|
7
|
-
def Check
|
8
|
-
ExecuteAgainstControl(self, @page) do |control, arg|
|
9
|
-
control.Check true
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def Click
|
14
|
-
ExecuteAgainstControl(self, @page) do |control, arg|
|
15
|
-
control.Click
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def MouseOver
|
20
|
-
ExecuteAgainstControl(self, @page) do |control, arg|
|
21
|
-
control.MouseOver
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def Uncheck
|
26
|
-
ExecuteAgainstControl(self, @page) do |control, arg|
|
27
|
-
control.Check false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def Set(hash)
|
32
|
-
ExecuteHashAgainstControl(hash, @page) do |control, arg|
|
33
|
-
control.Set arg
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Not(item)
|
5
|
-
Not.new(item)
|
6
|
-
end
|
7
|
-
|
8
|
-
class Not
|
9
|
-
|
10
|
-
def initialize(item)
|
11
|
-
@item = item
|
12
|
-
@item.ModifyWith self
|
13
|
-
end
|
14
|
-
|
15
|
-
def Modify(item)
|
16
|
-
return @modifier.Modify(!item) if @modifier != nil
|
17
|
-
!item
|
18
|
-
end
|
19
|
-
|
20
|
-
def Evaluate(evaluation)
|
21
|
-
if(evaluation.left == evaluation.right)
|
22
|
-
messages = []
|
23
|
-
|
24
|
-
messages << "expected NOT: (nil)" if evaluation.right == nil
|
25
|
-
messages << "expected NOT: " + evaluation.right.to_s if evaluation.right != nil
|
26
|
-
messages << "got: (nil)" if evaluation.left == nil
|
27
|
-
messages << "got: " + evaluation.left.to_s if evaluation.left != nil
|
28
|
-
|
29
|
-
raise ExpectationException.new(messages)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def execute
|
34
|
-
@item.execute
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Contain(item)
|
5
|
-
ContainsNullModifier.new(Contain.new(item, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Contain
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Contain(@item, @modifier), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Count(item)
|
5
|
-
NullModifier.new(Count.new(item, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Count
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Count(@item, @modifier), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Differ(arg)
|
5
|
-
return Differ.new(arg)
|
6
|
-
end
|
7
|
-
|
8
|
-
class Differ
|
9
|
-
def initialize(arg)
|
10
|
-
@arg = arg
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute
|
14
|
-
return Evaluation.new(true, @arg.Differ) #args[0] is the value that should be the difference
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Error(hash)
|
5
|
-
NullModifier.new(Error.new(hash, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Error
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Error(@item), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Hide(args)
|
5
|
-
NullModifier.new(Hide.new(args, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Hide
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Hide(@item, @modifier), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
def Show(item)
|
5
|
-
NullModifier.new(Show.new(item, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Show
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Show(@item, @modifier), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Browser
|
4
|
-
|
5
|
-
def Transition(url)
|
6
|
-
NullModifier.new(Transition.new(url))
|
7
|
-
end
|
8
|
-
|
9
|
-
class Transition
|
10
|
-
def initialize(item)
|
11
|
-
@item = item
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
@modifier.Modify($browser.ShouldTransitionTo(@item))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Data
|
4
|
-
def Exist(value)
|
5
|
-
Not(Exist.new(value, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Exist
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Exists(@item), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Data
|
4
|
-
def Validate(hash)
|
5
|
-
NullModifier.new(Validate.new(hash, @page))
|
6
|
-
end
|
7
|
-
|
8
|
-
class Validate
|
9
|
-
def initialize(item, page)
|
10
|
-
@item = item
|
11
|
-
@page = page
|
12
|
-
end
|
13
|
-
|
14
|
-
def ModifyWith(item)
|
15
|
-
@modifier = item
|
16
|
-
end
|
17
|
-
|
18
|
-
def execute
|
19
|
-
return { :value => SapphireConfig.Current.GetBy(@item.class).new(@page).Validate(@item), :modifier => @modifier }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
data/lib/sapphire/Strategies.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
class ContainsNullModifier
|
2
|
-
def initialize(item)
|
3
|
-
@item = item
|
4
|
-
@item.ModifyWith self
|
5
|
-
end
|
6
|
-
|
7
|
-
def ModifyWith(item)
|
8
|
-
@modifier = item
|
9
|
-
end
|
10
|
-
|
11
|
-
def Modify(item)
|
12
|
-
return @modifier.Modify(item) if @modifier != nil
|
13
|
-
item if @modifier == nil
|
14
|
-
end
|
15
|
-
|
16
|
-
def Evaluate(evaluation)
|
17
|
-
return @modifier.Evaluate(evaluation) if @modifier != nil
|
18
|
-
|
19
|
-
if(!evaluation.left.include? evaluation.right)
|
20
|
-
messages = []
|
21
|
-
|
22
|
-
messages << "expected to contain: (nil)" if evaluation.right == nil
|
23
|
-
messages << "expected to contain: " + evaluation.right.to_s if evaluation.right != nil
|
24
|
-
messages << "got: (nil)" if evaluation.left == nil
|
25
|
-
messages << "got: " + evaluation.left.to_s if evaluation.left != nil
|
26
|
-
|
27
|
-
raise ExpectationException.new(messages)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def execute
|
32
|
-
@item.execute
|
33
|
-
end
|
34
|
-
end
|