小编TEN*_*pin的帖子

错误:locator.click:错误:严格模式违规:getByRole('button', { name: 'Statements' }) 解析为 2 个元素:

当我运行测试时,出现以下错误。我对剧作家和编码相当陌生,所以我不确定解决方案是什么

\n
Error: locator.click: Error: strict mode violation: getByRole(\'button\', { name: \'Statements\' }) resolved to 2 elements:\n1) <button title="Statements" aria-label="Statements" data-\xe2\x80\xa6>Statements</button> aka locator(\'#lp_line_6_a11y_queue\').getByRole(\'button\', { name: \'Statements\' })\n2) <button title="Statements" aria-label="Statements" data-\xe2\x80\xa6>Statements</button> aka locator(\'#lp_line_6\').getByRole(\'button\', { name: \'Statements\' })\n
Run Code Online (Sandbox Code Playgroud)\n

我刚刚进行了测试,希望不会出现错误。

\n
test(\'test\', async ({ page }) => {\n  await page.goto(\'https://www.test.com\');    \n  await page.getByPlaceholder(\'Section tag #1\').click();\n  await page.getByPlaceholder(\'Section tag #1\').press(\'Control+a\');\n  await page.getByPlaceholder(\'Section tag #1\').fill(\'inapptest\');\n\n  await page.getByRole(\'button\', { name: \'UPDATE\' }).click();\n  await page.getByRole(\'button\', { name: \'Message us\' }).click();\n  await page.getByPlaceholder(\'Enter text here\').click();\n  await …
Run Code Online (Sandbox Code Playgroud)

typescript playwright

5
推荐指数
1
解决办法
6284
查看次数

标签 统计

playwright ×1

typescript ×1