watir-webdriver 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/lib/watir-webdriver/browser.rb +2 -2
- data/lib/watir-webdriver/element_collection.rb +0 -1
- data/lib/watir-webdriver/elements/button.rb +5 -2
- data/lib/watir-webdriver/elements/element.rb +16 -9
- data/lib/watir-webdriver/elements/frame.rb +2 -2
- data/lib/watir-webdriver/locators/button_locator.rb +5 -4
- data/lib/watir-webdriver/locators/child_row_locator.rb +1 -1
- data/lib/watir-webdriver/locators/element_locator.rb +8 -6
- data/lib/watir-webdriver/locators/text_field_locator.rb +5 -3
- data/lib/watir-webdriver/version.rb +1 -1
- data/lib/watir-webdriver/xpath_support.rb +2 -2
- data/spec/browser_spec.rb +2 -2
- data/spec/element_spec.rb +2 -2
- data/spec/html/keylogger.html +1 -1
- data/spec/implementation.rb +6 -0
- data/watir-webdriver.gemspec +1 -1
- metadata +4 -5
- data/lib/watir-webdriver/extensions/wait.rb +0 -1
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -120,7 +120,7 @@ module Watir
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def execute_script(script, *args)
|
123
|
-
args.map! { |e| e.kind_of?(Watir::Element) ? e.
|
123
|
+
args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e }
|
124
124
|
returned = @driver.execute_script(script, *args)
|
125
125
|
|
126
126
|
wrap_elements_in(returned)
|
@@ -190,7 +190,7 @@ module Watir
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def wrap_element(element)
|
193
|
-
Watir.element_class_for(element.tag_name).new(self, :element => element)
|
193
|
+
Watir.element_class_for(element.tag_name.downcase).new(self, :element => element)
|
194
194
|
end
|
195
195
|
|
196
196
|
end # Browser
|
@@ -23,13 +23,16 @@ module Watir
|
|
23
23
|
|
24
24
|
def text
|
25
25
|
assert_exists
|
26
|
-
|
26
|
+
|
27
|
+
tn = @element.tag_name.downcase
|
28
|
+
|
29
|
+
case tn
|
27
30
|
when 'input'
|
28
31
|
@element.attribute(:value)
|
29
32
|
when 'button'
|
30
33
|
@element.text
|
31
34
|
else
|
32
|
-
raise Exception::Error, "unknown tag name for button: #{
|
35
|
+
raise Exception::Error, "unknown tag name for button: #{tn}"
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
@@ -47,7 +47,7 @@ module Watir
|
|
47
47
|
return false unless other.kind_of? self.class
|
48
48
|
|
49
49
|
assert_exists
|
50
|
-
@element == other.
|
50
|
+
@element == other.wd
|
51
51
|
end
|
52
52
|
alias_method :eql?, :==
|
53
53
|
|
@@ -62,7 +62,7 @@ module Watir
|
|
62
62
|
|
63
63
|
def tag_name
|
64
64
|
assert_exists
|
65
|
-
@element.tag_name
|
65
|
+
@element.tag_name.downcase
|
66
66
|
end
|
67
67
|
|
68
68
|
def click
|
@@ -102,7 +102,7 @@ module Watir
|
|
102
102
|
|
103
103
|
begin
|
104
104
|
@element.value || ''
|
105
|
-
rescue WebDriver::Error::
|
105
|
+
rescue WebDriver::Error::InvalidElementStateError
|
106
106
|
""
|
107
107
|
end
|
108
108
|
end
|
@@ -145,19 +145,26 @@ module Watir
|
|
145
145
|
e = driver.execute_script "return arguments[0].parentNode", @element
|
146
146
|
|
147
147
|
if e.kind_of?(WebDriver::Element)
|
148
|
-
Watir.element_class_for(e.tag_name).new(@parent, :element => e)
|
148
|
+
Watir.element_class_for(e.tag_name.downcase).new(@parent, :element => e)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
+
#
|
153
|
+
# @api private
|
154
|
+
#
|
155
|
+
|
152
156
|
def driver
|
153
157
|
@parent.driver
|
154
158
|
end
|
155
159
|
|
156
|
-
|
160
|
+
#
|
161
|
+
# @api private
|
162
|
+
#
|
163
|
+
|
164
|
+
def wd
|
157
165
|
assert_exists
|
158
166
|
@element
|
159
167
|
end
|
160
|
-
alias_method :wd, :element # ensures duck typing with Browser
|
161
168
|
|
162
169
|
#
|
163
170
|
# Returns true if this element is visible on the page
|
@@ -183,7 +190,7 @@ module Watir
|
|
183
190
|
assert_exists
|
184
191
|
@element.style property
|
185
192
|
else
|
186
|
-
attribute_value("style")
|
193
|
+
attribute_value("style").to_s.strip
|
187
194
|
end
|
188
195
|
end
|
189
196
|
|
@@ -200,8 +207,8 @@ module Watir
|
|
200
207
|
#
|
201
208
|
|
202
209
|
def to_subtype
|
203
|
-
elem =
|
204
|
-
tag_name = elem.tag_name
|
210
|
+
elem = wd()
|
211
|
+
tag_name = elem.tag_name.downcase
|
205
212
|
|
206
213
|
klass = nil
|
207
214
|
|
@@ -50,10 +50,11 @@ module Watir
|
|
50
50
|
|
51
51
|
def matches_selector?(element, rx_selector)
|
52
52
|
rx_selector = rx_selector.dup
|
53
|
+
tag_name = element.tag_name.downcase
|
53
54
|
|
54
55
|
[:value, :caption].each do |key|
|
55
56
|
if rx_selector.has_key?(key)
|
56
|
-
correct_key =
|
57
|
+
correct_key = tag_name == 'button' ? :text : :value
|
57
58
|
rx_selector[correct_key] = rx_selector.delete(key)
|
58
59
|
end
|
59
60
|
end
|
@@ -61,12 +62,12 @@ module Watir
|
|
61
62
|
super
|
62
63
|
end
|
63
64
|
|
64
|
-
def tag_name_matches?(
|
65
|
-
!!(/^(input|button)$/ ===
|
65
|
+
def tag_name_matches?(tag_name, _)
|
66
|
+
!!(/^(input|button)$/ === tag_name)
|
66
67
|
end
|
67
68
|
|
68
69
|
def validate_element(element)
|
69
|
-
return if element.tag_name == "input" && !Button::VALID_TYPES.include?(element.attribute(:type))
|
70
|
+
return if element.tag_name.downcase == "input" && !Button::VALID_TYPES.include?(element.attribute(:type))
|
70
71
|
super
|
71
72
|
end
|
72
73
|
|
@@ -16,7 +16,7 @@ module Watir
|
|
16
16
|
selectors.delete(:tag_name) || raise("internal error: no tag_name?!")
|
17
17
|
|
18
18
|
expressions = %w[./tr]
|
19
|
-
unless %w[tbody tfoot thead].include?(@wd.tag_name)
|
19
|
+
unless %w[tbody tfoot thead].include?(@wd.tag_name.downcase)
|
20
20
|
expressions += %w[./tbody/tr ./thead/tr ./tfoot/tr]
|
21
21
|
end
|
22
22
|
|
@@ -168,7 +168,7 @@ module Watir
|
|
168
168
|
when :text
|
169
169
|
element.text
|
170
170
|
when :tag_name
|
171
|
-
element.tag_name
|
171
|
+
element.tag_name.downcase
|
172
172
|
when :href
|
173
173
|
(href = element.attribute(:href)) && href.strip
|
174
174
|
else
|
@@ -239,7 +239,7 @@ module Watir
|
|
239
239
|
return unless selector.empty? # multiple attributes
|
240
240
|
|
241
241
|
element = @wd.find_element(:id, id)
|
242
|
-
return if tag_name && !tag_name_matches?(element, tag_name)
|
242
|
+
return if tag_name && !tag_name_matches?(element.tag_name.downcase, tag_name)
|
243
243
|
|
244
244
|
element
|
245
245
|
rescue WebDriver::Error::NoSuchElementError => wde
|
@@ -250,8 +250,8 @@ module Watir
|
|
250
250
|
@wd.find_elements(:xpath => ".//*")
|
251
251
|
end
|
252
252
|
|
253
|
-
def tag_name_matches?(
|
254
|
-
tag_name ===
|
253
|
+
def tag_name_matches?(element_tag_name, tag_name)
|
254
|
+
tag_name === element_tag_name
|
255
255
|
end
|
256
256
|
|
257
257
|
def valid_attribute?(attribute)
|
@@ -317,9 +317,11 @@ module Watir
|
|
317
317
|
|
318
318
|
def validate_element(element)
|
319
319
|
tn = @selector[:tag_name]
|
320
|
-
|
320
|
+
element_tag_name = element.tag_name.downcase
|
321
321
|
|
322
|
-
if
|
322
|
+
return if tn && !tag_name_matches?(element_tag_name, tn)
|
323
|
+
|
324
|
+
if element_tag_name == 'input'
|
323
325
|
return if @selector[:type] && @selector[:type] != element.attribute(:type)
|
324
326
|
end
|
325
327
|
|
@@ -46,9 +46,11 @@ module Watir
|
|
46
46
|
def matches_selector?(element, rx_selector)
|
47
47
|
rx_selector = rx_selector.dup
|
48
48
|
|
49
|
+
tag_name = element.tag_name.downcase
|
50
|
+
|
49
51
|
[:text, :value, :label].each do |key|
|
50
52
|
if rx_selector.has_key?(key)
|
51
|
-
correct_key =
|
53
|
+
correct_key = tag_name == 'input' ? :value : :text
|
52
54
|
rx_selector[correct_key] = rx_selector.delete(key)
|
53
55
|
end
|
54
56
|
end
|
@@ -58,8 +60,8 @@ module Watir
|
|
58
60
|
|
59
61
|
VALID_TEXT_FIELD_TAGS = %w[input textarea]
|
60
62
|
|
61
|
-
def tag_name_matches?(
|
62
|
-
VALID_TEXT_FIELD_TAGS.include?(
|
63
|
+
def tag_name_matches?(tag_name, _)
|
64
|
+
VALID_TEXT_FIELD_TAGS.include?(tag_name)
|
63
65
|
end
|
64
66
|
end # TextFieldLocator
|
65
67
|
end # Watir
|
@@ -9,7 +9,7 @@ module Watir
|
|
9
9
|
|
10
10
|
def element_by_xpath(xpath)
|
11
11
|
e = wd.find_element(:xpath, xpath)
|
12
|
-
Watir.element_class_for(e.tag_name).new(self, :element => e)
|
12
|
+
Watir.element_class_for(e.tag_name.downcase).new(self, :element => e)
|
13
13
|
rescue WebDriver::Error::NoSuchElementError
|
14
14
|
Element.new(self, :xpath => xpath)
|
15
15
|
end
|
@@ -20,7 +20,7 @@ module Watir
|
|
20
20
|
|
21
21
|
def elements_by_xpath(xpath)
|
22
22
|
wd.find_elements(:xpath, xpath).map do |e|
|
23
|
-
Watir.element_class_for(e.tag_name).new(self, :element => e)
|
23
|
+
Watir.element_class_for(e.tag_name.downcase).new(self, :element => e)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/spec/browser_spec.rb
CHANGED
@@ -66,7 +66,7 @@ describe Watir::Browser do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
not_compliant_on [:webdriver, :chrome] do
|
70
70
|
it "raises an error when trying to interact with a closed browser" do
|
71
71
|
b = WatirSpec.new_browser
|
72
72
|
b.goto(WatirSpec.files + "/definition_lists.html")
|
@@ -108,7 +108,7 @@ describe Watir::Browser do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
describe "#ready_state" do
|
111
|
-
it "gets the
|
111
|
+
it "gets the document's readyState property" do
|
112
112
|
browser.should_receive(:execute_script).with('return document.readyState')
|
113
113
|
browser.ready_state
|
114
114
|
end
|
data/spec/element_spec.rb
CHANGED
@@ -5,8 +5,8 @@ describe Watir::Element do
|
|
5
5
|
describe "#send_keys" do
|
6
6
|
it "sends keystrokes to the element" do
|
7
7
|
browser.goto("file://" + File.expand_path("html/keylogger.html", File.dirname(__FILE__)))
|
8
|
-
browser.
|
9
|
-
browser.
|
8
|
+
browser.element(:id, 'receiver').send_keys("hello world")
|
9
|
+
browser.element(:id, 'output').ps.size.should == 11
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
data/spec/html/keylogger.html
CHANGED
data/spec/implementation.rb
CHANGED
@@ -8,6 +8,12 @@ WatirSpec.implementation do |imp|
|
|
8
8
|
imp.browser_class = Watir::Browser
|
9
9
|
imp.browser_args = [browser]
|
10
10
|
|
11
|
+
case browser
|
12
|
+
when :chromedriver
|
13
|
+
# assumes the chromedriver server is running on the default port
|
14
|
+
imp.browser_args = [:remote, {:url => "http://localhost:9515"}]
|
15
|
+
end
|
16
|
+
|
11
17
|
imp.guard_proc = lambda { |args|
|
12
18
|
args.any? { |arg| arg == name || arg == [name, browser] }
|
13
19
|
}
|
data/watir-webdriver.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "selenium-webdriver", '>= 0.1.
|
22
|
+
s.add_dependency "selenium-webdriver", '>= 0.1.4'
|
23
23
|
|
24
24
|
s.add_development_dependency "rspec", "~> 2.3.0"
|
25
25
|
s.add_development_dependency "yard", "~> 0.6"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: watir-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jari Bakken
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-21 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.1.
|
24
|
+
version: 0.1.4
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -138,7 +138,6 @@ files:
|
|
138
138
|
- lib/watir-webdriver/extensions/alerts.rb
|
139
139
|
- lib/watir-webdriver/extensions/nokogiri.rb
|
140
140
|
- lib/watir-webdriver/extensions/performance.rb
|
141
|
-
- lib/watir-webdriver/extensions/wait.rb
|
142
141
|
- lib/watir-webdriver/html.rb
|
143
142
|
- lib/watir-webdriver/html/generator.rb
|
144
143
|
- lib/watir-webdriver/html/idl_sorter.rb
|
@@ -197,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
196
|
requirements: []
|
198
197
|
|
199
198
|
rubyforge_project: watir-webdriver
|
200
|
-
rubygems_version: 1.5.
|
199
|
+
rubygems_version: 1.5.2
|
201
200
|
signing_key:
|
202
201
|
specification_version: 3
|
203
202
|
summary: Watir on WebDriver
|
@@ -1 +0,0 @@
|
|
1
|
-
warn "wait helpers are now loaded by default, please remove require of 'watir-webdriver/extensions/wait'"
|