mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Handle mixedCase element names in Selenium Node#path - Fixes Issue #2051
This commit is contained in:
parent
51bed769a2
commit
b3aa90fdb4
3 changed files with 12 additions and 4 deletions
|
@ -91,4 +91,4 @@ if defined?(::RSpec::Expectations::Version)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -160,7 +160,7 @@ class Capybara::Selenium::Node < Capybara::Driver::Node
|
|||
default_ns = path.last[:namespaceURI]
|
||||
while (node = path.shift)
|
||||
parent = path.first
|
||||
selector = node.tag_name
|
||||
selector = node[:tagName]
|
||||
if node[:namespaceURI] != default_ns
|
||||
selector = XPath.child.where((XPath.local_name == selector) & (XPath.namespace_uri == node[:namespaceURI])).to_s
|
||||
selector
|
||||
|
|
|
@ -180,15 +180,23 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
|
|||
# this is here because it is testing for an XPath that is specific to the algorithm used in the selenium driver
|
||||
session.visit('/path')
|
||||
element = session.find(:link, 'Second Link')
|
||||
expect(element.path).to eq('/html/body/div[2]/a[1]')
|
||||
expect(element.path).to eq('/HTML/BODY/DIV[2]/A[1]')
|
||||
end
|
||||
|
||||
it "handles namespaces" do
|
||||
session.visit "/with_namespace"
|
||||
rect = session.find(:css, "div svg rect")
|
||||
expect(rect.path).to eq("/html/body/div/./*[((local-name(.) = 'svg') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))]/./*[((local-name(.) = 'rect') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))][1]")
|
||||
expect(rect.path).to eq("/HTML/BODY/DIV/./*[((local-name(.) = 'svg') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))]/./*[((local-name(.) = 'rect') and (namespace-uri(.) = 'http://www.w3.org/2000/svg'))][1]")
|
||||
expect(session.find(:xpath, rect.path)).to eq rect
|
||||
end
|
||||
|
||||
it "handles case sensitive element names" do
|
||||
session.visit "/with_namespace"
|
||||
els = session.all(:css, "div *", visible: :all)
|
||||
expect { els.map(&:path) }.not_to raise_error
|
||||
lg = session.find(:css, "div linearGradient", visible: :all)
|
||||
expect(session.find(:xpath, lg.path, visible: :all)).to eq lg
|
||||
end
|
||||
end
|
||||
|
||||
describe "all with disappearing elements" do
|
||||
|
|
Loading…
Reference in a new issue