how to check if attribute value is empty or null?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

how to check if attribute value is empty or null?

Post by hobli » Wed Jun 02, 2010 10:23 am

Hi,

sometimes, web developer may code a html element in following 2 ways:

1. <ahtmlTag attributeX=''>
or
2. <ahtmlTag >

The difference is in way 1, an 'attributeX' with value of empty is defined, where in way 2, 'attributeX' is not
defined at all. Browser may have different behavior with the 2 ways of coding.

When query the attribute value, ranorex (2.3.1) always return null for the attribute. It would be nice if Ranorex can differentiate them by return empty string for 1st approach and null/Nothing for 2 approach.

This will be helpful to detect different behavior of FF browser with html code like following:

Code: Select all

<ul type=''>
<li>item 1</li>
<li>item 2</li>
</ul>
and

Code: Select all

<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
if there's already a solution, pls advise.
thanks a lot

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: how to check if attribute value is empty or null?

Post by Support Team » Wed Jun 02, 2010 11:13 am

hello hobli,

The Ranorex Firefox plugin currently returns null for empty attributes; we will try to fix that. Very perceptive observation :D

The IE plugin, however, returns null for missing attributes and the empty string for empty attributes.
In your special case (ul and type="") the type attribute is thrown away by IE and is no longer available in the DOM. To check the html source, you have to look through the parent's innerhtml string.

Michael
Ranorex Team
.
Image

hobli
Posts: 57
Joined: Thu Jul 30, 2009 1:15 am

Re: how to check if attribute value is empty or null?

Post by hobli » Thu Jun 03, 2010 2:55 am

Hi,

thanks for your information.