I have this simple HTML:
<div> Test <span> someting </span></div>
How can I retrieve only the innertext
of the div?
Using text
retrieves all text from the div:
[1] pry(#<SandBox>)> first(:xpath, '//div').text
=> "Test someting"
Using text()
in my XPath query results in the following error:
[2] pry(#<SandBox>)> first(:xpath, '//div/text()')
Capybara::Poltergeist::BrowserError: There was an error inside the PhantomJS portion of Poltergeist. This is probably a bug, so please report it.
TypeError: 'null' is not an object (evaluating 'window.getComputedStyle(element).display')
However, using the same XPath with Nokogiri works:
[3] pry(#<SandBox>)> Nokogiri::HTML(page.html).xpath('//div/text()').text
=> " Test "
Is there a way to do it using only capybara without resorting to Nokogiri?