GetAttribute of Boolean Property always returns null

181 views
Skip to first unread message

Scott Walton

unread,
Feb 24, 2015, 2:16:36 PM2/24/15
to seleniu...@googlegroups.com
When running the Element.GetAttribute(), I am getting a null value back whether the value is true or false.  The expected behavior according to Selenium is null for false and "true" for true.  Has anyone seen this before?  I am looking up the isContentEditable property with Chrome and it is showing false, which returns null.  I then try something that should be true like "translate" or "spellcheck", and those also return null.  Is it possible that this must be set by the developer in the outer HTML?

_driver.NavigateTo("http:\\www.yahoo.com");
string returnValue = _driver.FindElement(By.XPath(elementXPath)).GetAttribute("spellcheck");
if (returnValue == null)   {
   MessageBox.Show("I'm null", "Disturbing Prompt");

Getting other attributes in this way works great, such as "offsetHeight" will return 32.

Thanks for looking.

Scott Walton

unread,
Feb 24, 2015, 2:45:01 PM2/24/15
to seleniu...@googlegroups.com
Forgot to add - This error was found in an earlier version of Firefox.  I tried this with the latest version of Chrome and GetAttribute worked like it should.

PeterJeffreyGale

unread,
Feb 24, 2015, 4:11:25 PM2/24/15
to seleniu...@googlegroups.com
I'm not sure that those "properties" will necessarily directly relate to individual element attributes,

You haven't defined the elementXpath in  your code snippet, so we cannot see what element you are looking at.

There are no elements with attributes called "spellcheck" at www.yahoo.com so for al we know getting a return of null could be right.

 ... Or is this not realistic code for us to look at?

glass Man

unread,
Feb 24, 2015, 4:24:06 PM2/24/15
to seleniu...@googlegroups.com
Thanks for the response.  Yes, this example worked great for both spellcheck and offsetHeight in Chrome, but in Firefox, it was not working.
( I see my original post has backslashes instead of forward, and leaves out a closed curly bracket, I hang my head )

Unfortunately, the end users will only use firefox 11, so I am forced to run the checks with this browser.  I'm guessing that this is the problem, or that these properties are only set in Chrome.

murali seleniumtrainer

unread,
Feb 25, 2015, 1:13:17 AM2/25/15
to seleniu...@googlegroups.com
Hi,

I tried to find spellcheck and offsetHeight  text but no luck..

glass Man

unread,
Feb 25, 2015, 12:21:19 PM2/25/15
to seleniu...@googlegroups.com
Thanks for trying. I will use a different approach since these properties do not seem to be pervasive to all browsers.  FYI for anyone else reading this thread, these properties are found in Chrome by right clicking the element of interest and clicking 'inspect element.'  In the Chrome window that comes up, and then click 'Properties.' (There are four tabs: Styles, Event Listeners, DOM Breakpoints, and Properties)  Select the top drop down arrow and you will see all the properties I'm refering to.  I have been successful pulling these out with Chrome, but only non-booleans with Firefox.  The property that originally got me on this kick was trying to access isContentEditable.  I'll try to get the developer to add it to the outer HTML.  Thanks all.
Reply all
Reply to author
Forward
0 new messages