watir-webdriver 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/jarib/watir-webdriver"
12
12
  gem.authors = ["Jari Bakken"]
13
13
 
14
- gem.add_dependency "selenium-webdriver", '>= 0.0.23'
14
+ gem.add_dependency "selenium-webdriver", '>= 0.0.26'
15
15
 
16
16
  gem.add_development_dependency "rspec"
17
17
  gem.add_development_dependency "webidl"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -324,9 +324,9 @@ module Watir
324
324
  @selector.inspect
325
325
  end
326
326
 
327
- def attribute?(a)
327
+ def attribute?(attribute)
328
328
  assert_exists
329
- rescue_no_match(false) { !!@element.attribute(a) }
329
+ driver.execute_script "return !!arguments[0].getAttributeNode(arguments[1]);", @element, attribute.downcase
330
330
  end
331
331
 
332
332
  def assert_enabled
@@ -30,6 +30,11 @@ module Watir
30
30
  end
31
31
  end
32
32
 
33
+ def options
34
+ assert_exists
35
+ super
36
+ end
37
+
33
38
  #
34
39
  # Returns true if the select list has one or more options where text or label matches the given value.
35
40
  #
@@ -4,8 +4,18 @@ module Watir
4
4
  include Watir::Exception
5
5
  include Selenium
6
6
 
7
- WD_FINDERS = [ :class, :class_name, :id, :link_text, :link,
8
- :partial_link_text, :name, :tag_name, :xpath ]
7
+ WD_FINDERS = [
8
+ :class,
9
+ :class_name,
10
+ :css,
11
+ :id,
12
+ :link,
13
+ :link_text,
14
+ :name,
15
+ :partial_link_text,
16
+ :tag_name,
17
+ :xpath
18
+ ]
9
19
 
10
20
  def initialize(wd, selector, valid_attributes)
11
21
  @wd = wd
@@ -138,7 +148,7 @@ module Watir
138
148
  when :tag_name
139
149
  element.tag_name
140
150
  else
141
- element.attribute(how) rescue "" # TODO: rescue specific exception
151
+ element.attribute(how)
142
152
  end
143
153
  end
144
154
 
@@ -20,11 +20,11 @@ module Watir
20
20
  @building = :input
21
21
  input_attr_exp = attribute_expression(selectors)
22
22
 
23
- xpath = ".//textarea"
24
- xpath << "[#{textarea_attr_exp}]" unless textarea_attr_exp.empty?
25
- xpath << " | .//input[(not(@type) or (#{NEGATIVE_TYPE_EXPR}))"
23
+ xpath = ".//input[(not(@type) or (#{NEGATIVE_TYPE_EXPR}))"
26
24
  xpath << " and #{input_attr_exp}" unless input_attr_exp.empty?
27
- xpath << "]"
25
+ xpath << "] "
26
+ xpath << "| .//textarea"
27
+ xpath << "[#{textarea_attr_exp}]" unless textarea_attr_exp.empty?
28
28
 
29
29
  p :build_xpath => xpath if $DEBUG
30
30
 
@@ -54,9 +54,11 @@ describe "Form" do
54
54
  end
55
55
 
56
56
  describe "#submit" do
57
- it "submits the form" do
58
- browser.form(:id, "delete_user").submit
59
- browser.text.should include("Semantic table")
57
+ not_compliant_on :celerity do
58
+ it "submits the form" do
59
+ browser.form(:id, "delete_user").submit
60
+ browser.text.should include("Semantic table")
61
+ end
60
62
  end
61
63
  end
62
64
 
@@ -171,37 +171,40 @@ describe "Image" do
171
171
  end
172
172
 
173
173
  # Other
174
- describe "#loaded?" do
175
- it "returns true if the image has been loaded" do
176
- browser.image(:title, 'Circle').should be_loaded
177
- browser.image(:alt, 'circle').should be_loaded
178
- browser.image(:alt, /circle/).should be_loaded
179
- end
180
174
 
