IE9 sees sibling HTML nodes as descendants
I'm investigating automated testing of an existing web application. I ran into the following problem while trying to select certain document nodes by XPath.
On a particular screen, the application shows a tab control with five tabs. The raw HTML behind this tab controls is as follows:
<ul class="tab_set-tabs">
<span id="forTab">
<li class="tab_set-tabSelectionAware">
<a href="javascript:void(0);" id="tabOption_tabSet1">
<strong id="tabOption_tabSet1" class="">
Vendor
</strong>
</a>
</li>
</span><span id="forTab_0">
<li class="tab_set-tabSelectionAware">
<a href="javascript:void(0);" id="tabOption_tabSet2">
<strong id="tabOption_tabSet2" class="">
Ship To
</strong>
</a>
</li>
</span><span id="forTab_1">
<li class="tab_set-tabSelectionAware">
<a href="javascript:void(0);" id="tabOption_tabSet3">
<strong id="tabOption_tabSet3" class="">
Comments
</strong>
</a>
</li>
</span><span id="forTab_2">
<li class="tab_set-tabSelectionAware">
<a href="javascript:void(0);" id="tabOption_tabSet4">
<strong id="tabOption_tabSet4" class="">
Custom
</strong>
</a>
</li>
</span><span id="forTab_3">
<li class="tab_set-tabSelectionAware">
<a href="javascript:void(0);" id="tabOption_tabSet5">
<strong id="tabOption_tabSet5" class="">
History
</strong>
</a>
</li>
</span>
</ul>
As you can see, there are 5 sibling "span" nodes, each representing one of 5 tabs. However, when I look at this same section of HTML in IE9's Developer tools, I see this:
Tried to post a screen cap of IE DevTools, but as a new user, the site won't let me, so here's a approximation of what I'm seeing:
[-] <ul class="tab_seet-tabs>
[-] <span id="forTab">
[-] <li ...>
[+] <a ...>
[-] <span id="forTab_0">
[-] <li ...>
[+] <a ...>
[-] <span id="forTab_1">
[-] <li ...>
[+] <a ...>
[-] <span id="forTab_2">
[-] <li ...>
[+] <a ...>
[-] <span id="forTab_3">
[-] <a ...>
[+] <strong id="tabOption_tabSet5">
So IE appears to be parsing the HTML incorrectly and treating the sibling span nodes as descendants of each other (or more specifically, it sees each span as a child of the previous span's li child).
This is not just a quirk of the Developer tools. Using our test tool, I'm trying to click the 5th tab labeled "History" using the following xpath:
//form[@id="form"]/ul/span/li/a[contains(strong,"History")]
This works fine in firefox and chrome, but fails to find the node in IE9. However, if I try this xpath in IE9 it works:
//form[@id="form"]/ul/span/li/span/li/span/li/span/li/span/li/a[contains(strong,"History")]
Any idea what could cause IE9 to fail so miserably at parsing basic HTML parent/sibling/child node relationships?
链接地址: http://www.djcxy.com/p/65956.html上一篇: IE9空文本节点
下一篇: IE9将兄弟HTML节点视为后代