【发布时间】: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)
【问题讨论】:
-
你检查过你在 HTML 中得到了什么吗? - IE。将 HTML 保存在文件中并在文本编辑器中打开。
-
这回答了你的问题了吗? Headless doesn't work using Playwright and BeautifulSoup 4。如果没有,请分享minimal reproducible example,以便其他人可以看到问题,以便他们帮助解决问题。
标签: python chromium e2e-testing playwright playwright-python