watir 6.5.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +58 -21
  3. data/CHANGES.md +11 -0
  4. data/Rakefile +3 -5
  5. data/lib/watir.rb +14 -2
  6. data/lib/watir/adjacent.rb +20 -27
  7. data/lib/watir/alert.rb +1 -1
  8. data/lib/watir/attribute_helper.rb +1 -1
  9. data/lib/watir/browser.rb +6 -3
  10. data/lib/watir/capabilities.rb +95 -0
  11. data/lib/watir/cookies.rb +5 -6
  12. data/lib/watir/element_collection.rb +17 -0
  13. data/lib/watir/elements/element.rb +12 -15
  14. data/lib/watir/elements/iframe.rb +1 -1
  15. data/lib/watir/elements/option.rb +5 -6
  16. data/lib/watir/elements/select.rb +52 -36
  17. data/lib/watir/legacy_wait.rb +2 -2
  18. data/lib/watir/locators/button/selector_builder.rb +10 -7
  19. data/lib/watir/locators/element/locator.rb +2 -2
  20. data/lib/watir/locators/element/selector_builder.rb +10 -4
  21. data/lib/watir/locators/element/selector_builder/xpath.rb +22 -3
  22. data/lib/watir/logger.rb +109 -0
  23. data/lib/watir/wait.rb +6 -6
  24. data/lib/watirspec.rb +1 -1
  25. data/lib/watirspec/guards.rb +4 -4
  26. data/lib/watirspec/implementation.rb +13 -5
  27. data/lib/watirspec/remote_server.rb +38 -0
  28. data/lib/watirspec/runner.rb +2 -2
  29. data/lib/watirspec/server.rb +1 -1
  30. data/spec/browser_spec.rb +101 -17
  31. data/spec/element_locator_spec.rb +1 -1
  32. data/spec/element_spec.rb +1 -1
  33. data/spec/logger_spec.rb +46 -0
  34. data/spec/watirspec/adjacent_spec.rb +45 -0
  35. data/spec/watirspec/after_hooks_spec.rb +45 -40
  36. data/spec/watirspec/alert_spec.rb +20 -14
  37. data/spec/watirspec/browser_spec.rb +71 -77
  38. data/spec/watirspec/cookies_spec.rb +13 -16
  39. data/spec/watirspec/drag_and_drop_spec.rb +6 -6
  40. data/spec/watirspec/elements/button_spec.rb +14 -7
  41. data/spec/watirspec/elements/collections_spec.rb +18 -1
  42. data/spec/watirspec/elements/dd_spec.rb +4 -2
  43. data/spec/watirspec/elements/del_spec.rb +12 -10
  44. data/spec/watirspec/elements/div_spec.rb +17 -13
  45. data/spec/watirspec/elements/dl_spec.rb +4 -2
  46. data/spec/watirspec/elements/form_spec.rb +8 -6
  47. data/spec/watirspec/elements/frame_spec.rb +27 -19
  48. data/spec/watirspec/elements/iframe_spec.rb +28 -17
  49. data/spec/watirspec/elements/ins_spec.rb +12 -10
  50. data/spec/watirspec/elements/option_spec.rb +17 -33
  51. data/spec/watirspec/elements/select_list_spec.rb +111 -97
  52. data/spec/watirspec/elements/span_spec.rb +12 -10
  53. data/spec/watirspec/elements/table_spec.rb +13 -11
  54. data/spec/watirspec/elements/tbody_spec.rb +13 -11
  55. data/spec/watirspec/elements/td_spec.rb +6 -4
  56. data/spec/watirspec/elements/text_field_spec.rb +19 -17
  57. data/spec/watirspec/elements/tr_spec.rb +12 -8
  58. data/spec/watirspec/html/javascript/helpers.js +2 -2
  59. data/spec/watirspec/html/nested_elements.html +5 -5
  60. data/spec/watirspec/relaxed_locate_spec.rb +13 -19
  61. data/spec/watirspec/wait_spec.rb +279 -301
  62. data/spec/watirspec/window_switching_spec.rb +190 -174
  63. data/spec/watirspec_helper.rb +64 -122
  64. data/support/doctest_helper.rb +4 -0
  65. data/watir.gemspec +2 -2
  66. metadata +15 -4
@@ -37,7 +37,7 @@ module Watir
37
37
 
38
38
  def until(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, object: nil)
39
39
  if deprecated_message || deprecated_timeout
40
- warn "Instead of passing arguments into Wait#until method, use keywords"
40
+ Watir.logger.deprecate "Using arguments for Wait#until", "keywords"
41
41
  timeout = deprecated_timeout
42
42
  message = deprecated_message
43
43
  end
@@ -63,7 +63,7 @@ module Watir
63
63
 
64
64
  def while(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, object: nil)
65
65
  if deprecated_message || deprecated_timeout
66
- warn "Instead of passing arguments into Wait#while method, use keywords"
66
+ Watir.logger.deprecate "Using arguments for Wait#while", "keywords"
67
67
  timeout = deprecated_timeout
68
68
  message = deprecated_message
69
69
  end
@@ -117,7 +117,7 @@ module Watir
117
117
 
118
118
  def wait_until(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, &blk)
119
119
  if deprecated_message || deprecated_timeout
120
- warn "Instead of passing arguments into #wait_until, use keywords"
120
+ Watir.logger.deprecate "Using arguments for #wait_until", "keywords"
121
121
  timeout = deprecated_timeout
122
122
  message = deprecated_message
123
123
  end
@@ -143,7 +143,7 @@ module Watir
143
143
 
144
144
  def wait_while(deprecated_timeout = nil, deprecated_message = nil, timeout: nil, message: nil, interval: nil, &blk)
145
145
  if deprecated_message || deprecated_timeout
146
- warn "Instead of passing arguments into #wait_while method, use keywords"
146
+ Watir.logger.deprecate "Using arguments for #wait_while", "keywords"
147
147
  timeout = deprecated_timeout
148
148
  message = deprecated_message
149
149
  end
@@ -167,7 +167,7 @@ module Watir
167
167
 
168
168
  def wait_until_present(deprecated_timeout = nil, timeout: nil, interval: nil)
169
169
  if deprecated_timeout
170
- warn "Instead of passing arguments into #wait_until_present method, use keywords"
170
+ Watir.logger.deprecate "Using arguments for #wait_until_present", "keywords"
171
171
  timeout = deprecated_timeout
172
172
  end
173
173
  wait_until(timeout: timeout, interval: interval, &:present?)
@@ -187,7 +187,7 @@ module Watir
187
187
 
188
188
  def wait_while_present(deprecated_timeout = nil, timeout: nil)
189
189
  if deprecated_timeout
190
- warn "Instead of passing arguments into #wait_while_present method, use keywords"
190
+ Watir.logger.deprecate "Using arguments for #wait_while_present", "keywords"
191
191
  timeout = deprecated_timeout
192
192
  end
193
193
  wait_while(timeout: timeout) do
@@ -77,7 +77,7 @@ module WatirSpec
77
77
  info << "#{caps.browser_name}"
78
78
  info << "#{caps.version}"
79
79
 
80
- $stderr.puts "running watirspec against #{info.join ' '} using:\n#{WatirSpec.implementation.inspect_args}"
80
+ Watir.logger.warn "running watirspec against #{info.join ' '} using:\n#{WatirSpec.implementation.inspect_args}"
81
81
  rescue
82
82
  # ignored
83
83
  end
@@ -12,17 +12,17 @@ module WatirSpec
12
12
 
13
13
  def report
14
14
  gs = WatirSpec.implementation.matching_guards_in(guards)
15
- print "\n\nWatirSpec guards for this implementation: "
15
+ str= "WatirSpec guards for this implementation: \n"
16
16
 
17
17
  if gs.empty?
18
- puts "none."
18
+ "\tnone."
19
19
  else
20
- puts
21
20
  gs.each do |guard|
22
21
  guard[:data][:file] = guard[:data][:file][/\/spec\/(.*):/, 1]
23
22
  guard_name = "#{guard[:name]}:".ljust(15)
24
- puts " #{guard_name} #{guard[:data].inspect}"
23
+ str << " \t#{guard_name} #{guard[:data].inspect}"
25
24
  end
25
+ Watir.logger.warn str
26
26
  end
27
27
  end
28
28
  end # class << self
@@ -8,6 +8,11 @@ module WatirSpec
8
8
  @guard_proc = nil
9
9
  end
10
10
 
11
+ def initialize_copy(orig)
12
+ super
13
+ @browser_args = Marshal.load( Marshal.dump(@browser_args))
14
+ end
15
+
11
16
  def browser_class
