sapphire 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. data/lib/sapphire/DSL/Browser/Browser.rb +13 -13
  2. data/lib/sapphire/DSL/Browser/Check.rb +12 -12
  3. data/lib/sapphire/DSL/Browser/Clear.rb +15 -15
  4. data/lib/sapphire/DSL/Browser/Click.rb +12 -12
  5. data/lib/sapphire/DSL/Browser/Close.rb +12 -12
  6. data/lib/sapphire/DSL/Browser/Complete.rb +15 -15
  7. data/lib/sapphire/DSL/Browser/CurrentUrl.rb +11 -11
  8. data/lib/sapphire/DSL/Browser/Error.rb +12 -12
  9. data/lib/sapphire/DSL/Browser/ExecuteAgainstControl.rb +45 -45
  10. data/lib/sapphire/DSL/Browser/Exists.rb +22 -22
  11. data/lib/sapphire/DSL/Browser/For.rb +10 -10
  12. data/lib/sapphire/DSL/Browser/Hide.rb +10 -10
  13. data/lib/sapphire/DSL/Browser/IsHidden.rb +28 -28
  14. data/lib/sapphire/DSL/Browser/IsVisible.rb +25 -25
  15. data/lib/sapphire/DSL/Browser/MouseOver.rb +12 -12
  16. data/lib/sapphire/DSL/Browser/Navigate.rb +11 -11
  17. data/lib/sapphire/DSL/Browser/Not.rb +9 -0
  18. data/lib/sapphire/DSL/Browser/Reload.rb +11 -11
  19. data/lib/sapphire/DSL/Browser/Set.rb +12 -12
  20. data/lib/sapphire/DSL/Browser/Should.rb +10 -10
  21. data/lib/sapphire/DSL/Browser/Show.rb +27 -26
  22. data/lib/sapphire/DSL/Browser/Start.rb +16 -16
  23. data/lib/sapphire/DSL/Browser/To.rb +10 -10
  24. data/lib/sapphire/DSL/Browser/Tracker.rb +15 -15
  25. data/lib/sapphire/DSL/Browser/Transition.rb +10 -10
  26. data/lib/sapphire/DSL/Browser/Uncheck.rb +12 -12
  27. data/lib/sapphire/DSL/Browser/With.rb +10 -10
  28. data/lib/sapphire/DSL/Configuration/ConfiguredBrowser.rb +12 -12
  29. data/lib/sapphire/DSL/Configuration/ConfiguredUser.rb +10 -10
  30. data/lib/sapphire/DSL/Configuration/Use.rb +15 -15
  31. data/lib/sapphire/DSL/Data/Exist.rb +11 -11
  32. data/lib/sapphire/DSL/Data/Find.rb +10 -10
  33. data/lib/sapphire/DSL/Data/GetPageField.rb +17 -17
  34. data/lib/sapphire/DSL/Data/Underscore.rb +8 -8
  35. data/lib/sapphire/DSL/Data/Validate.rb +16 -16
  36. data/lib/sapphire/DSL/Data/Verify.rb +10 -10
  37. data/lib/sapphire/DSL/Scenarios/Is.rb +9 -9
  38. data/lib/sapphire/DSL/Scenarios/Pending.rb +28 -28
  39. data/lib/sapphire/DSL/Scenarios/and.rb +24 -24
  40. data/lib/sapphire/DSL/Scenarios/background.rb +22 -22
  41. data/lib/sapphire/DSL/Scenarios/dsl.rb +60 -60
  42. data/lib/sapphire/DSL/Scenarios/finally.rb +31 -31
  43. data/lib/sapphire/DSL/Scenarios/given.rb +56 -56
  44. data/lib/sapphire/DSL/Scenarios/runner.rb +30 -30
  45. data/lib/sapphire/DSL/Scenarios/scenario.rb +51 -51
  46. data/lib/sapphire/DSL/Scenarios/then.rb +33 -33
  47. data/lib/sapphire/DSL/Scenarios/when.rb +46 -46
  48. data/lib/sapphire/DataAbstractions/Database.rb +57 -57
  49. data/lib/sapphire/DataAbstractions/Query.rb +19 -19
  50. data/lib/sapphire/Testing/ResultList.rb +18 -18
  51. data/lib/sapphire/Testing/ResultTree.rb +37 -37
  52. data/lib/sapphire/WebAbstractions/Controls/Base/Control.rb +74 -74
  53. data/lib/sapphire/WebAbstractions/Controls/Base/Page.rb +47 -47
  54. data/lib/sapphire/WebAbstractions/Controls/Base/WebBrowser.rb +74 -74
  55. data/lib/sapphire/WebAbstractions/Controls/Button.rb +9 -9
  56. data/lib/sapphire/WebAbstractions/Controls/CheckBox.rb +28 -28
  57. data/lib/sapphire/WebAbstractions/Controls/Chrome.rb +21 -21
  58. data/lib/sapphire/WebAbstractions/Controls/DropDown.rb +25 -25
  59. data/lib/sapphire/WebAbstractions/Controls/FireFox.rb +22 -22
  60. data/lib/sapphire/WebAbstractions/Controls/Hyperlink.rb +8 -8
  61. data/lib/sapphire/WebAbstractions/Controls/Image.rb +9 -9
  62. data/lib/sapphire/WebAbstractions/Controls/InternetExplorer.rb +21 -21
  63. data/lib/sapphire/WebAbstractions/Controls/Label.rb +8 -8
  64. data/lib/sapphire/WebAbstractions/Controls/RadioButton.rb +18 -18
  65. data/lib/sapphire/WebAbstractions/Controls/TableCell.rb +10 -0
  66. data/lib/sapphire/WebAbstractions/Controls/TextBox.rb +31 -31
  67. data/lib/sapphire/WebAbstractions/Controls/Title.rb +12 -12
  68. data/lib/sapphire/version.rb +1 -1
  69. metadata +13 -9
