Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

text for svg elements not working #437

Closed
betelgeuse opened this Issue Dec 26, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

betelgeuse commented Dec 26, 2012

With 0.13.0 I was able to test the text content for the svg text element. With bca84f9 I get a blank string:

[5] pry(#<Cucumber::Rails::World>)> e.base                                                                                                                                                                                                   
=> #<Capybara::Webkit::Node tag="text" path="/html/stuff_in_between/svg/text[2]"> 
[6] pry(#<Cucumber::Rails::World>)> e.base.text                                                                                                                                                                                              
=> "" 
Contributor

betelgeuse commented Dec 26, 2012

This is due that in capybara-1.1.4 the check is done with xpath:

/home/betelgeuse/.rvm/gems/ruby-1.9.3-p327/gems/capybara-1.1.4/lib/capybara/node/matchers.rb:184
has_xpath?(XPath::HTML.content(content))
(rdb:1) p XPath::HTML.content(content)
./descendant-or-self::*[contains(normalize-space(.), 'text to find')]

Capybara 2.0 calls #text for the last scope. I am calling the text checking in a within block so it's the actual text node shown in the initial report. @jnicklas can maybe shed some more light on the issue but it should get fixed by having text method the content also for svg elements.

/home/betelgeuse/.rvm/gems/ruby-1.9.3-p327/gems/capybara-2.0.1/lib/capybara/node/matchers.rb:204
unless Capybara::Helpers.normalize_whitespace(text).match(Capybara::Helpers.to_regexp(content))
(rdb:1) p self.class
Capybara::Node::Element

betelgeuse added a commit to betelgeuse/capybara-webkit that referenced this issue Dec 26, 2012

Make Node#text work for svg elements
svg elements don't return to the non standard innerText attribute so
fall back on the standard textContent when innerText is null.

Fixes #437.

betelgeuse added a commit to betelgeuse/capybara-webkit that referenced this issue Jan 21, 2013

Make Node#text work for svg elements
svg elements don't return to the non standard innerText attribute so
fall back on the standard textContent when innerText is null.

Fixes #437.

@mhoran mhoran closed this in 2f3832f Feb 7, 2013

youpy added a commit to youpy/capybara-webkit that referenced this issue Jul 22, 2014

Make Node#text work for svg elements
svg elements don't return to the non standard innerText attribute so
fall back on the standard textContent when innerText is null.

Fixes #437.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment