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 CHANGED
@@ -1,5 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
+ *.sublime-project
4
+ *.sublime-workspace
3
5
  .bundle
4
6
  .config
5
7
  .yardoc
@@ -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
- SearchContext.new search_elements(_options), self
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
@@ -1,3 +1,3 @@
1
1
  module SeleniumSurfer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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
- version: 0.1.1
5
- prerelease:
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
- date: 2013-09-26 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
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
- - !ruby/object:Gem::Dependency
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
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
43
39
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.3'
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
- requirement: !ruby/object:Gem::Requirement
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
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
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
- files:
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
- homepage: ''
83
- licenses:
82
+ has_rdoc: true
83
+ homepage: ""
84
+ licenses:
84
85
  - MIT
85
86
  post_install_message:
86
87
  rdoc_options: []
87
- require_paths:
88
+
89
+ require_paths:
88
90
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- required_rubygems_version: !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ! '>='
99
- - !ruby/object:Gem::Version
100
- version: '0'
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.8.23
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
- has_rdoc:
113
+