12
17
  @browser_class || raise("browser_class not set")
13
18
  end
@@ -30,11 +35,14 @@ module WatirSpec
30
35
  end
31
36
 
32
37
  def inspect_args
33
- caps = browser_args.last.delete(:desired_capabilities).send(:capabilities)
34
- string = "driver: #{browser_args.first}\n"
35
- browser_args.last.each { |arg| string << "#{arg.inspect}\n" }
36
- string << "capabilities:\n"
37
- caps.each { |k, v| string << "\t#{k}: #{v}\n"}
38
+ hash = browser_args.last
39
+ desired_capabilities = hash.delete(:desired_capabilities)
40
+ caps = desired_capabilities.send(:capabilities)
41
+ string = "\tdriver: #{browser_args.first}\n"
42
+ hash.each { |arg| string << "#{arg.inspect}\n" }
43
+ string << "\tcapabilities:\n"
44
+ caps.each { |k, v| string << "\t\t#{k}: #{v}\n"}
45
+ hash[:desired_capabilities] = desired_capabilities
38
46
  string
39
47
  end
40
48
  end # Implementation
@@ -0,0 +1,38 @@
1
+ module WatirSpec
2
+ class RemoteServer
3
+ attr_reader :server
4
+
5
+ def start(port = 4444)
6
+ require 'selenium/server'
7
+
8
+ @server ||= Selenium::Server.new(jar,
9
+ port: Selenium::WebDriver::PortProber.above(port),
10
+ log: !!$DEBUG,
11
+ background: true,
12
+ timeout: 60)
13
+ @server.start
14
+ at_exit { @server.stop }
15
+ end
16
+
17
+ private
18
+
19
+ def jar
20
+ if ENV['LOCAL_SELENIUM']
21
+ local = File.expand_path('../selenium/buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar')
22
+ end
23
+
24
+ if File.exist?(ENV['REMOTE_SERVER_BINARY'] || '')
25
+ ENV['REMOTE_SERVER_BINARY']
26
+ elsif ENV['LOCAL_SELENIUM'] && File.exists?(local)
27
+ local
28
+ elsif !Dir.glob('*selenium*.jar').empty?
29
+ Dir.glob('*selenium*.jar').first
30
+ else
31
+ Selenium::Server.download :latest
32
+ end
33
+ rescue SocketError
34
+ # not connected to internet
35
+ raise Watir::Exception::Error, "unable to find or download selenium-server-standalone jar"
36
+ end
37
+ end
38
+ end
@@ -35,8 +35,8 @@ module WatirSpec
35
35
  config.include(BrowserHelper)
36
36
  config.include(MessagesHelper)
37
37
 
38
- $browser = WatirSpec.new_browser
39
- at_exit { $browser.close }
38
+ config.before(:suite) { $browser = WatirSpec.new_browser }
39
+ config.after(:suite) { $browser.close }
40
40
  end
41
41
  end
42
42
 
@@ -54,7 +54,7 @@ module WatirSpec
54
54
 
55
55
  client.write(response(status, headers, body))
56
56
  rescue Errno::ECONNRESET
57
- STDERR.puts 'Client reset connection, skipping.'
57
+ Watir.logger.warn 'Client reset connection, skipping.'
58
58
  ensure
59
59
  client.close
60
60
  end
@@ -3,19 +3,103 @@ require 'watirspec_helper'
3
3
  describe Watir::Browser do
4
4
 
5
5
  describe ".new" do
6
- it "passes the args to Selenium" do
7
- expect(Selenium::WebDriver).to receive(:for).with(:firefox, :foo).and_return(nil)
8
- Watir::Browser.new(:firefox, :foo)
9
- end
10
-
11
- it "takes a Driver instance as argument" do
12
- mock_driver = double(Selenium::WebDriver::Driver)
13
- expect(Selenium::WebDriver::Driver).to receive(:===).with(mock_driver).and_return(true)
14
- expect { Watir::Browser.new(mock_driver) }.to_not raise_error
15
- end
16
-
17
- it "raises ArgumentError for invalid args" do
18
- expect { Watir::Browser.new(Object.new) }.to raise_error(ArgumentError)
6
+ not_compliant_on :remote do
7
+ context "with parameters" do
8
+ let(:url) {"http://localhost:4544/wd/hub/"}
9
+
10
+ before(:all) do
11
+ @original = WatirSpec.implementation.clone
12
+
13
+ require 'watirspec/remote_server'
14
+ WatirSpec::RemoteServer.new.start(4544)
15
+ browser.close
16
+ end
17
+
18
+ before(:each) do
19
+ @opts = WatirSpec.implementation.browser_args.last
20
+ end
21
+
22
+ after(:each) do
23
+ WatirSpec.implementation = @original.clone
24
+ end
25
+
26
+ after(:all) do
27
+ $browser = WatirSpec.new_browser
28
+ end
29
+
30
+ it "uses remote client based on provided url" do
31
+ @opts.merge!(url: url)
32
+ new_browser = WatirSpec.new_browser
33
+
34
+ server_url = new_browser.driver.instance_variable_get('@bridge').http.instance_variable_get('@server_url')
35
+ expect(server_url).to eq URI.parse(url)
36
+ new_browser.close
37
+ end
38
+
39
+ it "sets client timeout" do
40
+ @opts.merge!(url: url, open_timeout: 44, read_timeout: 47)
41
+ new_browser = WatirSpec.new_browser
42
+
43
+ http = new_browser.driver.instance_variable_get('@bridge').http
44
+
45
+ expect(http.open_timeout).to eq 44
46
+ expect(http.read_timeout).to eq 47
47
+ new_browser.close
48
+ end
49
+
50
+ it "accepts http_client" do
51
+ http_client = Selenium::WebDriver::Remote::Http::Default.new
52
+ @opts.merge!(url: url, http_client: http_client)
53
+ new_browser = WatirSpec.new_browser
54
+
55
+ expect(new_browser.driver.instance_variable_get('@bridge').http).to eq http_client
56
+ new_browser.close
57
+ end
58
+
59
+ compliant_on :firefox do
60
+ it "accepts Remote::Capabilities instance as :desired_capabilities" do
61
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true)
62
+ @opts.merge!(url: url, desired_capabilities: caps)
63
+
64
+ expect { @new_browser = WatirSpec.new_browser }.to output.to_stderr
65
+
66
+ expect(@new_browser.driver.capabilities['acceptInsecureCerts']).to eq true
67
+ @new_browser.close
68
+ end
69
+ end
70
+
71
+ compliant_on :firefox do
72
+ it "accepts individual driver capabilities" do
73
+ @opts.merge!(accept_insecure_certs: true)
74
+ new_browser = WatirSpec.new_browser
75
+
76
+ expect(new_browser.driver.capabilities[:accept_insecure_certs]).to eq true
77
+ new_browser.close
78
+ end
79
+ end
80
+
81
+ compliant_on :chrome do
82
+ it "accepts browser options" do
83
+ @opts.merge!(options: {emulation: {userAgent: 'foo;bar'}})
84
+
85
+ new_browser = WatirSpec.new_browser
86
+
87
+ ua = new_browser.execute_script 'return window.navigator.userAgent'
88
+ expect(ua).to eq('foo;bar')
89
+ new_browser.close
90
+ end
91
+ end
92
+ end
93
+
94
+ it "takes a driver instance as argument" do
95
+ mock_driver = double(Selenium::WebDriver::Driver)
96
+ expect(Selenium::WebDriver::Driver).to receive(:===).with(mock_driver).and_return(true)
97
+ expect { Watir::Browser.new(mock_driver) }.to_not raise_error
98
+ end
99
+
100
+ it "raises ArgumentError for invalid args" do
101
+ expect { Watir::Browser.new(Object.new) }.to raise_error(ArgumentError)
102
+ end
19
103
  end
20
104
  end
21
105
 
@@ -67,11 +151,11 @@ describe Watir::Browser do
67
151
 
68
152
  bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1290814", :firefox do
69
153
  it "raises an error when trying to interact with a closed browser" do
70
- b = WatirSpec.new_browser
71
- b.goto WatirSpec.url_for "definition_lists.html"
72
- b.close
154
+ browser.goto WatirSpec.url_for "definition_lists.html"
155
+ browser.close
73
156
 
74
- expect { b.dl(id: "experience-list").id }.to raise_error(Watir::Exception::Error, "browser was closed")
157
+ expect { browser.dl(id: "experience-list").id }.to raise_error(Watir::Exception::Error, "browser was closed")
158
+ $browser = WatirSpec.new_browser
75
159
  end
