This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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?
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.
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?
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.