是否保证元素 return 按照它们在 DOM 中出现的顺序排列?
Are elements guaranteed to return in the order they appear in DOM?
我正在使用 WebdriverIO
来驱动我的 Selenium 服务器,但我很好奇 Selenium 规范中是否有保证,或者 CSS 规范中保证元素是 return按照它们在页面上出现的顺序排列。
例如:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
如果我做 driver.getText('li');
,我能保证它会 return:
['One', 'Two', 'Three']
或者是否存在行为未定义的情况?也许还有,我应该期待什么样的行为?我想这可能是深度优先搜索?
是的,订单由WebDriver specification保证:
All element location strategies must return elements in the order in which they appear in the current document.
我正在使用 WebdriverIO
来驱动我的 Selenium 服务器,但我很好奇 Selenium 规范中是否有保证,或者 CSS 规范中保证元素是 return按照它们在页面上出现的顺序排列。
例如:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
如果我做 driver.getText('li');
,我能保证它会 return:
['One', 'Two', 'Three']
或者是否存在行为未定义的情况?也许还有,我应该期待什么样的行为?我想这可能是深度优先搜索?
是的,订单由WebDriver specification保证:
All element location strategies must return elements in the order in which they appear in the current document.