Selenium可以在一个浏览器中使用多线程吗? [英] Can Selenium use multi threading in one browser?

查看:2160
本文介绍了Selenium可以在一个浏览器中使用多线程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在多线程中测试Web,但是当我打开太多的chromedrivers时,它们会使用过多的内存.我可以在一个浏览器中使用多线程吗?

解决方案

WebDriver不是线程安全.线程安全问题不在您的代码中,而是在实际的浏览器绑定中.他们都假设一次只能有一个命令(例如,像真实用户一样).但是,另一方面,您可以为每个线程实例化一个WebDriver实例,但是它将启动多个浏览器,这将占用更多的内存...

希望这对您有帮助....如果有任何疑问,请尽快回来

I want to test a web in multi threading but when I open too many chromedrivers they use too much memory. Can I use multi threading in one browser?

解决方案

WebDriver is not thread-safe.The issue of thread-safety isn't in your code but in the actual browser bindings. They all assume there will only be one command at a time (e.g. like a real user).But you can on the other hand instantiate one WebDriver instance for each thread but it will launch multiple browsers which will consume more memory...

Hope this helps you....Kindly get back if you have any queries

这篇关于Selenium可以在一个浏览器中使用多线程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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