76
160
  end
77
161
 
@@ -303,7 +303,7 @@ describe Watir::Locators::Element::Locator do
303
303
  it "raises a TypeError if selector value is not a String, Regexp or Boolean" do
304
304
  num_type = RUBY_VERSION[/^\d+\.(\d+)/, 1].to_i >= 4 ? 'Integer' : 'Fixnum'
305
305
  expect { locate_one(tag_name: 123) }.to \
306
- raise_error(TypeError, %[expected one of [Array, String, Regexp, TrueClass, FalseClass], got 123:#{num_type}])
306
+ raise_error(TypeError, %[expected one of [Array, String, Regexp, TrueClass, FalseClass, Symbol], got 123:#{num_type}])
307
307
  end
308
308
 
309
309
  it "raises a MissingWayOfFindingObjectException if the attribute is not valid" do
@@ -45,7 +45,7 @@ describe Watir::Element do
45
45
  end
46
46
 
47
47
  it "raises UnknownObjectException if the element doesn't exist" do
48
- expect { browser.element(name: "no_such_name").enabled? }.to raise_error(Watir::Exception::UnknownObjectException)
48
+ expect { browser.element(name: "no_such_name").enabled? }.to raise_unknown_object_exception
49
49
  end
50
50
  end
51
51
 
@@ -0,0 +1,46 @@
1
+ require 'watirspec_helper'
2
+
3
+ module Watir
4
+ describe Logger do
5
+ around do |example|
6
+ debug = $DEBUG
7
+ $DEBUG = false
8
+ example.call
9
+ $DEBUG = debug
10
+ Watir.instance_variable_set(:@logger, nil) # reset cache
11
+ end
12
+
13
+ it 'logs warnings by default' do
14
+ expect(Watir.logger.level).to eq(2)
15
+ end
16
+
17
+ it 'logs everything if $DEBUG is set to true' do
18
+ $DEBUG = true
19
+ expect(Watir.logger.level).to eq(0)
20
+ end
21
+
22
+ it 'allows to change level during execution' do
23
+ Watir.logger.level = :info
24
+ expect(Watir.logger.level).to eq(1)
25
+ end
26
+
27
+ it 'outputs to stdout by default' do
28
+ expect { Watir.logger.warn('message') }.to output(/WARN Watir message/).to_stdout
29
+ end
30
+
31
+ it 'allows to output to file' do
32
+ begin
33
+ Watir.logger.output = 'test.log'
34
+ Watir.logger.warn('message')
35
+ expect(File.read('test.log')).to include('WARN Watir message')
36
+ ensure
37
+ File.delete('test.log')
38
+ end
39
+ end
40
+
41
+ it 'allows to deprecate functionality' do
42
+ message = /WARN Watir \[DEPRECATION\] #old is deprecated\. Use #new instead\./
43
+ expect { Watir.logger.deprecate('#old', '#new') }.to output(message).to_stdout
44
+ end
45
+ end
46
+ end
@@ -21,6 +21,10 @@ describe "Adjacent Elements" do
21
21
  expect(browser.div(id: "first_sibling").parent(tag_name: :div)).to be_a Watir::Div
22
22
  end
23
23
 
24
+ it "accepts class_name argument" do
25
+ expect(browser.div(id: "first_sibling").parent(class_name: 'parent').id).to eq 'parent_span'
26
+ end
27
+
24
28
  it "accepts index and tag_name arguments" do
25
29
  expect(browser.div(id: "first_sibling").parent(tag_name: :div, index: 1).id).to eq 'grandparent'
26
30
  expect(browser.div(id: "first_sibling").parent(tag_name: :div, index: 1)).to be_a Watir::Div
@@ -51,11 +55,23 @@ describe "Adjacent Elements" do
51
55
  expect(browser.div(id: "first_sibling").following_sibling(tag_name: :div)).to be_a Watir::Div
52
56
  end
53
57
 
58
+ it "accepts class_name argument" do
59
+ expect(browser.div(id: "first_sibling").following_sibling(class_name: 'b').id).to eq 'second_sibling'
60
+ end
61
+
54
62
  it "accepts index and tag_name arguments" do
55
63
  expect(browser.div(id: "first_sibling").following_sibling(tag_name: :div, index: 1).id).to eq 'third_sibling'
56
64
  expect(browser.div(id: "first_sibling").following_sibling(tag_name: :div, index: 1)).to be_a Watir::Div
57
65
  end
58
66
 
67
+ it "accepts text as Regexp" do
68
+ expect(browser.div(id: "first_sibling").following_sibling(text: /t/).id).to eq 'third_sibling'
69
+ end
70
+
71
+ it "accepts text as String" do
72
+ expect(browser.div(id: "first_sibling").following_sibling(text: 'text').id).to eq 'third_sibling'
73
+ end
74
+
59
75
  it "does not error when no next sibling of an index exists" do
60
76
  expect(browser.body.following_sibling(index: 1)).to_not exist
61
77
  end
@@ -75,6 +91,16 @@ describe "Adjacent Elements" do
75
91
  expect(browser.div(id: "second_sibling").following_siblings(tag_name: :div).size).to eq 1
76
92
  expect(browser.div(id: "second_sibling").following_siblings(tag_name: :div).first).to be_a Watir::Div
77
93
  end
94
+
95
+ it "accepts class_name argument" do
96
+ expect(browser.div(id: "second_sibling").following_siblings(class_name: 'b').size).to eq 1
97
+ expect(browser.div(id: "second_sibling").following_siblings(class_name: 'b').first).to be_a Watir::Div
98
+ end
99
+
100
+ it "accepts class_name argument for multiple classes" do
101
+ expect(browser.div(id: "second_sibling").following_siblings(class_name: ['a','b']).size).to eq 1
102
+ expect(browser.div(id: "second_sibling").following_siblings(class_name: ['a', 'b']).first).to be_a Watir::Div
103
+ end
78
104
  end
79
105
 
80
106
  describe "#previous_sibling" do
@@ -93,6 +119,10 @@ describe "Adjacent Elements" do
93
119
  expect(browser.div(id: "third_sibling").previous_sibling(tag_name: :div)).to be_a Watir::Div
94
120
  end
95
121
 
122
+ it "accepts class_name argument" do
123
+ expect(browser.div(id: "third_sibling").previous_sibling(class_name: 'a').id).to eq 'between_siblings2'
124
+ end
125
+
96
126
  it "accepts index and tag_name arguments" do
97
127
  expect(browser.div(id: "third_sibling").previous_sibling(tag_name: :div, index: 1).id).to eq 'first_sibling'
98
128
  expect(browser.div(id: "third_sibling").previous_sibling(tag_name: :div, index: 1)).to be_a Watir::Div
@@ -117,6 +147,11 @@ describe "Adjacent Elements" do
117
147
  expect(browser.div(id: "second_sibling").previous_siblings(tag_name: :div).size).to eq 1
118
148
  expect(browser.div(id: "second_sibling").previous_siblings(tag_name: :div).first).to be_a Watir::Div
119
149
  end
150
+
151
+ it "accepts class_name argument" do
152
+ expect(browser.div(id: "second_sibling").previous_siblings(class_name: 'a').size).to eq 1
153
+ expect(browser.div(id: "second_sibling").previous_siblings(class_name: 'a').first.id).to eq 'between_siblings1'
154
+ end
120
155
  end
121
156
 
122
157
  describe "#child" do
@@ -135,6 +170,10 @@ describe "Adjacent Elements" do
135
170
  expect(browser.div(id: "parent").child(tag_name: :span)).to be_a Watir::Span
136
171
  end
137
172
 
173
+ it "accepts class_name argument" do
174
+ expect(browser.div(id: "parent").child(class_name: 'b').id).to eq 'second_sibling'
175
+ end
176
+
138
177
  it "accepts index and tag_name arguments" do
139
178
  expect(browser.div(id: "parent").child(tag_name: :div, index: 1).id).to eq 'second_sibling'
140
179
  expect(browser.div(id: "parent").child(tag_name: :div, index: 1)).to be_a Watir::Div
@@ -160,5 +199,11 @@ describe "Adjacent Elements" do
160
199
  expect(children.size).to eq 3
161
200
  expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
162
201
  end
202
+
203
+ it "accepts a class_name argument" do
204
+ children = browser.div(id: "parent").children(class_name: 'b')
205
+ expect(children.size).to eq 2
206
+ expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
207
+ end
163
208
  end
164
209
  end