使用 Selenium 测试渐进式 Web 应用程序安装

Test Progressive Web App installation with Selenium

提问人:Pimv_h 提问时间:10/23/2023 最后编辑:Pimv_h 更新时间:10/24/2023 访问量:37

问:

我目前正在使用 Selenium 为我的 Vue 应用程序进行 GUI 测试。我正在用 C# 编写测试,测试似乎在 Google Chrome 客户端上运行。

Vue 应用程序是一个渐进式 Web 应用程序 (PWA),具有自定义的 beforeinstallprompt 事件,可为应用程序安装添加一些风格。它确实依赖于按本机浏览器提示符上的“安装”按钮来实际下载应用程序并将其放在主屏幕上。

现在我想在我的 GUI 测试中测试此功能,但似乎无法弄清楚如何......我知道如何进入浏览器的安装提示,但不知道如何与之交互。

请参阅下面我到目前为止使用的代码

var installPromptExistsInitially = IsElementVisible("#installPrompt"); // Check if the custom installPrompt exists before interacting with it

WaitForElement("#installPrompt"); // Always wait until the custom installPrompt is loaded

Click("#installApp"); // Click the install button on my custom prompt

// here I need to accept the browser's native installation prompt

var installPromptExistsAfterInstalling = IsElementVisible("#installPrompt"); // Check if the custom installPrompt has disappeared after actually installing the PWA

Assert.IsTrue(installPromptExistsInitially); // Assert that the prompt was there in the beginning
Assert.IsFalse(installPromptExistsAfterInstalling); // Assert that it is gone now

我希望你们中的一个人能帮助我解决这个问题。提前致谢:)

javascript c# google-chrome selenium-webdriver 渐进式网络应用程序

评论


答: 暂无答案