剧作家试拖

use*_*359 2 typescript playwright playwright-test

我正在开发这个模板,其中使用 DragTo() 函数进行拖放。当我在头部模式下运行测试时,它工作得很好。但是当我在无头模式下运行测试时,它根本不会拖动任何东西,并且测试将在页面空白的情况下通过。有什么方法可以减慢拖动速度,以便页面可以在跳转到其他操作之前识别拖动的元素?

我尝试通过以下方式添加超时但仍然没有运气:

await this.page.locator('text=Column').first()
  .dragTo(this.page.locator('[role="tabpanel"]')
  .first(), {force:true}), {timeout:3000};
Run Code Online (Sandbox Code Playgroud)

Suc*_*UKR 5

我想说的{force:true}是对你不利。

force 是否绕过可操作性检查

听起来您确实等待可操作性。

默认超时为 30 秒,您将其减少到 3 秒。

并尝试分解命令并检查您的源和目标

const source = this.page.locator('text=Column').first()
const target = this.page.locator('[role="tabpanel"]').first()
await source.dragTo(target)
Run Code Online (Sandbox Code Playgroud)