Skip to content

Commit

Permalink
Merge pull request #42 from cap10morgan/fix-issue-41
Browse files Browse the repository at this point in the history
Fix issue 41
  • Loading branch information
jnicklas committed Jun 4, 2012
2 parents f1dbaaf + 4089879 commit 79766e2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/xpath/html.rb
Expand Up @@ -19,7 +19,7 @@ def link(locator)
# Value, title, id, or image alt attribute of the button
#
def button(locator)
button = descendant(:input)[attr(:type).one_of('submit', 'image', 'button')][attr(:id).equals(locator) | attr(:value).contains(locator) | attr(:title).contains(locator)]
button = descendant(:input)[attr(:type).one_of('submit', 'reset', 'image', 'button')][attr(:id).equals(locator) | attr(:value).contains(locator) | attr(:title).contains(locator)]
button += descendant(:button)[attr(:id).equals(locator) | attr(:value).contains(locator) | string.n.contains(locator) | attr(:title).contains(locator)]
button += descendant(:input)[attr(:type).equals('image')][attr(:alt).contains(locator)]
end
Expand Down
10 changes: 9 additions & 1 deletion spec/fixtures/form.html
Expand Up @@ -28,7 +28,15 @@ <h1>Form</h1>
<input type="submit" title="My submit title" value="submit-with-title" data="title-submit">
<input type="submit" title="Exact submit title" value="exact title submit" data="exact-title-submit">
<input type="submit" title="Not Exact submit title" value="exact title submit" data="not-exact-title-submit">


<input type="reset" id="reset-with-id" data="id-reset" value="Has ID"/>
<input type="reset" value="reset-with-value" data="value-reset"/>
<input type="reset" value="not exact value reset" data="not-exact-value-reset"/>
<input type="reset" value="exact value reset" data="exact-value-reset"/>
<input type="reset" title="My reset title" value="reset-with-title" data="title-reset">
<input type="reset" title="Exact reset title" value="exact title reset" data="exact-title-reset">
<input type="reset" title="Not Exact reset title" value="exact title reset" data="not-exact-title-reset">

<input type="button" id="button-with-id" data="id-button" value="Has ID"/>
<input type="button" value="button-with-value" data="value-button"/>
<input type="button" value="not exact value button" data="not-exact-value-button"/>
Expand Down
8 changes: 8 additions & 0 deletions spec/html_spec.rb
Expand Up @@ -41,6 +41,14 @@ def all(*args)
it("finds buttons by approximate title") { get('submit title').should == 'title-submit' }
end

context "with reset type" do
it("finds buttons by id") { get('reset-with-id').should == 'id-reset' }
it("finds buttons by value") { get('reset-with-value').should == 'value-reset' }
it("finds buttons by approximate value") { get('set-with-val').should == 'value-reset' }
it("finds buttons by title") { get('My reset title').should == 'title-reset' }
it("finds buttons by approximate title") { get('reset title').should == 'title-reset' }
end

context "with button type" do
it("finds buttons by id") { get('button-with-id').should == 'id-button' }
it("finds buttons by value") { get('button-with-value').should == 'value-button' }
Expand Down

0 comments on commit 79766e2

Please sign in to comment.