Page 1 of 1

how to check if attribute value is empty or null?

Posted: Wed Jun 02, 2010 10:23 am
by hobli
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

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

Posted: Wed Jun 02, 2010 11:13 am
by Support Team
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

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

Posted: Thu Jun 03, 2010 2:55 am
by hobli
Hi,

thanks for your information.