sapphire 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire.rb +30 -0
- data/lib/sapphire/DSL/Browser/Browser.rb +13 -0
- data/lib/sapphire/DSL/Browser/Check.rb +12 -0
- data/lib/sapphire/DSL/Browser/Clear.rb +15 -0
- data/lib/sapphire/DSL/Browser/Click.rb +12 -0
- data/lib/sapphire/DSL/Browser/Close.rb +12 -0
- data/lib/sapphire/DSL/Browser/Complete.rb +15 -0
- data/lib/sapphire/DSL/Browser/CurrentUrl.rb +11 -0
- data/lib/sapphire/DSL/Browser/Error.rb +12 -0
- data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +45 -0
- data/lib/sapphire/DSL/Browser/Exists.rb +22 -0
- data/lib/sapphire/DSL/Browser/For.rb +10 -0
- data/lib/sapphire/DSL/Browser/Hide.rb +10 -0
- data/lib/sapphire/DSL/Browser/IsHidden.rb +28 -0
- data/lib/sapphire/DSL/Browser/IsVisible.rb +25 -0
- data/lib/sapphire/DSL/Browser/MouseOver.rb +12 -0
- data/lib/sapphire/DSL/Browser/Navigate.rb +11 -0
- data/lib/sapphire/DSL/Browser/Reload.rb +11 -0
- data/lib/sapphire/DSL/Browser/Set.rb +12 -0
- data/lib/sapphire/DSL/Browser/Should.rb +10 -0
- data/lib/sapphire/DSL/Browser/Show.rb +26 -0
- data/lib/sapphire/DSL/Browser/Start.rb +16 -0
- data/lib/sapphire/DSL/Browser/To.rb +10 -0
- data/lib/sapphire/DSL/Browser/Tracker.rb +15 -0
- data/lib/sapphire/DSL/Browser/Transition.rb +10 -0
- data/lib/sapphire/DSL/Browser/Uncheck.rb +12 -0
- data/lib/sapphire/DSL/Browser/With.rb +10 -0
- data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +13 -0
- data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +11 -0
- data/lib/sapphire/DSL/Configuration/Use.rb +15 -0
- data/lib/sapphire/DSL/Data/Exist.rb +11 -0
- data/lib/sapphire/DSL/Data/Find.rb +10 -0
- data/lib/sapphire/DSL/Data/GetPageField.rb +17 -0
- data/lib/sapphire/DSL/Data/Underscore.rb +9 -0
- data/lib/sapphire/DSL/Data/Validate.rb +16 -0
- data/lib/sapphire/DSL/Data/Verify.rb +10 -0
- data/lib/sapphire/DSL/Scenarios/Is.rb +9 -0
- data/lib/sapphire/DSL/Scenarios/Pending.rb +29 -0
- data/lib/sapphire/DSL/Scenarios/and.rb +25 -0
- data/lib/sapphire/DSL/Scenarios/background.rb +23 -0
- data/lib/sapphire/DSL/Scenarios/dsl.rb +60 -0
- data/lib/sapphire/DSL/Scenarios/finally.rb +32 -0
- data/lib/sapphire/DSL/Scenarios/given.rb +57 -0
- data/lib/sapphire/DSL/Scenarios/runner.rb +30 -0
- data/lib/sapphire/DSL/Scenarios/scenario.rb +51 -0
- data/lib/sapphire/DSL/Scenarios/then.rb +34 -0
- data/lib/sapphire/DSL/Scenarios/when.rb +47 -0
- data/lib/sapphire/DataAbstractions/Database.rb +57 -0
- data/lib/sapphire/DataAbstractions/Query.rb +20 -0
- data/lib/sapphire/Testing/Executable.rb +30 -0
- data/lib/sapphire/Testing/RSpecRunner.rb +85 -0
- data/lib/sapphire/Testing/RakeTask.rb +109 -0
- data/lib/sapphire/Testing/ResultList.rb +19 -0
- data/lib/sapphire/Testing/ResultTree.rb +37 -0
- data/lib/sapphire/Testing/ScenarioResult.rb +31 -0
- data/lib/sapphire/Testing/TestResult.rb +24 -0
- data/lib/sapphire/Testing/TestRunnerAdapter.rb +62 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +74 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +47 -0
- data/lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb +74 -0
- data/lib/sapphire/WebAbstractions/Controls/Button.rb +9 -0
- data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -0
- data/lib/sapphire/WebAbstractions/Controls/Chrome.rb +21 -0
- data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +25 -0
- data/lib/sapphire/WebAbstractions/Controls/FireFox.rb +22 -0
- data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -0
- data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -0
- data/lib/sapphire/WebAbstractions/Controls/InternetExplorer.rb +21 -0
- data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -0
- data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -0
- data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -0
- data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -0
- data/lib/sapphire/version.rb +3 -0
- metadata +152 -0
data/lib/sapphire.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "rubygems"
|
3
|
+
require "rspec"
|
4
|
+
require 'yaml'
|
5
|
+
require 'selenium-webdriver'
|
6
|
+
require 'delegate'
|
7
|
+
require 'Forwardable'
|
8
|
+
require 'win32ole'
|
9
|
+
require 'json'
|
10
|
+
|
11
|
+
Dir[File.dirname(__FILE__) + '/sapphire/Testing/*.rb'].each {|file| require file }
|
12
|
+
Dir[File.dirname(__FILE__) + '/sapphire/WebAbstractions/Controls/Base/*.rb'].each {|file| require file }
|
13
|
+
Dir[File.dirname(__FILE__) + '/sapphire/WebAbstractions/Controls/*.rb'].each {|file| require file }
|
14
|
+
Dir[File.dirname(__FILE__) + '/sapphire/DataAbstractions/*.rb'].each {|file| require file }
|
15
|
+
Dir[File.dirname(__FILE__) + '/sapphire/DSL/Browser/*.rb'].each {|file| require file }
|
16
|
+
Dir[File.dirname(__FILE__) + '/sapphire/DSL/Configuration/*.rb'].each {|file| require file }
|
17
|
+
Dir[File.dirname(__FILE__) + '/sapphire/DSL/Data/*.rb'].each {|file| require file }
|
18
|
+
Dir[File.dirname(__FILE__) + '/sapphire/DSL/Scenarios/*.rb'].each {|file| require file }
|
19
|
+
|
20
|
+
module Sapphire
|
21
|
+
module Sapphire
|
22
|
+
include DSL::Scenarios
|
23
|
+
include DSL::Browser
|
24
|
+
include DSL::Configuration
|
25
|
+
include DSL::Data
|
26
|
+
include DataAbstractions
|
27
|
+
include WebAbstractions
|
28
|
+
include Testing
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def ExecuteHashAgainstControl(hash, &block)
|
5
|
+
hash.keys.each do |key|
|
6
|
+
@page.fields.each do |field|
|
7
|
+
field.keys.each do |field_key|
|
8
|
+
if(field_key == key)
|
9
|
+
block.call(field[key], hash[key])
|
10
|
+
return
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
raise "cannot find control matching " + hash.to_s + " for page " + @page.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def ExecuteAgainstControl(*args, &block)
|
20
|
+
@page.fields.each do |field|
|
21
|
+
field.keys.each do |field_key|
|
22
|
+
args.each do |arg_array|
|
23
|
+
arg_array.each do |arg|
|
24
|
+
if(field_key == arg)
|
25
|
+
block.call(field[field_key], arg)
|
26
|
+
return
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
arglist = ""
|
34
|
+
args.each do |arg_array|
|
35
|
+
arg_array.each do |arg|
|
36
|
+
arglist += arg.to_s + ", "
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
raise "Cannot find controls matching: " + arglist + "for page " + @page.to_s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def Exists(symbol)
|
5
|
+
@page.fields.each do |field|
|
6
|
+
field.keys.each do |field_key|
|
7
|
+
if(field_key == symbol)
|
8
|
+
begin
|
9
|
+
x = field[field_key].FindWithoutWait
|
10
|
+
return x.displayed?
|
11
|
+
rescue
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def IsHidden(args)
|
5
|
+
@page.fields.each do |field|
|
6
|
+
field.keys.each do |field_key|
|
7
|
+
if(field_key == args)
|
8
|
+
begin
|
9
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
10
|
+
element = wait.until { x = field[field_key].Find
|
11
|
+
x and !x.displayed?
|
12
|
+
}
|
13
|
+
if(element)
|
14
|
+
return element.displayed?
|
15
|
+
end
|
16
|
+
rescue
|
17
|
+
return true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
raise "cannot find control matching " + args.to_s + " for page " + @page.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,25 @@
|
|
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
|
+
return x.displayed?
|
12
|
+
end
|
13
|
+
rescue
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
raise "cannot find control matching " + args.to_s + " for page " + @page.to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Browser
|
4
|
+
def Show(item)
|
5
|
+
|
6
|
+
if(item.is_a? Hash)
|
7
|
+
ExecuteHashAgainstControl(item) do |control, arg|
|
8
|
+
control.Text.should == arg
|
9
|
+
end
|
10
|
+
return
|
11
|
+
elsif(item.is_a? Symbol)
|
12
|
+
IsVisible(item).should == true
|
13
|
+
return
|
14
|
+
elsif(item.is_a? Class)
|
15
|
+
@page = @browser.ShouldNavigateTo item
|
16
|
+
sleep(1)
|
17
|
+
else
|
18
|
+
@page = item
|
19
|
+
end
|
20
|
+
|
21
|
+
@page.Init
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|