我正在使用 WebdriverIO
来驱动我的 Selenium 服务器,但我很好奇 Selenium 规范或 CSS 规范中是否有保证元素按照它们在页面上出现的顺序返回的保证。
例如:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
如果我做
driver.getText('li');
,我保证它会返回:['One', 'Two', 'Three']
或者是否存在行为未定义的情况?也许还有,我应该期待什么样的行为?我想这可能是深度优先搜索?
最佳答案
是的,订单由WebDriver specification保证:
All element location strategies must return elements in the order in which they appear in the current document.
关于selenium - 元素是否保证按照它们在 DOM 中出现的顺序返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30489908/