Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 在Chromedriver中拍摄屏幕截图时由于未知错误导致的零星测试失败_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Selenium webdriver 在Chromedriver中拍摄屏幕截图时由于未知错误导致的零星测试失败

Selenium webdriver 在Chromedriver中拍摄屏幕截图时由于未知错误导致的零星测试失败,selenium-webdriver,selenium-chromedriver,Selenium Webdriver,Selenium Chromedriver,在Chrome中运行时,我们开始出现零星的测试失败。我认为每10次测试中就有3次会发生这种情况。我不知道为什么会发生这种情况,也不知道如何解决。感谢您的帮助。下面是我们看到的堆栈跟踪错误 org.openqa.selenium.WebDriverException:未知错误:无法拍摄屏幕截图 来自未知错误:未能捕获选项卡:未知错误 JavaScript堆栈: 错误:未能捕获选项卡:未知错误 在checkForExtensionError(chrome)时-extension://aapnijgd

在Chrome中运行时,我们开始出现零星的测试失败。我认为每10次测试中就有3次会发生这种情况。我不知道为什么会发生这种情况,也不知道如何解决。感谢您的帮助。下面是我们看到的堆栈跟踪错误

org.openqa.selenium.WebDriverException:未知错误:无法拍摄屏幕截图 来自未知错误:未能捕获选项卡:未知错误 JavaScript堆栈: 错误:未能捕获选项卡:未知错误 在checkForExtensionError(chrome)时-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:14:17) 在Object.callback(chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/background.js:37:5) 在安全回调时应用(扩展::sendRequest:21:15) at HandlerResponse(扩展名::sendRequest:73:7) (会话信息:chrome=42.0.2311.135) (驱动程序信息:chromedriver=2.9.248315,平台=Windows NT 6.1 SP1 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:13毫秒 构建信息:版本:“2.44.0”,修订版:“76d78cf323ce037c5f92db6c1bba601c2ac43ad8”,时间:“2014-10-23 13:11:40” 系统信息:主机:'RTCIST5CG2xY1',ip:'10.14.101.52',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_67'


我最好的猜测是浏览器窗口正在关闭,但屏幕截图尚未拍摄,因此当它试图拍摄屏幕截图时,它会说“呃,我甚至无法访问选项卡”,并在你面前爆炸


正确方向上的一个步骤是将截图代码包装在try/catch中,并将由此产生的任何错误记录到测试日志中(这样您就不会完全接受异常)。然后失败测试的实际异常将出现在堆栈跟踪中(因为它不应该被捕获)。

这正是发生的情况。谢谢你的回答。用try/catch包装屏幕截图也是一个很好的主意。您好,您能写下您为解决这个问题所做的具体代码吗?谢谢@Conner