This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29278 - [WebDriver Spec]: Get Title
Summary: [WebDriver Spec]: Get Title
Status: RESOLVED FIXED
Alias: None
Product: Browser Test/Tools WG
Classification: Unclassified
Component: WebDriver (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Browser Testing and Tools WG
QA Contact: Browser Testing and Tools WG
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 20860
  Show dependency treegraph
 
Reported: 2015-11-13 19:16 UTC by samuong
Modified: 2016-09-19 16:38 UTC (History)
5 users (show)

See Also:


Attachments

Description samuong 2015-11-13 19:16:43 UTC
When browsing to a page that has no <title> element in Chrome, the text in the tab handle is set to the URL, and window.top.document.title is an empty string. So the existing GetTitle command in ChromeDriver will return the URL, since this is what a user would see when looking at the browser's UI.

This differs from FirefoxDriver which will return an empty string, as well as the current draft spec - section 7.6 Get Title says that the get title command is equivalent to calling "window.top.document.title" in JavaScript.

I'm not particularly attached to any existing behavior, but changing this does break some existing tests, so I'd like to get some clarification on what the correct behavior is. Should we try to match what the user sees in the UI, or what is in window.top.document.title?
Comment 1 David Burns :automatedtester 2015-11-13 20:33:25 UTC
My preference is this returns what is in `<title></title>`. I think most people would be looking at the markup and then expecting a normalised version of what is in there.
Comment 2 Andreas Tolfsen 2015-12-07 11:07:19 UTC
Get Title currently returns the equivalent of window.top.document.title, which is an empty string when <title> is missing.

Philosophically I am quite drawn to returning what the user sees, since document.title is available through Execute Script.  But this quickly turns into a compatibility problem:

  Firefox: file:///Users/ato/Desktop/title_test.html
  Chrome: title_test.html
  Safari: title_test.html

Firefox’ UI automation solution is based on top of WebDriver and allows the user to get the tab title.  I imagine other vendors have similar solutions for getting at the internals of each of their browsers.

Compatibility is the strong argument for leaving the spec as-is.  Correctness, as in “truthfulness to what is displayed” is the counter-argument for doing that samuong describes.

Thoughts?  Opinions?
Comment 3 Simon Stewart 2016-01-11 11:07:34 UTC
The idea of webdriver is to emulate what a user would do or see, so the argument for "truthfulness of what is displayed" is pretty strong. Having said that, modern browsers make it pretty hard to actually see what the title is (particularly on mobile), with small tabs frequently eliding the full title text. 

If there's a way to express the truthful approach in the spec in a clear way, we should be doing that. If not, then I suggest we leave the spec as-is.