Fix :element selector without element type

This commit is contained in:
Thomas Walpole 2018-08-15 10:11:32 -07:00
parent 76dc18b369
commit 39a46bbba0
2 changed files with 5 additions and 1 deletions

View File

@ -460,7 +460,7 @@ end
Capybara.add_selector(:element) do
xpath do |locator, **|
XPath.descendant((locator || '@').to_sym)
locator ? XPath.descendant(locator.to_sym) : XPath.descendant
end
expression_filter(:attributes, matcher: /.+/) do |xpath, name, val|

View File

@ -261,6 +261,10 @@ RSpec.describe Capybara do
expect { string.all(:element, 'input', type: 'submit', count: 1) }.not_to raise_error
end
it 'works without element type' do
expect(string.find(:element, type: 'submit').value).to eq 'click me'
end
it 'includes wildcarded keys in description' do
expect { string.find(:element, 'input', not_there: 'bad', count: 1) }
.to(raise_error do |e|