WebDriverError:通过 Jenkins 和 Selenium 使用 ChromeDriver Chrome 时没有此类会话错误 [英] WebDriverError: no such session error using ChromeDriver Chrome through Jenkins and Selenium

查看:30
本文介绍了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)AppDataLocalTemp.在此文件夹中,您将看到许多类似于 scoped_dir1234_5678 的缓存文件夹.每个文件夹占用大约 10mb.如果 Jenkins 经常运行 ChromeDriver,ChromeDriver 可能会过度填充临时文件夹中的缓存文件.你应该在你的 C 盘上考虑 30-50GB 的缓存文件,并充分利用你的 C 驱动.

ChromeDriver will create some cache files in folder:C:Users(yourAccountName)AppDataLocalTemp. 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将无法启动,然后返回给我错误信息FacebookWebDriverExceptionNoSuchDriverException: no such session".

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

解决办法:

  1. 进入temp文件夹,删除所有ChromeDriver缓存文件夹即可清理C空间.
  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.我不确定通过 selenium 服务器进行测试时是否会有所不同

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 时没有此类会话错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