本文介绍了WebDriverError:通过Jenkins和Selenium使用ChromeDriver Chrome时,不会出现此类会话错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从Jenkins运行脚本时,通常不会出现此类会话错误.是什么原因造成的?是否有任何连接失败或由于其他原因(我正在运行26个脚本,并且其中至少有一个脚本没有此类会话错误)

Often I am getting no such session error when I am running the scripts from Jenkins. What's the cause for it? Is there any connection failure or is it due to someother reason (I am running around 26 scripts and out of it atleast one script has no such session error)

这些脚本是不同的脚本,对于相同的脚本,不会再次发生此类会话错误

The scripts are different scripts and no such session error is not again repeated for the same scripts

推荐答案

有时我遇到过这种情况.我将ChromeDriver与Laravel Dusk结合使用,而不是与Selenium结合使用.但是,我认为原因在于ChromeDriver,而不是Selenium

I met this kind of case sometimes. I use ChromeDriver with Laravel Dusk, rather than Selenium. However, I believe the cause is on ChromeDriver, not Selenium

ChromeDriver将在文件夹C:\Users\(yourAccountName)\AppData\Local\Temp中创建一些缓存文件.在此文件夹中,您将看到许多看起来像scoped_dir1234_5678的缓存文件夹.每个文件夹占用约10mb.如果Jenkins频繁运行ChromeDriver,则ChromeDriver可能会在temp文件夹中填充高速缓存文件.您应该考虑一下C驱动器上的30-50GB缓存文件,并充分利用C驱动器.

ChromeDriver will create some cache files in folder:C:\Users\(yourAccountName)\AppData\Local\Temp. In this folder, you will see many cache folders that look like scoped_dir1234_5678. Each folder occupied around 10mb. If Jenkins runs ChromeDriver much frequently, ChromeDriver can overpopulate the cache file in the temp folder. You should think of 30-50GB cache files on your C drive and make full of your C driver.

当我的C盘空间不足时,ChromeDriver将无法启动,然后向我返回错误消息"Facebook \ WebDriver \ Exception \ NoSuchDriverException:无此类会话".

When my C drive is out of space, ChromeDriver will not be able to start, and then return to me the error message "Facebook\WebDriver\Exception\NoSuchDriverException: no such session".

解决方案:

  1. 转到temp文件夹,删除所有可以清理C空间的ChromeDriver缓存文件夹.
  2. 创建可删除/清理ChromeDriver缓存文件夹的脚本.

-更新-

找到导致该问题的另一种情况.

Find another situation to cause the issue.

如果您运行相同的脚本以在同一操作系统上的两个不同实例中同时启动ChromeDriver,则当一个实例完成并关闭chromedriver时,另一个chrome浏览器实例也可能会关闭.

If your run same script to start ChromeDriver in two different instance at same time on same OS, when one instance is finished and shut down the chromedriver, the other chrome browser instance might be closed as well.

例如,您打开两个控制台并执行chromeDriver脚本,或者您的Jenkins项目同时启动.

For example you open the two console and execute chromeDriver script, or your Jenkins project start at the same time.

我相信,即使您运行其他脚本但同时需要chromeDriver,由于chrome浏览器实例关闭,其中一个脚本也将没有此类会话".

I believe even if you run different script but require chromeDriver at same time, one of the script will have "no such session" due to the chrome browser instance shutdown.

解决方案:

  1. 在jenkins中安装构建阻止程序
  2. 在构建阻止程序中设置项目,目标项目需要等待它直到完成.

我的情况是使用不含硒的Laravel Dusk.我不确定通过硒服务器进行测试时是否会有所不同

My case is using Laravel Dusk without selenium. I am not sure if it will make different when test go through selenium server

这篇关于WebDriverError:通过Jenkins和Selenium使用ChromeDriver Chrome时,不会出现此类会话错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 06:33