简体   繁体   English

无法在无头模式下检测弹出窗口

[英]Unable to detect pop ups in headless mode

I'm running some UI tests with selenium and TestNG. 我正在使用selenium和TestNG运行一些UI测试。 All test cases are passed when executed with Firefox driver. 使用Firefox驱动程序执行时,所有测试用例均通过。 But when I use HtmlUnitDriver, one test case fails where it requires accepting a confirmation pop up message by clicking on the button. 但是,当我使用HtmlUnitDriver时,一个测试用例失败了,它需要通过单击按钮来接受确认弹出消息。 Is there a workaround for this? 有没有解决方法?

It might be possible that the button you are trying to click is not visible to the driver in headless mode. 在无头模式下,驱动程序可能看不到您尝试单击的按钮。 Try taking a screenshot to make sure it appears on the screen. 尝试拍摄屏幕截图以确保它出现在屏幕上。 You can have a condition which checks if the button is visible before clicking it. 您可以具有一个条件,在单击按钮之前先检查该按钮是否可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM