previousElement
返回所选 DOM 元素的前一个同级元素。
用法
$(selector).previousElement()
示例
index.html
<div class="parent">
<p>Sibling One</p>
<p>Sibling Two</p>
<p>Sibling Three</p>
</div>
previousElement.js
it('should get text from previous sibling element', async () => {
const elem = await $$('p');
const previousElem = await elem[1].previousElement()
console.log(await previousElem.getText()); // outputs: "Sibling One"
});