【问题标题】:playwright headless chromium can't find selector, but finds it in UI mode剧作家无头铬找不到选择器,但在UI模式下找到它
【发布时间】:2022-11-11 16:06:29
【问题描述】:

我正在尝试做的事情

我正在 webapp 上与剧作家进行一些 e2e 测试

问题

每当我想使用无头模式节省资源时,我都会遇到问题。 我的编剧脚本在 chromium UI 模式下运行良好。当遇到第一个 from (login) 时,会发生这种情况:

[2022-03-31 07:57:38,079] [root] [ERROR] [MainThread]: Timeout 30000ms exceeded.
=========================== logs ===========================
waiting for selector "#username"

我试过的

我寻找答案,但在这个问题上找不到任何东西。我完全不知道为什么 id 选择器可以在 UI 模式下工作,但不能在无头模式下工作。它只是 html,它还能够传递其他选择器,例如单击按钮以获取登录信息。我在这里不知所措。

代码sn-p:

# goto voice client
await page.click(selector='[title=log_in]')
await page.wait_for_timeout(timeout=500)

# enter credentials
await page.type(selector='#username', text=self.username, delay=50)
await page.type(selector='#password', text=self.password, delay=50)
await page.wait_for_timeout(timeout=100)

【问题讨论】:

标签: python chromium e2e-testing playwright playwright-python


【解决方案1】:

我也遇到了这个问题,我的测试将以有头模式而不是无头模式运行。尝试运行我的测试时,我打开了一个 Chromium 窗口,它会失败。一旦我关闭了所有 Chromium 窗口,它就会以无头模式工作。

【讨论】:

    猜你喜欢
    • 2022-12-24
    • 2021-12-14
    • 2023-01-03
    • 2023-02-26
    • 1970-01-01
    • 2021-03-23
    • 1970-01-01
    • 2022-06-22
    • 2015-12-12
    相关资源
    最近更新 更多