diff --git a/lib/xpath/html.rb b/lib/xpath/html.rb index 8274b8a..10d6d09 100644 --- a/lib/xpath/html.rb +++ b/lib/xpath/html.rb @@ -23,7 +23,7 @@ def link_or_button(locator) end def fieldset(locator) - descendant(:fieldset)[attr(:id).equals(locator) | descendant(:legend)[text.is(locator)]] + descendant(:fieldset)[attr(:id).equals(locator) | descendant(:legend)[string.n.is(locator)]] end def field(locator, options={}) diff --git a/spec/fixtures/form.html b/spec/fixtures/form.html index a5becaf..ecf16f5 100644 --- a/spec/fixtures/form.html +++ b/spec/fixtures/form.html @@ -66,6 +66,7 @@

bleh

Some Legend
+
Span Legend
Long legend yo
Long legend

diff --git a/spec/html_spec.rb b/spec/html_spec.rb index eba3d2d..11642a5 100644 --- a/spec/html_spec.rb +++ b/spec/html_spec.rb @@ -81,10 +81,11 @@ def all(*args) describe '#fieldset' do subject { :fieldset } - it("finds fieldsets by id") { get('some-fieldset-id').should == 'fieldset-id' } - it("finds fieldsets by legend") { get('Some Legend').should == 'fieldset-legend' } - it("accepts approximate legends") { get('Legend').should == 'fieldset-legend' } - it("prefers exact legend") { all('Long legend').should == ['fieldset-exact', 'fieldset-fuzzy'] } + it("finds fieldsets by id") { get('some-fieldset-id').should == 'fieldset-id' } + it("finds fieldsets by legend") { get('Some Legend').should == 'fieldset-legend' } + it("finds fieldsets by legend child tags") { get('Span Legend').should == 'fieldset-legend-span' } + it("accepts approximate legends") { get('Legend').should == 'fieldset-legend' } + it("prefers exact legend") { all('Long legend').should == ['fieldset-exact', 'fieldset-fuzzy'] } end describe '#field' do