selenium_surfer 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/lib/selenium_surfer/search_context.rb +31 -1
- data/lib/selenium_surfer/version.rb +1 -1
- metadata +70 -65
data/.gitignore
CHANGED
@@ -10,6 +10,8 @@ module SeleniumSurfer
|
|
10
10
|
include Enumerable
|
11
11
|
extend Forwardable
|
12
12
|
|
13
|
+
TIMEOUT = 10.0 # Default timeout for waiting operations
|
14
|
+
|
13
15
|
def initialize(_elements, _parent)
|
14
16
|
@elements = _elements
|
15
17
|
@parent = _parent
|
@@ -40,7 +42,35 @@ module SeleniumSurfer
|
|
40
42
|
# searches for elements that match a given selector
|
41
43
|
def search(_selector=nil, _options={})
|
42
44
|
_options[:css] = _selector if _selector
|
43
|
-
|
45
|
+
|
46
|
+
wait_mode = _options.delete :wait
|
47
|
+
if wait_mode
|
48
|
+
|
49
|
+
# retrieve timeout
|
50
|
+
timeout = _options.delete :timeout
|
51
|
+
timeout = TIMEOUT if timeout.nil?
|
52
|
+
|
53
|
+
# use a selenium timeout
|
54
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout)
|
55
|
+
wait.until do
|
56
|
+
new_elements = search_elements _options
|
57
|
+
|
58
|
+
# test wait condition
|
59
|
+
ok = case wait_mode
|
60
|
+
when :present then (new_elements.length > 0)
|
61
|
+
when :visible then (new_elements.length > 0 and new_elements.first.displayed?)
|
62
|
+
when :enabled then (new_elements.length > 0 and new_elements.first.displayed? and new_elements.first.enabled?)
|
63
|
+
when :not_present then (new_elements.length == 0)
|
64
|
+
when :not_visible then (not new_elements.any? { |e| e.displayed? })
|
65
|
+
else
|
66
|
+
raise SetupError.new "Invalid wait mode '#{wait_mode}'"
|
67
|
+
end
|
68
|
+
|
69
|
+
SearchContext.new new_elements, self if ok
|
70
|
+
end
|
71
|
+
else
|
72
|
+
SearchContext.new search_elements(_options), self
|
73
|
+
end
|
44
74
|
end
|
45
75
|
|
46
76
|
# clears and sends_keys to this context main element
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_surfer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Ignacio Baixas
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2013-10-24 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: selenium-webdriver
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.33.0
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
requirements:
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
27
25
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 33
|
30
|
+
- 0
|
29
31
|
version: 2.33.0
|
30
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
31
35
|
name: bundler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '1.3'
|
38
|
-
type: :development
|
39
36
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
requirements:
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
43
39
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
-
|
47
|
-
|
48
|
-
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 3
|
44
|
+
version: "1.3"
|
54
45
|
type: :development
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
55
49
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
62
59
|
description: Selenium Surfer Robots!
|
63
|
-
email:
|
60
|
+
email:
|
64
61
|
- ignacio@platan.us
|
65
62
|
executables: []
|
63
|
+
|
66
64
|
extensions: []
|
65
|
+
|
67
66
|
extra_rdoc_files: []
|
68
|
-
|
67
|
+
|
68
|
+
files:
|
69
69
|
- .gitignore
|
70
70
|
- Gemfile
|
71
71
|
- LICENSE.txt
|
@@ -79,30 +79,35 @@ files:
|
|
79
79
|
- lib/selenium_surfer/surf_context.rb
|
80
80
|
- lib/selenium_surfer/version.rb
|
81
81
|
- selenium_surfer.gemspec
|
82
|
-
|
83
|
-
|
82
|
+
has_rdoc: true
|
83
|
+
homepage: ""
|
84
|
+
licenses:
|
84
85
|
- MIT
|
85
86
|
post_install_message:
|
86
87
|
rdoc_options: []
|
87
|
-
|
88
|
+
|
89
|
+
require_paths:
|
88
90
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
101
105
|
requirements: []
|
106
|
+
|
102
107
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.3.6
|
104
109
|
signing_key:
|
105
110
|
specification_version: 3
|
106
111
|
summary: Base infrastructure for webdriver robots with session managing and rich DSL
|
107
112
|
test_files: []
|
108
|
-
|
113
|
+
|