181
- it "returns false if the image has not been loaded" do
182
- browser.image(:id, 'no_such_file').should_not be_loaded
183
- end
175
+ not_compliant_on(:webdriver) {
176
+ describe "#loaded?" do
177
+ it "returns true if the image has been loaded" do
178
+ browser.image(:title, 'Circle').should be_loaded
179
+ browser.image(:alt, 'circle').should be_loaded
180
+ browser.image(:alt, /circle/).should be_loaded
181
+ end
184
182
 
185
- it "raises UnknownObjectException if the image doesn't exist" do
186
- lambda { browser.image(:id, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
187
- lambda { browser.image(:src, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
188
- lambda { browser.image(:alt, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
189
- lambda { browser.image(:index, 1337).loaded? }.should raise_error(UnknownObjectException)
183
+ it "returns false if the image has not been loaded" do
184
+ browser.image(:id, 'no_such_file').should_not be_loaded
185
+ end
186
+
187
+ it "raises UnknownObjectException if the image doesn't exist" do
188
+ lambda { browser.image(:id, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
189
+ lambda { browser.image(:src, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
190
+ lambda { browser.image(:alt, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
191
+ lambda { browser.image(:index, 1337).loaded? }.should raise_error(UnknownObjectException)
192
+ end
190
193
  end
191
- end
192
194
 
193
- describe "#save" do
194
195
  bug "WTR-336", :watir do
195
- it "saves the image to a file" do
196
- file = "#{File.expand_path Dir.pwd}/sample.img.dat"
197
- begin
198
- browser.image(:index, 1).save(file)
199
- File.exist?(file).should be_true
200
- ensure
201
- File.delete(file) if File.exist?(file)
196
+ describe "#save" do
197
+ it "saves the image to a file" do
198
+ file = "#{File.expand_path Dir.pwd}/sample.img.dat"
199
+ begin
200
+ browser.image(:index, 1).save(file)
201
+ File.exist?(file).should be_true
202
+ ensure
203
+ File.delete(file) if File.exist?(file)
204
+ end
202
205
  end
203
206
  end
204
207
  end
205
- end
208
+ }
206
209
 
207
210
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  module WatirSpec
3
4
  class Server < Sinatra::Base
4
5
  class << self
@@ -76,6 +77,24 @@ module WatirSpec
76
77
  self.class.name
77
78
  end
78
79
 
80
+ class BigContent
81
+ def each(&blk)
82
+ yield "<html><head><title>Big Content</title></head><body>"
83
+
84
+ string = "hello"*205
85
+
86
+ 300.times do
87
+ yield string
88
+ end
89
+
90
+ yield "</body></html>"
91
+ end
92
+ end
93
+
94
+ get '/big' do
95
+ BigContent.new
96
+ end
97
+
79
98
  post '/post_to_me' do
80
99
  "You posted the following content:\n#{ env['rack.input'].read }"
81
100
  end
@@ -92,16 +111,16 @@ module WatirSpec
92
111
 
93
112
  get '/charset_mismatch' do
94
113
  content_type 'text/html; charset=UTF-8'
95
- <<-HTML
96
- <html>
97
- <head>
98
- <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
99
- </head>
100
- <body>
101
- <h1>ø</h1>
102
- </body>
103
- </html>
104
- HTML
114
+ %{
115
+ <html>
116
+ <head>
117
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
118
+ </head>
119
+ <body>
120
+ <h1>ø</h1>
121
+ </body>
122
+ </html>
123
+ }
105
124
  end
106
125
 
107
126
  get '/octet_stream' do
@@ -132,5 +151,9 @@ module WatirSpec
132
151
  "ok"
133
152
  end
134
153
 
154
+ get '/encodable_<stuff>' do
155
+ 'page with characters in URI that need encoding'
156
+ end
157
+
135
158
  end # Server
136
159
  end # WatirSpec
@@ -20,8 +20,8 @@ module WatirSpec
20
20
 
21
21
  def execute
22
22
  load_requires
23
- configure
24
23
  start_server
24
+ configure
25
25
  add_guard_hook
26
26
  end
27
27
 
@@ -91,12 +91,14 @@ describe "Option" do
91
91
  describe "#select" do
92
92
  bug "WTR-367", :watir do
93
93
  it "selects the chosen option (page context)" do
94
+ browser.select_list(:name, "new_user_country").clear
94
95
  browser.option(:text, "Denmark").select
95
96
  browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
96
97
  end
97
98
  end
98
99
 
99
100
  it "selects the chosen option (select_list context)" do
101
+ browser.select_list(:name, "new_user_country").clear
100
102
  browser.select_list(:name, "new_user_country").option(:text, "Denmark").select
101
103
  browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
102
104
  end
@@ -14,11 +14,12 @@ describe "SelectList" do
14
14
  browser.select_list(:id, /new_user_country/).should exist
15
15
  browser.select_list(:name, 'new_user_country').should exist
16
16
  browser.select_list(:name, /new_user_country/).should exist
17
- # TODO: check behaviour in Watir
18
- # browser.select_list(:value, 'Norway').should exist
19
- # browser.select_list(:value, /Norway/).should exist
20
- browser.select_list(:text, 'Norway').should exist
21
- browser.select_list(:text, /Norway/).should exist
17
+
18
+ not_compliant_on :webdriver do
19
+ browser.select_list(:text, 'Norway').should exist
20
+ browser.select_list(:text, /Norway/).should exist
21
+ end
22
+
22
23
  browser.select_list(:class, 'country').should exist
23
24
  browser.select_list(:class, /country/).should exist
24
25
  browser.select_list(:index, 0).should exist
@@ -155,11 +156,28 @@ describe "SelectList" do
155
156
  lambda { browser.select_list(:name, 'no_such_name').options }.should raise_error(UnknownObjectException)
156
157
  end
157
158
 
158
- bug "WTR-339", :watir do
159
+ #
160
+ # The correct behaviour here needs to be discussed.
161
+ #
162
+
163
+ deviates_on :celerity do
159
164
  it "returns all the options as an Array" do
160
165
  browser.select_list(:name, "new_user_country").options.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA", "Germany"]
161
166
  end
162
167
  end
168
+
169
+ deviates_on :webdriver do
170
+ it "returns all the options as a collection of Options" do
171
+ options = browser.select_list(:name, "new_user_country").options
172
+ options.map { |opt| opt.text }.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA", "Germany"]
173
+ end
174
+ end
175
+
176
+ deviates_on :watir do # see also WTR-339
177
+ it "returns all the options as an Array" do
178
+ browser.select_list(:name, "new_user_country").options.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA"]
179
+ end
180
+ end
163
181
  end
164
182
 
165
183
  describe "#selected_options" do
@@ -0,0 +1,186 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{watir-webdriver}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jari Bakken"]
12
+ s.date = %q{2010-07-21}
13
+ s.description = %q{WebDriver-backed Watir}
14
+ s.email = %q{jari.bakken@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ ".gitmodules",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "TODO",
28
+ "VERSION",
29
+ "lib/watir-webdriver.rb",
30
+ "lib/watir-webdriver/base_element.rb",
31
+ "lib/watir-webdriver/browser.rb",
32
+ "lib/watir-webdriver/browserbot.js",
33
+ "lib/watir-webdriver/collections/buttons_collection.rb",
34
+ "lib/watir-webdriver/collections/element_collection.rb",
35
+ "lib/watir-webdriver/collections/table_rows_collection.rb",
36
+ "lib/watir-webdriver/collections/text_fields_collection.rb",
37
+ "lib/watir-webdriver/container.rb",
38
+ "lib/watir-webdriver/core_ext/string.rb",
39
+ "lib/watir-webdriver/elements/button.rb",
40
+ "lib/watir-webdriver/elements/checkbox.rb",
41
+ "lib/watir-webdriver/elements/file_field.rb",
42
+ "lib/watir-webdriver/elements/font.rb",
43
+ "lib/watir-webdriver/elements/form.rb",
44
+ "lib/watir-webdriver/elements/frame.rb",
45
+ "lib/watir-webdriver/elements/generated.rb",
46
+ "lib/watir-webdriver/elements/headings.rb",
47
+ "lib/watir-webdriver/elements/hidden.rb",
48
+ "lib/watir-webdriver/elements/image.rb",
49
+ "lib/watir-webdriver/elements/input.rb",
50
+ "lib/watir-webdriver/elements/link.rb",
51
+ "lib/watir-webdriver/elements/option.rb",
52
+ "lib/watir-webdriver/elements/radio.rb",
53
+ "lib/watir-webdriver/elements/select_list.rb",
54
+ "lib/watir-webdriver/elements/table.rb",
55
+ "lib/watir-webdriver/elements/table_row.rb",
56
+ "lib/watir-webdriver/elements/text_field.rb",
57
+ "lib/watir-webdriver/exception.rb",
58
+ "lib/watir-webdriver/extensions/nokogiri.rb",
59
+ "lib/watir-webdriver/locators/button_locator.rb",
60
+ "lib/watir-webdriver/locators/element_locator.rb",
61
+ "lib/watir-webdriver/locators/table_row_locator.rb",
62
+ "lib/watir-webdriver/locators/text_field_locator.rb",
63
+ "lib/watir-webdriver/xpath_support.rb",
64
+ "spec/base_element_spec.rb",
65
+ "spec/html/keylogger.html",
66
+ "spec/spec_helper.rb",
67
+ "support/html5/html5.idl",
68
+ "support/html5/old/html5.idl",
69
+ "support/html5/old/html5_extras.idl",
70
+ "support/html5/watir_visitor.rb",
71
+ "support/yard_handlers.rb",
72
+ "watir-webdriver.gemspec"
73
+ ]
74
+ s.homepage = %q{http://github.com/jarib/watir-webdriver}
75
+ s.rdoc_options = ["--charset=UTF-8"]
76
+ s.require_paths = ["lib"]
77
+ s.rubygems_version = %q{1.3.7}
78
+ s.summary = %q{Watir on WebDriver}
79
+ s.test_files = [
80
+ "spec/base_element_spec.rb",
81
+ "spec/spec_helper.rb",
82
+ "spec/watirspec/area_spec.rb",
83
+ "spec/watirspec/areas_spec.rb",
84
+ "spec/watirspec/browser_spec.rb",
85
+ "spec/watirspec/button_spec.rb",
86
+ "spec/watirspec/buttons_spec.rb",
87
+ "spec/watirspec/checkbox_spec.rb",
88
+ "spec/watirspec/checkboxes_spec.rb",
89
+ "spec/watirspec/dd_spec.rb",
90
+ "spec/watirspec/dds_spec.rb",
91
+ "spec/watirspec/div_spec.rb",
92
+ "spec/watirspec/divs_spec.rb",
93
+ "spec/watirspec/dl_spec.rb",
94
+ "spec/watirspec/dls_spec.rb",
95
+ "spec/watirspec/dt_spec.rb",
96
+ "spec/watirspec/dts_spec.rb",
97
+ "spec/watirspec/element_spec.rb",
98
+ "spec/watirspec/em_spec.rb",
99
+ "spec/watirspec/ems_spec.rb",
100
+ "spec/watirspec/filefield_spec.rb",
101
+ "spec/watirspec/filefields_spec.rb",
102
+ "spec/watirspec/font_spec.rb",
103
+ "spec/watirspec/form_spec.rb",
104
+ "spec/watirspec/forms_spec.rb",
105
+ "spec/watirspec/frame_spec.rb",
106
+ "spec/watirspec/frames_spec.rb",
107
+ "spec/watirspec/hidden_spec.rb",
108
+ "spec/watirspec/hiddens_spec.rb",
109
+ "spec/watirspec/hn_spec.rb",
110
+ "spec/watirspec/hns_spec.rb",
111
+ "spec/watirspec/image_spec.rb",
112
+ "spec/watirspec/images_spec.rb",
113
+ "spec/watirspec/label_spec.rb",
114
+ "spec/watirspec/labels_spec.rb",
115
+ "spec/watirspec/li_spec.rb",
116
+ "spec/watirspec/lib/guards.rb",
117
+ "spec/watirspec/lib/server.rb",
118
+ "spec/watirspec/lib/spec_helper.rb",
119
+ "spec/watirspec/lib/watirspec.rb",
120
+ "spec/watirspec/link_spec.rb",
121
+ "spec/watirspec/links_spec.rb",
122
+ "spec/watirspec/lis_spec.rb",
123
+ "spec/watirspec/map_spec.rb",
124
+ "spec/watirspec/maps_spec.rb",
125
+ "spec/watirspec/meta_spec.rb",
126
+ "spec/watirspec/metas_spec.rb",
127
+ "spec/watirspec/ol_spec.rb",
128
+ "spec/watirspec/ols_spec.rb",
129
+ "spec/watirspec/option_spec.rb",
130
+ "spec/watirspec/p_spec.rb",
131
+ "spec/watirspec/pre_spec.rb",
132
+ "spec/watirspec/pres_spec.rb",
133
+ "spec/watirspec/ps_spec.rb",
134
+ "spec/watirspec/radio_spec.rb",
135
+ "spec/watirspec/radios_spec.rb",
136
+ "spec/watirspec/select_list_spec.rb",
137
+ "spec/watirspec/select_lists_spec.rb",
138
+ "spec/watirspec/span_spec.rb",
139
+ "spec/watirspec/spans_spec.rb",
140
+ "spec/watirspec/spec_helper.rb",
141
+ "spec/watirspec/strong_spec.rb",
142
+ "spec/watirspec/strongs_spec.rb",
143
+ "spec/watirspec/table_bodies_spec.rb",
144
+ "spec/watirspec/table_body_spec.rb",
145
+ "spec/watirspec/table_cell_spec.rb",
146
+ "spec/watirspec/table_cells_spec.rb",
147
+ "spec/watirspec/table_footer_spec.rb",
148
+ "spec/watirspec/table_footers_spec.rb",
149
+ "spec/watirspec/table_header_spec.rb",
150
+ "spec/watirspec/table_headers_spec.rb",
151
+ "spec/watirspec/table_row_spec.rb",
152
+ "spec/watirspec/table_rows_spec.rb",
153
+ "spec/watirspec/table_spec.rb",
154
+ "spec/watirspec/tables_spec.rb",
155
+ "spec/watirspec/text_field_spec.rb",
156
+ "spec/watirspec/text_fields_spec.rb",
157
+ "spec/watirspec/ul_spec.rb",
158
+ "spec/watirspec/uls_spec.rb"
159
+ ]
160
+
161
+ if s.respond_to? :specification_version then
162
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
163
+ s.specification_version = 3
164
+
165
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
166
+ s.add_runtime_dependency(%q<selenium-webdriver>, [">= 0.0.26"])
167
+ s.add_development_dependency(%q<rspec>, [">= 0"])
168
+ s.add_development_dependency(%q<webidl>, [">= 0"])
169
+ s.add_development_dependency(%q<sinatra>, [">= 1.0"])
170
+ s.add_development_dependency(%q<activesupport>, [">= 2.3.5"])
171
+ else
172
+ s.add_dependency(%q<selenium-webdriver>, [">= 0.0.26"])
173
+ s.add_dependency(%q<rspec>, [">= 0"])
174
+ s.add_dependency(%q<webidl>, [">= 0"])
175
+ s.add_dependency(%q<sinatra>, [">= 1.0"])
176
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
177
+ end
178
+ else
179
+ s.add_dependency(%q<selenium-webdriver>, [">= 0.0.26"])
180
+ s.add_dependency(%q<rspec>, [">= 0"])
181
+ s.add_dependency(%q<webidl>, [">= 0"])
182
+ s.add_dependency(%q<sinatra>, [">= 1.0"])
183
+ s.add_dependency(%q<activesupport>, [">= 2.3.5"])
184
+ end
185
+ end
186
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jari Bakken
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-30 00:00:00 +02:00
18
+ date: 2010-07-21 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 49
29
+ hash: 43
30
30
  segments:
31
31
  - 0
32
32
  - 0
33
- - 23
34
- version: 0.0.23
33
+ - 26
34
+ version: 0.0.26
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -155,6 +155,7 @@ files:
155
155
  - support/html5/old/html5_extras.idl
156
156
  - support/html5/watir_visitor.rb
157
157
  - support/yard_handlers.rb
158
+ - watir-webdriver.gemspec
158
159
  - spec/watirspec/area_spec.rb
159
160
  - spec/watirspec/areas_spec.rb
160
161
  - spec/watirspec/browser_spec.rb