epowd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/epo.gemspec +28 -0
- data/lib/common.rb +24 -0
- data/lib/epo.rb +39 -0
- metadata +47 -0
data/epo.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{epowd}
|
3
|
+
s.version = "0.0.1"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["Eason Han"]
|
7
|
+
s.date = %q{2012-06-28}
|
8
|
+
s.description = %q{Easy Page Object}
|
9
|
+
s.email = %q{nbkhic@gmail.com}
|
10
|
+
s.files = ["lib/common.rb", "epo.gemspec", "lib/epo.rb"]
|
11
|
+
s.has_rdoc = false
|
12
|
+
s.homepage = %q{http://github.com/nbkhic/epowd}
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
s.rubyforge_project = %q{epowd}
|
15
|
+
s.rubygems_version = %q{1.8.17}
|
16
|
+
s.summary = %q{Easy way for using page object with webdriver}
|
17
|
+
|
18
|
+
if s.respond_to? :specification_version then
|
19
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
20
|
+
s.specification_version = 3
|
21
|
+
|
22
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
23
|
+
else
|
24
|
+
end
|
25
|
+
else
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/common.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# EPO stands for Easy Page Object
|
2
|
+
# or Eason Page Object
|
3
|
+
|
4
|
+
require 'selenium-webdriver'
|
5
|
+
|
6
|
+
module EPO
|
7
|
+
class EPOError < StandardError; end
|
8
|
+
class NotValidDriverError < EPOError; end
|
9
|
+
|
10
|
+
VERY_SIMPLE_DSL = %w{
|
11
|
+
button
|
12
|
+
text_field
|
13
|
+
text_area
|
14
|
+
h1
|
15
|
+
h2
|
16
|
+
h3
|
17
|
+
h4
|
18
|
+
h5
|
19
|
+
span
|
20
|
+
select_list
|
21
|
+
radio
|
22
|
+
}
|
23
|
+
end #EPO
|
24
|
+
|
data/lib/epo.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path(File.join('.', 'lib', 'common'))
|
2
|
+
|
3
|
+
module EPO
|
4
|
+
module PageObject
|
5
|
+
attr_reader :dr, :url, :ui_methods
|
6
|
+
def initialize dr, domain
|
7
|
+
valid_driver? dr
|
8
|
+
@dr, @domain = dr, domain
|
9
|
+
end #initialize
|
10
|
+
|
11
|
+
def valid_driver? dr
|
12
|
+
raise NotValidDriverError unless dr.is_a?(Selenium::WebDriver::Driver)
|
13
|
+
end
|
14
|
+
|
15
|
+
def navigate_to path = '', timestamp=false
|
16
|
+
if timestamp
|
17
|
+
@dr.get(@domain + path + make_timestamp)
|
18
|
+
else
|
19
|
+
@dr.get(@domain + path)
|
20
|
+
end #if
|
21
|
+
end #navigate_to
|
22
|
+
|
23
|
+
def make_timestamp
|
24
|
+
"?#{Time.now.to_f.to_s}"
|
25
|
+
end #make_timestamp
|
26
|
+
|
27
|
+
def method_missing m, *param, &blk
|
28
|
+
if VERY_SIMPLE_DSL.any? {|dsl| m.match Regexp.new(dsl)}
|
29
|
+
if m[m.length - 1] == 's'
|
30
|
+
return @dr.find_elements *param
|
31
|
+
else
|
32
|
+
return @dr.find_element *param
|
33
|
+
end #if
|
34
|
+
end #if
|
35
|
+
@dr.send(m, *param, &blk) if @dr.respond_to?(m)
|
36
|
+
end #method_missing
|
37
|
+
end #PageObject
|
38
|
+
end #EPO
|
39
|
+
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: epowd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Eason Han
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-28 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Easy Page Object
|
15
|
+
email: nbkhic@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/common.rb
|
21
|
+
- epo.gemspec
|
22
|
+
- lib/epo.rb
|
23
|
+
homepage: http://github.com/nbkhic/epowd
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project: epowd
|
43
|
+
rubygems_version: 1.8.17
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Easy way for using page object with webdriver
|
47
|
+
test_files: []
|