sikulio 0.1.beta
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.
- data/.gitignore +52 -0
- data/.rspec +3 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +29 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/lib/sikulio.rb +13 -0
- data/lib/sikulio/component.rb +76 -0
- data/lib/sikulio/config.rb +12 -0
- data/lib/sikulio/element.rb +35 -0
- data/lib/sikulio/exceptions.rb +5 -0
- data/lib/sikulio/relative_element.rb +37 -0
- data/lib/sikulio/screen.rb +20 -0
- data/lib/sikulio/version.rb +3 -0
- data/sikulio.gemspec +19 -0
- data/spec/integration/hello_world_component_spec.rb +61 -0
- data/spec/integration/text_entry_component_spec.rb +74 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/images/clicking_is_fun/button_clicked_dialog.png +0 -0
- data/spec/support/images/clicking_is_fun/click_me_button.png +0 -0
- data/spec/support/images/my_component/some_button.png +0 -0
- data/spec/support/images/my_component/some_label.png +0 -0
- data/spec/support/images/typing_is_fun/enter_text_label.png +0 -0
- data/spec/support/images/typing_is_fun/expected_result.png +0 -0
- data/spec/unit/component_spec.rb +72 -0
- data/spec/unit/element_spec.rb +40 -0
- data/support/images/my_component/some_button.png +0 -0
- data/support/images/my_component/some_label.png +0 -0
- metadata +88 -0
data/.gitignore
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# gem build
|
2
|
+
sikulio-*.gem
|
3
|
+
|
4
|
+
# rcov generated
|
5
|
+
coverage
|
6
|
+
coverage.data
|
7
|
+
|
8
|
+
# rdoc generated
|
9
|
+
rdoc
|
10
|
+
|
11
|
+
# yard generated
|
12
|
+
doc
|
13
|
+
.yardoc
|
14
|
+
|
15
|
+
# bundler
|
16
|
+
.bundle
|
17
|
+
|
18
|
+
# jeweler generated
|
19
|
+
pkg
|
20
|
+
|
21
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
22
|
+
#
|
23
|
+
# * Create a file at ~/.gitignore
|
24
|
+
# * Include files you want ignored
|
25
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
26
|
+
#
|
27
|
+
# After doing this, these files will be ignored in all your git projects,
|
28
|
+
# saving you from having to 'pollute' every project you touch with them
|
29
|
+
#
|
30
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
31
|
+
#
|
32
|
+
# For MacOS:
|
33
|
+
#
|
34
|
+
#.DS_Store
|
35
|
+
|
36
|
+
# For TextMate
|
37
|
+
#*.tmproj
|
38
|
+
#tmtags
|
39
|
+
|
40
|
+
# For emacs:
|
41
|
+
*~
|
42
|
+
#\#*
|
43
|
+
#.\#*
|
44
|
+
|
45
|
+
# For vim:
|
46
|
+
*.swp
|
47
|
+
|
48
|
+
# For redcar:
|
49
|
+
#.redcar
|
50
|
+
|
51
|
+
# For rubinius:
|
52
|
+
#*.rbc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://www.rubygems.org/
|
3
|
+
specs:
|
4
|
+
active_support (3.0.0)
|
5
|
+
activesupport (= 3.0.0)
|
6
|
+
activesupport (3.0.0)
|
7
|
+
diff-lcs (1.1.3)
|
8
|
+
i18n (0.6.1)
|
9
|
+
rspec (2.12.0)
|
10
|
+
rspec-core (~> 2.12.0)
|
11
|
+
rspec-expectations (~> 2.12.0)
|
12
|
+
rspec-mocks (~> 2.12.0)
|
13
|
+
rspec-core (2.12.2)
|
14
|
+
rspec-expectations (2.12.1)
|
15
|
+
diff-lcs (~> 1.1.3)
|
16
|
+
rspec-mocks (2.12.2)
|
17
|
+
sikuli (0.3.0)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
java
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
active_support (~> 3.0.0)
|
24
|
+
bundler
|
25
|
+
i18n (~> 0.6.0)
|
26
|
+
redcarpet
|
27
|
+
rspec
|
28
|
+
sikuli (~> 0.3.0)
|
29
|
+
yard
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Matthew Hull
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
Sikulio: A framework for testing with Sikuli
|
2
|
+
============================================
|
3
|
+
|
4
|
+
Sikulio provides a Page Object style framework on top of Sikuli.
|
5
|
+
|
6
|
+
Still very much a work in progress.
|
7
|
+
|
8
|
+
Requirements
|
9
|
+
------------
|
10
|
+
|
11
|
+
* [JRuby] (http://jruby.org/download)
|
12
|
+
* [Sikuli Ruby] (https://github.com/chaslemley/sikuli_ruby)
|
13
|
+
|
14
|
+
See the [Sikuli Ruby README] (https://github.com/chaslemley/sikuli_ruby/blob/master/README.md) for details on installing and configuring Sikuli.
|
15
|
+
|
16
|
+
Installation
|
17
|
+
------------
|
18
|
+
|
19
|
+
gem install sikulio --pre
|
20
|
+
|
21
|
+
Usage
|
22
|
+
-----
|
23
|
+
|
24
|
+
require 'sikulio'
|
25
|
+
|
26
|
+
Sikulio::Config.image_root = 'images'
|
27
|
+
|
28
|
+
class MyComponent < Sikulio::Component
|
29
|
+
init_image_elements -- Adds a Sikulio element for each .png files found in images/my_component
|
30
|
+
|
31
|
+
relative_element :first_name_field,
|
32
|
+
:relative_to => :first_name_label,
|
33
|
+
:offset_x => 30, -- Look x pixels to the right of the relative_to element's center
|
34
|
+
:offset_y => 0 -- Look y pixels down from the relative_to element's center
|
35
|
+
end
|
36
|
+
|
37
|
+
comp = MyComponent.new
|
38
|
+
|
39
|
+
comp.first_name_label.click
|
40
|
+
comp.first_name_label.type 'Joe'
|
41
|
+
|
42
|
+
Running the test suite
|
43
|
+
----------------------
|
44
|
+
|
45
|
+
jruby -S bundle exec rspec spec
|
46
|
+
|
47
|
+
Take some chill time while the tests are running - the integration tests will launch a Java Swing application
|
48
|
+
and will fail if you take focus away.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/sikulio.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'java'
|
2
|
+
require 'sikuli'
|
3
|
+
require 'active_support/all'
|
4
|
+
|
5
|
+
require 'sikulio/version'
|
6
|
+
|
7
|
+
require 'sikulio/config'
|
8
|
+
require 'sikulio/exceptions'
|
9
|
+
require 'sikulio/screen'
|
10
|
+
|
11
|
+
require 'sikulio/element'
|
12
|
+
require 'sikulio/relative_element'
|
13
|
+
require 'sikulio/component'
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Sikulio
|
2
|
+
|
3
|
+
##
|
4
|
+
# Represents a segment of the UI. For example:
|
5
|
+
# * Web page
|
6
|
+
# * Modal dialog
|
7
|
+
# * Windows toolbar
|
8
|
+
#
|
9
|
+
# Exposes a DSL for initializing and accessing Sikulio elements
|
10
|
+
#
|
11
|
+
# The following example MyComponent class will include an auto-generated Sikulio element for
|
12
|
+
# each image file located in the my_component folder under the image_root folder. Additionally,
|
13
|
+
# defines a text entry field relative to the some_label element.
|
14
|
+
#
|
15
|
+
# Sikulio::Config.image_root = 'image_root'
|
16
|
+
#
|
17
|
+
# class MyComponent < Component
|
18
|
+
# ...
|
19
|
+
# init_image_elements
|
20
|
+
#
|
21
|
+
# relative_element :some_entry_field,
|
22
|
+
# :relative_to => :some_label,
|
23
|
+
# :offset_x => 30,
|
24
|
+
# :offset_y => 0
|
25
|
+
# ...
|
26
|
+
|
27
|
+
class Component
|
28
|
+
|
29
|
+
# A Sikuli screen instance that will be shared by this component's elements
|
30
|
+
attr_accessor :screen
|
31
|
+
|
32
|
+
# The root folder under which GUI images are stored
|
33
|
+
cattr_accessor :image_root
|
34
|
+
|
35
|
+
def component_path
|
36
|
+
@component_path ||= self.class.to_s.underscore
|
37
|
+
end
|
38
|
+
|
39
|
+
def component_path=(path)
|
40
|
+
@component_path = path
|
41
|
+
end
|
42
|
+
|
43
|
+
# Sets the screen attribute for this component
|
44
|
+
# Defaults to the singleton screen provided by Sikulio::Screen
|
45
|
+
def initialize(screen = Sikulio::Screen.instance.screen)
|
46
|
+
self.screen = screen
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes Sikulio image elements corresponding to
|
50
|
+
# the images in the specified location
|
51
|
+
def self.init_image_elements(component_path=nil, image_root=Sikulio::Config.image_root)
|
52
|
+
|
53
|
+
component_path ||= self.to_s.underscore
|
54
|
+
|
55
|
+
images = Dir[File.join(image_root, component_path, "/*.png")]
|
56
|
+
|
57
|
+
images.each do |i|
|
58
|
+
el_name = File.basename(i, ".png")
|
59
|
+
define_method(el_name) { Element.new self.instance_variable_get(:@screen), i }
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# Defines an element positioned relative to another element
|
65
|
+
# e.g. a text input field, relative to the field label
|
66
|
+
def self.relative_element(el_name, params = {})
|
67
|
+
|
68
|
+
define_method(el_name) do
|
69
|
+
RelativeElement.new self.instance_variable_get(:@screen),
|
70
|
+
self.send(params[:relative_to]).ident,
|
71
|
+
params[:offset_x],
|
72
|
+
params[:offset_y]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Sikulio
|
2
|
+
class Element
|
3
|
+
|
4
|
+
attr_accessor :screen
|
5
|
+
|
6
|
+
# The identifier (e.g. filename or OCR string) which Sikuli will use to locate the element
|
7
|
+
attr_accessor :ident
|
8
|
+
|
9
|
+
# Sets screen and image file path
|
10
|
+
def initialize(screen, ident)
|
11
|
+
self.screen = screen
|
12
|
+
self.ident = ident
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_relative_element(offset_x, offset_y)
|
16
|
+
Sikulio::RelativeElement.new screen, ident, offset_x, offset_y
|
17
|
+
end
|
18
|
+
|
19
|
+
# Click on this element
|
20
|
+
def click
|
21
|
+
screen.click ident
|
22
|
+
end
|
23
|
+
|
24
|
+
# Find this element on screen
|
25
|
+
def find
|
26
|
+
screen.find ident
|
27
|
+
end
|
28
|
+
|
29
|
+
# Send keystrokes
|
30
|
+
def type(keystrokes)
|
31
|
+
screen.type keystrokes
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Sikulio
|
2
|
+
class RelativeElement
|
3
|
+
|
4
|
+
attr_accessor :screen
|
5
|
+
attr_accessor :ident
|
6
|
+
attr_accessor :offset_x
|
7
|
+
attr_accessor :offset_y
|
8
|
+
|
9
|
+
# Sets screen and image file path
|
10
|
+
def initialize(screen, ident, offset_x, offset_y)
|
11
|
+
self.screen = screen
|
12
|
+
self.ident = ident
|
13
|
+
self.offset_x = offset_x
|
14
|
+
self.offset_y = offset_y
|
15
|
+
end
|
16
|
+
|
17
|
+
# Click on this element
|
18
|
+
def click
|
19
|
+
start_point = screen.find ident
|
20
|
+
click_x = start_point.x + offset_x
|
21
|
+
click_y = start_point.y + offset_y
|
22
|
+
|
23
|
+
screen.click click_x, click_y
|
24
|
+
end
|
25
|
+
|
26
|
+
# Find this element on screen
|
27
|
+
def find
|
28
|
+
screen.find ident
|
29
|
+
end
|
30
|
+
|
31
|
+
# Send keystrokes to element
|
32
|
+
def type(keystrokes)
|
33
|
+
screen.type keystrokes
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Sikulio
|
4
|
+
|
5
|
+
# Provides consistent access to a single Sikuli screen object
|
6
|
+
#
|
7
|
+
# Sikuli throws intermittent errors if multiple screen objects are in use
|
8
|
+
# Providing singleton access to a screen prevents this from occuring
|
9
|
+
# Usage: Sikulio::Screen.instance
|
10
|
+
|
11
|
+
class Screen
|
12
|
+
include Singleton
|
13
|
+
|
14
|
+
attr_accessor :screen
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
self.screen = Sikuli::Screen.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/sikulio.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sikulio/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sikulio"
|
8
|
+
gem.version = Sikulio::VERSION
|
9
|
+
gem.authors = ["Matthew Hull"]
|
10
|
+
gem.email = ["hull.matt@gmail.com"]
|
11
|
+
gem.description = %q{A Page Object style framework leveraging Sikuli}
|
12
|
+
gem.summary = %q{Test automation framework for all the things}
|
13
|
+
gem.homepage = "https://github.com/matthull/sikulio"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
include Java
|
4
|
+
|
5
|
+
import javax.swing.JFrame
|
6
|
+
import javax.swing.JPanel
|
7
|
+
import javax.swing.JButton
|
8
|
+
import javax.swing.JOptionPane
|
9
|
+
|
10
|
+
class ClickingIsFunApp < JFrame
|
11
|
+
def initialize
|
12
|
+
super "Clicking Is Fun"
|
13
|
+
|
14
|
+
self.initUI
|
15
|
+
end
|
16
|
+
|
17
|
+
def initUI
|
18
|
+
|
19
|
+
panel = JPanel.new
|
20
|
+
self.getContentPane.add panel
|
21
|
+
panel.setLayout nil
|
22
|
+
|
23
|
+
button = JButton.new "Click Me"
|
24
|
+
button.setBounds 100,60,100,30
|
25
|
+
|
26
|
+
button.addActionListener do |e|
|
27
|
+
JOptionPane.showMessageDialog panel, "Button Clicked", "An Informative Message", JOptionPane::INFORMATION_MESSAGE
|
28
|
+
end
|
29
|
+
|
30
|
+
panel.add button
|
31
|
+
|
32
|
+
self.setSize 300,200
|
33
|
+
self.setDefaultCloseOperation JFrame::DISPOSE_ON_CLOSE
|
34
|
+
self.setLocationRelativeTo nil
|
35
|
+
self.setVisible true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe Component do
|
41
|
+
|
42
|
+
Sikulio::Config.image_root = File.join(File.dirname(__FILE__), '..', 'support', 'images')
|
43
|
+
|
44
|
+
class ClickingIsFun < Component
|
45
|
+
init_image_elements
|
46
|
+
end
|
47
|
+
|
48
|
+
it "clicks the image" do
|
49
|
+
|
50
|
+
app = ClickingIsFunApp.new
|
51
|
+
|
52
|
+
cif = ClickingIsFun.new
|
53
|
+
|
54
|
+
cif.click_me_button.click
|
55
|
+
|
56
|
+
cif.button_clicked_dialog.find
|
57
|
+
|
58
|
+
app.dispose
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
include Java
|
4
|
+
|
5
|
+
import javax.swing.JFrame
|
6
|
+
import javax.swing.JPanel
|
7
|
+
import javax.swing.JOptionPane
|
8
|
+
import javax.swing.JTextField
|
9
|
+
import javax.swing.JLabel
|
10
|
+
|
11
|
+
class TypingIsFunApp < JFrame
|
12
|
+
def initialize
|
13
|
+
super "Typing Is Fun"
|
14
|
+
|
15
|
+
self.initUI
|
16
|
+
end
|
17
|
+
|
18
|
+
def initUI
|
19
|
+
|
20
|
+
panel = JPanel.new
|
21
|
+
panel.setLayout nil
|
22
|
+
|
23
|
+
wrongTextField = JTextField.new 10
|
24
|
+
wrongTextField.setBounds 10,20,20,30
|
25
|
+
panel.add wrongTextField
|
26
|
+
|
27
|
+
label = JLabel.new "Enter Text"
|
28
|
+
label.setBounds 10,80,60,90
|
29
|
+
|
30
|
+
panel.add label
|
31
|
+
|
32
|
+
textField = JTextField.new 30
|
33
|
+
textField.setBounds 78,80,180,90
|
34
|
+
panel.add textField
|
35
|
+
|
36
|
+
self.add panel
|
37
|
+
self.pack
|
38
|
+
|
39
|
+
self.setSize 300,300
|
40
|
+
self.setDefaultCloseOperation JFrame::DISPOSE_ON_CLOSE
|
41
|
+
self.setLocationRelativeTo nil
|
42
|
+
self.setVisible true
|
43
|
+
|
44
|
+
wrongTextField.requestFocus
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe Component do
|
50
|
+
|
51
|
+
Sikulio::Config.image_root = File.join(File.dirname(__FILE__), '..', 'support', 'images')
|
52
|
+
|
53
|
+
class TypingIsFun < Component
|
54
|
+
init_image_elements 'typing_is_fun'
|
55
|
+
relative_element :enter_text_field,
|
56
|
+
:relative_to => :enter_text_label,
|
57
|
+
:offset_x => 100,
|
58
|
+
:offset_y => 0
|
59
|
+
end
|
60
|
+
|
61
|
+
it "clicks the image" do
|
62
|
+
|
63
|
+
app = TypingIsFunApp.new
|
64
|
+
tif = TypingIsFun.new
|
65
|
+
|
66
|
+
tif.enter_text_field.click
|
67
|
+
tif.enter_text_field.type "blah and blah"
|
68
|
+
|
69
|
+
tif.expected_result.find
|
70
|
+
|
71
|
+
app.dispose
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
end
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
require 'sikulio'
|
20
|
+
include Sikulio
|
Binary file
|
Binary file
|
File without changes
|
File without changes
|
Binary file
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Component do
|
4
|
+
|
5
|
+
Sikulio::Config.image_root = File.join(File.dirname(__FILE__), '..', 'support', 'images')
|
6
|
+
|
7
|
+
describe 'component_path' do
|
8
|
+
|
9
|
+
class MyComponent < Component; end
|
10
|
+
|
11
|
+
subject(:comp) { MyComponent.new }
|
12
|
+
|
13
|
+
its(:component_path) { should == 'my_component' }
|
14
|
+
|
15
|
+
it 'can be set manually' do
|
16
|
+
comp.component_path = 'foo'
|
17
|
+
comp.component_path.should == 'foo'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#init_image_elements', 'when component path and image root are manually specified' do
|
22
|
+
|
23
|
+
class ManuallyConfiguredComponent < Component
|
24
|
+
init_image_elements 'my_component', Sikulio::Config.image_root
|
25
|
+
end
|
26
|
+
|
27
|
+
subject { ManuallyConfiguredComponent.new }
|
28
|
+
|
29
|
+
its(:some_button) { should respond_to :click }
|
30
|
+
its(:some_label) { should respond_to :click }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#init_image_elements', 'when only component path is manually specified' do
|
34
|
+
|
35
|
+
class ConfiguredComponentPathComponent < Component
|
36
|
+
init_image_elements 'my_component'
|
37
|
+
end
|
38
|
+
|
39
|
+
subject { ConfiguredComponentPathComponent.new }
|
40
|
+
|
41
|
+
its(:some_button) { should respond_to :click }
|
42
|
+
its(:some_label) { should respond_to :click }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#init_image_elements', 'when no paths are specified' do
|
46
|
+
|
47
|
+
class MyComponent < Component
|
48
|
+
init_image_elements
|
49
|
+
end
|
50
|
+
|
51
|
+
subject { MyComponent.new }
|
52
|
+
|
53
|
+
its(:some_button) { should respond_to :click }
|
54
|
+
its(:some_label) { should respond_to :click }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#relative_element' do
|
58
|
+
|
59
|
+
class MyComponent < Component
|
60
|
+
init_image_elements
|
61
|
+
|
62
|
+
relative_element :some_field,
|
63
|
+
:relative_to => :some_label,
|
64
|
+
:offset_x => 20,
|
65
|
+
:offset_y => 0
|
66
|
+
end
|
67
|
+
|
68
|
+
subject { MyComponent.new }
|
69
|
+
|
70
|
+
it { should respond_to :some_field }
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe Element do
|
4
|
+
|
5
|
+
let(:file) { File.join(File.dirname(__FILE__), "images", "my_pic.png") }
|
6
|
+
let(:screen) { Sikuli::Screen.new }
|
7
|
+
|
8
|
+
before do
|
9
|
+
@el = Element.new(screen, file)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#initialize" do
|
13
|
+
it "sets its screen and ident based on the provided values" do
|
14
|
+
@el.screen.should == screen
|
15
|
+
@el.ident.should == file
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#click" do
|
20
|
+
it "clicks itself" do
|
21
|
+
@el.screen.should_receive(:click).with(file)
|
22
|
+
@el.click
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#find" do
|
27
|
+
it "finds itself" do
|
28
|
+
@el.screen.should_receive(:find).with(file)
|
29
|
+
@el.find
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#type" do
|
34
|
+
it "sends some keystrokes" do
|
35
|
+
@el.screen.should_receive(:type).with("blah")
|
36
|
+
@el.type "blah"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sikulio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: 4
|
5
|
+
version: 0.1.beta
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matthew Hull
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A Page Object style framework leveraging Sikuli
|
15
|
+
email:
|
16
|
+
- hull.matt@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- lib/sikulio.rb
|
29
|
+
- lib/sikulio/component.rb
|
30
|
+
- lib/sikulio/config.rb
|
31
|
+
- lib/sikulio/element.rb
|
32
|
+
- lib/sikulio/exceptions.rb
|
33
|
+
- lib/sikulio/relative_element.rb
|
34
|
+
- lib/sikulio/screen.rb
|
35
|
+
- lib/sikulio/version.rb
|
36
|
+
- sikulio.gemspec
|
37
|
+
- spec/integration/hello_world_component_spec.rb
|
38
|
+
- spec/integration/text_entry_component_spec.rb
|
39
|
+
- spec/spec_helper.rb
|
40
|
+
- spec/support/images/clicking_is_fun/button_clicked_dialog.png
|
41
|
+
- spec/support/images/clicking_is_fun/click_me_button.png
|
42
|
+
- spec/support/images/my_component/some_button.png
|
43
|
+
- spec/support/images/my_component/some_label.png
|
44
|
+
- spec/support/images/typing_is_fun/enter_text_label.png
|
45
|
+
- spec/support/images/typing_is_fun/expected_result.png
|
46
|
+
- spec/unit/component_spec.rb
|
47
|
+
- spec/unit/element_spec.rb
|
48
|
+
- support/images/my_component/some_button.png
|
49
|
+
- support/images/my_component/some_label.png
|
50
|
+
homepage: https://github.com/matthull/sikulio
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: !binary |-
|
61
|
+
MA==
|
62
|
+
none: false
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - !binary |-
|
66
|
+
Pg==
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.1
|
69
|
+
none: false
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.25
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Test automation framework for all the things
|
76
|
+
test_files:
|
77
|
+
- spec/integration/hello_world_component_spec.rb
|
78
|
+
- spec/integration/text_entry_component_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/support/images/clicking_is_fun/button_clicked_dialog.png
|
81
|
+
- spec/support/images/clicking_is_fun/click_me_button.png
|
82
|
+
- spec/support/images/my_component/some_button.png
|
83
|
+
- spec/support/images/my_component/some_label.png
|
84
|
+
- spec/support/images/typing_is_fun/enter_text_label.png
|
85
|
+
- spec/support/images/typing_is_fun/expected_result.png
|
86
|
+
- spec/unit/component_spec.rb
|
87
|
+
- spec/unit/element_spec.rb
|
88
|
+
has_rdoc:
|