From 2349daef8ab2094b2f23cbdd8fd6e8b6ff396301 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Fri, 26 Jul 2024 16:32:20 +0300 Subject: [PATCH] docs: add warning about newWindow command --- docs/commands/browser/newWindow.mdx | 18 ++++++++++++++++++ .../current/commands/browser/newWindow.mdx | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/docs/commands/browser/newWindow.mdx b/docs/commands/browser/newWindow.mdx index 582351c..99ecbd7 100644 --- a/docs/commands/browser/newWindow.mdx +++ b/docs/commands/browser/newWindow.mdx @@ -12,6 +12,24 @@ import Admonition from "@theme/Admonition"; Команда _newWindow_ не работает в мобильных окружениях (!) + + Команда может не работать c _devtools_ протоколом. Также она не дожидается загрузки страницы. + Чтобы решить эти проблемы, рекомендуется перезаписать команду (на стороне Testplane это будет сделано в версии 9.0.0): + ```javascript + browser.overwriteCommand("newWindow", async function(pageUrl, windowName, windowFeatures) { + if (browser.isDevTools) { + const puppeteer = await browser.getPuppeteer(); + await puppeteer.newPage(); + } else { + await browser.newWindow("about:blank", windowName, windowFeatures); + } + + await browser.url(pageUrl); + }); + ``` + + + ## Использование {#usage} ```javascript diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/browser/newWindow.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/browser/newWindow.mdx index e7ab3e8..6ed24f0 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/commands/browser/newWindow.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/browser/newWindow.mdx @@ -14,6 +14,24 @@ Note that this command will automatically switch you to the new window upon exec The _newWindow_ command does not work in mobile environments (!) + + The command might not work with _devtools_ protocol. It also does not wait untill page load. + In order to fix these problems, it is recommended to overwrite the command (on the Testplane side it would be done in version 9.0.0): + ```javascript + browser.overwriteCommand("newWindow", async function(pageUrl, windowName, windowFeatures) { + if (browser.isDevTools) { + const puppeteer = await browser.getPuppeteer(); + await puppeteer.newPage(); + } else { + await browser.newWindow("about:blank", windowName, windowFeatures); + } + + await browser.url(pageUrl); + }); + ``` + + + ## Usage {#usage} ```javascript