Ask a Question

Empty Span Elements

Regular Contributor

Empty Span Elements

I am having an issue with empty span elements. I know span elements are not mapped unless they have text or a role.

I am curious if anybody has a suggestion on how to handle my situation. Here is what my section looks like:

<div class="blah blah blah">            

<span class="twoLines displayGroup"><label>VIN</label><span class="value">2FMxxxxxxxxxxxxxx</span></span>

<span class="twoLines displayGroup"><label>Exterior Color</label><span class="value"></span></span>

<span class="twoLines displayGroup"><label>Deal Type</label><span class="value">Retail</span></span>

<span class="twoLines displayGroup"><label>Vehicle Category</label><span class="value">Sedan</span></span>

<span class="twoLines displayGroup"><label>Interior Color</label><span class="value"></span></span>

<span class="twoLines displayGroup"><label>Stock Type</label><span class="value">New</span></span>

<span class="twoLines displayGroup"><label>Style</label><span class="value">4dr SEL FWD</span></span>

<span class="twoLines displayGroup"><label>License Plate #</label><span class="value">GYNASD</span></span>

<span class="twoLines displayGroup"><label>Extended Warranty</label><span class="value"></span></span>

<span class="twoLines displayGroup"><label>Mileage</label><span class="value">10,700</span></span>

<span class="twoLines displayGroup"><label>License Plate Exp Date</label><span class="value"></span></span>


The problem I have is that the value spans may or may not contain a value. For example, "Exterior Color" is an optional value the use may not have entered. Well, if the value is not entered then TestComplete does not map it. This causes all the TextNodes to shift down one. Where Vehicle Category was TextNode 3 it is not TextNode 2.

How can I check the TextNode values if the number of TextNodes that displays varies depending on whether the user entered information or not?

Alternatively, is there some way to "Find" the correct span based on the Label next to it?

Lastly, Is there a logical reason whey TestComplete does not map empty span elements? Or, is this just flaw with TestComplete that SmartBear does not consider worth the time to fix since nobody complains about it?
Valued Contributor

The short answer here is No. You cannot map, nor logically find an object that has no unique properties or object hierarchy. It's not a flaw or bug. There is simply not enough information for TestComplete to recognize it as a unique object. It could guess...but then it would likely be wrong when the user enters different information. Likely why it's "shifting down" in your mapping because it thinks it's the same object.

I suggest using an image comparison or alternate method to check the page.

If you're attempting to click on one of these spans you may want to try clicking on the containing parent object and specifying coordinates. In this case you would click <span class="twoLines displayGroup"> span object at X,Y coordinate (location of child span object).

If nothing else TARGET='_blank'>Text Recognition may work for this.

''-Praise the sun and Give Kudos.''
Occasional Contributor

Ok, so I have another problem with spans: spans on my page have "idStr" but TestComplete does not recognize it.
a litle code snippet from my site:

<div class="bla" id="myDiv">
        <span class="mySpan" id="spanOfDiv" onclick="doSomething()">A short Text about a sleeping Cat</span>

I use following function to search for span:

FindChild("idStr", "spanOfDiv", 10)


Anybody else here with the same problem or does anyone know a solution?


Community Hero



The quick idea is to search for the label and then use its sibling (which,according to the layout you've provided should be a span element).

Something like this (untested pseudocode):

Set oLabel = <RootObject>.FindChild(Array("ObjectIdentifier", "contentText"), Array("Label", "VIN"), 20)

If (Not oLabel.Exists) Then


Set oSpan = oLabel.Parent.FindChild("ObjectIdentifier", "Span", 0)


Set oSpan = oLabel.Parent.FindChildByXPath("./SPAN")

if for some reason .FindChild does not work.


  /Alex [Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
Occasional Contributor

Thanks for the answer. At time I use the FindChildByXPath() function, it's seems to work in every situation for me.  The return object is different to FindChild() function, but it's ok.





Showing results for 
Search instead for 
Did you mean: