/html/head/title #863

glebm opened this Issue Nov 14, 2012 · 8 comments


None yet

4 participants


Getting empty string from first('title').text since 2.0
Meanwhile, first('title').native.text works

Narrowed down to the fact that:
first('title').base.visible? returns false

And capybara returns "" for text for invisible elements.

Note that page title is always visible from a human perspective.


This is to be expected. Capybara 2 will ignore invisible text.

@jnicklas jnicklas closed this Nov 14, 2012

We should have an API for getting the page title, since that is available in pretty much all drivers. No idea why no one has ever implemented that though. I personally never assert on the title, since the user isn't particularly likely to care about it at all.


The user cares about page title, e.g. when it appears on Google results page

Capybara 2 will ignore invisible text.

Title is visible though.


Is it really visible, as in visible on the page? Not just in the title bar? In that case that would be a bug in Selenium, not much we can do about that.

Also, as I said, I'm open to having that kind of API, it's just not something that I personally need, which is why I haven't implemented it.

@glebm glebm added a commit to glebm/capybara that referenced this issue Nov 14, 2012
@glebm glebm Fixes #863 07a7df5

I am using Rack::Test, but the bug isn't in the driver, it's in Simple
Anyway, great to hear you are not against it! Pull request submitted :)


Ahh, I see, no that does not make any sense at all. The title is always invisible under RackTest, since that's what browsers default to. You actually can make the title visible in browsers, by setting display:block on it (and on the head element), but that's not what we're talking about here. Instead we could have an API explicitly for getting the page title, which would ignore the fact that it is not visible, but that's not what this change is doing.


Well unfortunately this is causing a few problems for me because different drivers treat this differently. If I am using RackTest I can check the title using first('head title').native.text, whereas with capybara webkit, when I do the same thing I am returned a string such as 3, and each time I make a request to .native I get the next number in the sequence.

It would be useful for everyone I think if there was a standardised way to access this title element as I now have to write some pretty ugly code to work around this.


It will be fixed in Capybara 2.1. See #953

@h-lame h-lame added a commit to alphagov/e-petitions that referenced this issue Apr 29, 2015
@h-lame h-lame Fix 'browser page title' within scopes
Capybara 2 doesn't let you see the text of a title using css / xpath (see: jnicklas/capybara#863) so we have to treat that scope differently and use the has_title? matchers.  The step definition is now horrible, but it works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment