Empty Span Elements
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Empty Span Elements
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>
</div>
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 http://support.smartbear.com/viewarticle/55418/ TARGET='_blank'>Text Recognition may work for this.
''-Praise the sun and Give Kudos.''
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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> </div>
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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)
or
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.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Regards,
APX
