getText() on <title> tags - current behavior feels wrong

137 views
Skip to first unread message

David Burns

unread,
Apr 11, 2013, 4:58:41 AM4/11/13
to selenium-...@googlegroups.com
Currently if we do

    driver.findElement(By.tagName('title')).getText() // it will return the value of the title tag.


Why I think this is wrong
  Other elements in <HEAD> are treated as invisible so if I do
   driver.findElement(By.tagName('meta')).getText() // it returns ''

I can see how if there are no frames this can be useful since
   title = driver.findElement(By.tagName('title')).getText()
   realTitle = driver.getTitle();
   assert title == realTitle

Since it is "visible" in the title bar of the window. However the minute we have frames and we aren't on TOP then the title isn't visible and breaks our visibility rules for text.

Proposal
Change getText() to return '' for any element in <HEAD>

David


Jason Leyba

unread,
Apr 11, 2013, 2:23:46 PM4/11/13
to selenium-...@googlegroups.com
+1

You can always retrieve the frame's title with executeScript("return document.title")


--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-develo...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Greg Dennis

unread,
Apr 11, 2013, 11:09:52 PM4/11/13
to selenium-...@googlegroups.com
+1

When I revised bot.dom.getVisibleText, I took the position that visible meant "visible in the DOM". Another way to put it is that the <title> element itself is never rendered --- the browser may or may not show the title in the title bar, but the *element* isn't shown. Also, there was no reliable way to tell if the title bar was shown. We could restrict to only top-level windows, but top-level popups can technically have their title bars hidden, too.

The webdriver getText atom has extra code to workaround this behavior to support returning the title text for top-level windows. If we go forward with this behavior change, we could nicely just delete this atom.

Greg
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.

andr...@opera.com

unread,
Apr 12, 2013, 5:19:07 AM4/12/13
to selenium-...@googlegroups.com
On Friday, April 12, 2013 5:09:52 AM UTC+2, Greg Dennis wrote:
When I revised bot.dom.getVisibleText, I took the position that visible meant "visible in the DOM". Another way to put it is that the <title> element itself is never rendered --- the browser may or may not show the title in the title bar, but the *element* isn't shown. Also, there was no reliable way to tell if the title bar was shown. We could restrict to only top-level windows, but top-level popups can technically have their title bars hidden, too.

I agree with what Greg is saying here.  Support the proposal.

Simon Stewart

unread,
Apr 19, 2013, 6:47:09 AM4/19/13
to selenium-developers
I've no strong feelings either way. I suspect that less experienced users will hold that the title is visible (at least for top-level windows) and will be confused, and I'm a little surprised to see Jason advocate for the use of JS, but since everyone who's voiced an opinion seems to be in favour of removing the functionality, I'm okay with it.

Simon


--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-develo...@googlegroups.com.

Jason Leyba

unread,
Apr 19, 2013, 3:20:44 PM4/19/13
to selenium-...@googlegroups.com
I think using JS here is similar to getAttribute/getProperty (which I still think should be distinct methods, but I digress).  The WebDriver API covers the common case and users can use JS if they need something different.

David Burns

unread,
Apr 30, 2013, 7:51:57 AM4/30/13
to selenium-...@googlegroups.com, selenium-...@googlegroups.com
This change has been landed.

David

Sent from Mailbox for iPhone
Reply all
Reply to author
Forward
0 new messages