@@ -1,57 +1,57 @@
1
-
2
-
3
- module Sapphire
4
- module DataAbstractions
5
- class Database
6
-
7
- def Open(connection_string)
8
- @connection = WIN32OLE.new('ADODB.Connection')
9
- @connection.Open(connection_string)
10
- end
11
-
12
- def query(sql)
13
- recordset = WIN32OLE.new('ADODB.Recordset')
14
- recordset.Open(sql, @connection, 0 , 1)
15
-
16
- fields = []
17
-
18
- recordset.Fields.each do |field|
19
- fields << field.Name
20
- end
21
- begin
22
- recordset.MoveFirst
23
- data = recordset.GetRows
24
- rescue
25
- data = []
26
- end
27
-
28
- if(recordset.State != 0)
29
- recordset.Close
30
- end
31
-
32
- data = data.transpose
33
- records = []
34
-
35
- data.each do |row|
36
- y = 0
37
- record = Hash.new
38
- row.each do |column|
39
- if(column != nil)
40
- record.store fields[y].underscore.intern, column.to_s
41
- else
42
- record.store fields[y].underscore.intern, column
43
- end
44
- y += 1
45
- end
46
- records << record
47
- end
48
- records
49
- end
50
-
51
- def close
52
- @connection.Close
53
- end
54
- end
55
- end
56
- end
57
-
1
+
2
+
3
+ module Sapphire
4
+ module DataAbstractions
5
+ class Database
6
+
7
+ def Open(connection_string)
8
+ @connection = WIN32OLE.new('ADODB.Connection')
9
+ @connection.Open(connection_string)
10
+ end
11
+
12
+ def query(sql)
13
+ recordset = WIN32OLE.new('ADODB.Recordset')
14
+ recordset.Open(sql, @connection, 0 , 1)
15
+
16
+ fields = []
17
+
18
+ recordset.Fields.each do |field|
19
+ fields << field.Name
20
+ end
21
+ begin
22
+ recordset.MoveFirst
23
+ data = recordset.GetRows
24
+ rescue
25
+ data = []
26
+ end
27
+
28
+ if(recordset.State != 0)
29
+ recordset.Close
30
+ end
31
+
32
+ data = data.transpose
33
+ records = []
34
+
35
+ data.each do |row|
36
+ y = 0
37
+ record = Hash.new
38
+ row.each do |column|
39
+ if(column != nil)
40
+ record.store fields[y].underscore.intern, column.to_s
41
+ else
42
+ record.store fields[y].underscore.intern, column
43
+ end
44
+ y += 1
45
+ end
46
+ records << record
47
+ end
48
+ records
49
+ end
50
+
51
+ def close
52
+ @connection.Close
53
+ end
54
+ end
55
+ end
56
+ end
57
+
@@ -1,20 +1,20 @@
1
- module Sapphire
2
- module DataAbstractions
3
- module Query
4
- def Execute(block)
5
- x = self.Database.new
6
-
7
- x.Open $config[x.Connection]
8
-
9
- path = File.expand_path(self.Script, __FILE__)
10
- file = File.open(path)
11
- contents = file.read
12
- self.Tokenize(contents)
13
-
14
- results = x.query(contents)
15
- block.call results
16
- x.close
17
- end
18
- end
19
- end
1
+ module Sapphire
2
+ module DataAbstractions
3
+ module Query
4
+ def Execute(block)
5
+ x = self.Database.new
6
+
7
+ x.Open $config[x.Connection]
8
+
9
+ path = File.expand_path(self.Script, __FILE__)
10
+ file = File.open(path)
11
+ contents = file.read
12
+ self.Tokenize(contents)
13
+
14
+ results = x.query(contents)
15
+ block.call results
16
+ x.close
17
+ end
18
+ end
19
+ end
20
20
  end
@@ -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,37 +1,37 @@
1
- module Sapphire
2
- module Testing
3
- class ResultTree
4
-
5
- attr_accessor :results
6
- attr_accessor :type
7
-
8
- def initialize(text, result)
9
-
10
- @type = 'pass'
11
- @execution_time = 0
12
-
13
- if(result != nil)
14
- self.type = result.type
15
- @iconCls = "accept" if result.type == "pass"
16
- @iconCls = "delete" if result.type == "fail"
17
- @iconCls = "error" if result.type == "pending"
18
- @execution_time = result.execution_time
19
- @expanded = true
20
- @message = result.message
21
- @stack = result.stack
22
- end
23
- @text = text
24
- @results = []
25
- @leaf = true
26
-
27
- end
28
-
29
- def AddChild(node)
30
- @results << node
31
- @leaf = false
32
- end
33
-
34
- end
35
- end
36
- end
37
-
1
+ module Sapphire
2
+ module Testing
3
+ class ResultTree
4
+
5
+ attr_accessor :results
6
+ attr_accessor :type
7
+
8
+ def initialize(text, result)
9
+
10
+ @type = 'pass'
11
+ @execution_time = 0
12
+
13
+ if(result != nil)
14
+ self.type = result.type
15
+ @iconCls = "accept" if result.type == "pass"
16
+ @iconCls = "delete" if result.type == "fail"
17
+ @iconCls = "error" if result.type == "pending"
18
+ @execution_time = result.execution_time
19
+ @expanded = true
20
+ @message = result.message
21
+ @stack = result.stack
22
+ end
23
+ @text = text
24
+ @results = []
25
+ @leaf = true
26
+
27
+ end
28
+
29
+ def AddChild(node)
30
+ @results << node
31
+ @leaf = false
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+
@@ -1,74 +1,74 @@
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
- if(@hash.has_key?(:id))
11
- FindBy :id
12
- elsif (@hash.has_key?(:name))
13
- FindBy :name
14
- elsif (@hash.has_key?(:xpath))
15
- FindBy :xpath
16
- end
17
- end
18
-
19
- def FindWithoutWait
20
- if(@hash.has_key?(:id))
21
- FindWithoutWaitBy :id
22
- elsif (@hash.has_key?(:name))
23
- FindWithoutWaitBy :name
24
- elsif (@hash.has_key?(:xpath))
25
- FindWithoutWaitBy :xpath
26
- end
27
- end
28
-
29
- def FindWithoutWaitBy(symbol)
30
- @browser.find_element symbol, @hash.fetch(symbol)
31
- end
32
-
33
- def FindBy(symbol)
34
- wait = Selenium::WebDriver::Wait.new(:timeout => 10)
35
- element = wait.until { x = @browser.find_element symbol, @hash.fetch(symbol)
36
- x
37
- }
38
- end
39
-
40
- def FindParent(hash)
41
- if(hash.has_key?(:id))
42
- @browser.find_element :id, hash.fetch(:id)
43
- elsif (hash.has_key?(:name))
44
- @browser.find_element :name, hash.fetch(:name)
45
- elsif (hash.has_key?(:xpath))
46
- @browser.find_element :xpath, hash.fetch(:xpath)
47
- end
48
- end
49
-
50
- def Text
51
- text = self.Find
52
- text.text
53
- end
54
-
55
- def Click
56
- control = self.Find
57
- control.click
58
- end
59
-
60
- def MouseOver
61
- if(@hash.has_key?(:id))
62
- @browser.execute_script("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
63
- elsif (@hash.has_key?(:name))
64
- @browser.execute_script("document.getElementById('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
65
- elsif (@hash.has_key?(:xpath))
66
- @browser.execute_script("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
67
- end
68
- sleep(1)
69
- end
70
- end
71
- end
72
- end
73
-
74
-
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
+ if(@hash.has_key?(:id))
11
+ FindBy :id
12
+ elsif (@hash.has_key?(:name))
13
+ FindBy :name
14
+ elsif (@hash.has_key?(:xpath))
15
+ FindBy :xpath
16
+ end
17
+ end
18
+
19
+ def FindWithoutWait
20
+ if(@hash.has_key?(:id))
21
+ FindWithoutWaitBy :id
22
+ elsif (@hash.has_key?(:name))
23
+ FindWithoutWaitBy :name
24
+ elsif (@hash.has_key?(:xpath))
25
+ FindWithoutWaitBy :xpath
26
+ end
27
+ end
28
+
29
+ def FindWithoutWaitBy(symbol)
30
+ @browser.find_element symbol, @hash.fetch(symbol)
31
+ end
32
+
33
+ def FindBy(symbol)
34
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
35
+ element = wait.until { x = @browser.find_element symbol, @hash.fetch(symbol)
36
+ x
37
+ }
38
+ end
39
+
40
+ def FindParent(hash)
41
+ if(hash.has_key?(:id))
42
+ @browser.find_element :id, hash.fetch(:id)
43
+ elsif (hash.has_key?(:name))
44
+ @browser.find_element :name, hash.fetch(:name)
45
+ elsif (hash.has_key?(:xpath))
46
+ @browser.find_element :xpath, hash.fetch(:xpath)
47
+ end
48
+ end
49
+
50
+ def Text
51
+ text = self.Find
52
+ text.text
53
+ end
54
+
55
+ def Click
56
+ control = self.Find
57
+ control.click
58
+ end
59
+
60
+ def MouseOver
61
+ if(@hash.has_key?(:id))
62
+ @browser.execute_script("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
63
+ elsif (@hash.has_key?(:name))
64
+ @browser.execute_script("document.getElementById('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
65
+ elsif (@hash.has_key?(:xpath))
66
+ @browser.execute_script("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
67
+ end
68
+ sleep(1)
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+
@@ -1,47 +1,47 @@
1
- module Sapphire
2
- module WebAbstractions
3
- class Page
4
-
5
- attr_reader :fields
6
-
7
- def initialize(browser)
8
- @browser = browser
9
- @fields = []
10
- end
11
-
12
- def DropDown(*args)
13
- @fields << { args.first => DropDown.new(@browser, args[1]) }
14
- end
15
-
16
- def TextBox(*args)
17
- @fields << { args.first => TextBox.new(@browser, args[1]) }
18
- end
19
-
20
- def RadioButton(*args)
21
- @fields << { args.first => RadioButton.new(@browser, args[1]) }
22
- end
23
-
24
- def CheckBox(*args)
25
- @fields << { args.first => CheckBox.new(@browser, args[1]) }
26
- end
27
-
28
- def Button(*args)
29
- @fields << { args.first => Button.new(@browser, args[1]) }
30
- end
31
-
32
- def Label(*args)
33
- @fields << { args.first => Label.new(@browser, args[1]) }
34
- end
35
-
36
- def Image(*args)
37
- @fields << { args.first => Image.new(@browser, args[1]) }
38
- end
39
-
40
- def Hyperlink(*args)
41
- @fields << { args.first => Hyperlink.new(@browser, args[1]) }
42
- end
43
-
44
- end
45
- end
46
- end
47
-
1
+ module Sapphire
2
+ module WebAbstractions
3
+ class Page
4
+
5
+ attr_reader :fields
6
+
7
+ def initialize(browser)
8
+ @browser = browser
9
+ @fields = []
10
+ end
11
+
12
+ def DropDown(*args)
13
+ @fields << { args.first => DropDown.new(@browser, args[1]) }
14
+ end
15
+
16
+ def TextBox(*args)
17
+ @fields << { args.first => TextBox.new(@browser, args[1]) }
18
+ end
19
+
20
+ def RadioButton(*args)
21
+ @fields << { args.first => RadioButton.new(@browser, args[1]) }
22
+ end
23
+
24
+ def CheckBox(*args)
25
+ @fields << { args.first => CheckBox.new(@browser, args[1]) }
26
+ end
27
+
28
+ def Button(*args)
29
+ @fields << { args.first => Button.new(@browser, args[1]) }
30
+ end
31
+
32
+ def Label(*args)
33
+ @fields << { args.first => Label.new(@browser, args[1]) }
34
+ end
35
+
36
+ def Image(*args)
37
+ @fields << { args.first => Image.new(@browser, args[1]) }
38
+ end
39
+
40
+ def Hyperlink(*args)
41
+ @fields << { args.first => Hyperlink.new(@browser, args[1]) }
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+