2

某个标签中的属性顺序是否相关。具体案例:

这是来自硒测试文件。给定一个测试用例

<?xml version="1.0" encoding="UTF-8" standalone="no"?><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="selenium.base" href="http://10.9.10.100"/>
<title>SQL-Injection</title>
</head>
<body>
<table border="1" cellpadding="1" cellspacing="1">
<thead>
<tr><td colspan="3" rowspan="1">SQL-Injection</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/main.php?page=start.inc</td>
    <td/>
</tr>
<tr>
    <td>type</td>
    <td>username</td>
    <td>OR 1=1 #</td>
</tr>
<tr>
    <td>type</td>
    <td>password</td>
    <td>OR 1=1 #</td>
</tr>
<tr>
    <td>clickAndWait</td>
    <td>loginbutton</td>
    <td/>
</tr>
<tr>
    <td>assertTextPresent</td>
    <td>Bei dem Hack-Test dieser Webanwendung geht es darum möglichst viele Schwachstellen zu finden und erfolgreich auszunutzen</td>
    <td/>
</tr>

</tbody></table>
</body>
</html>

感兴趣的线是这样的:

<link rel="selenium.base" href="http://10.9.10.100"/>

当如上指定时,它将被固定版本的 Selenium IDE 软件正确解析。但是,当我切换两个参数时:

<link  href="http://10.9.10.100" rel="selenium.base"/>

Selenium IDE 不会正确解析 href 属性。

我总是认为属性的顺序并不重要。我错了还是这是一个实施错误?

4

1 回答 1

4

在解析 XML 文件时,属性(通常)按从左到右的顺序(取决于实现)放入文档树中。因此,在现实世界中,顺序会以某种方式影响树的拓扑结构,但是消费者应该足够聪明,并独立于顺序提供一致的结果。所以这绝对是一个实现错误。

顺便说一句,XML 规范指出

开始标签中属性规范的顺序不重要

于 2010-06-14T14:04:05.380 回答