与Selenium开幕超过9次 [英] Opening more than 9 sessions with Selenium

查看:125
本文介绍了与Selenium开幕超过9次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Selenium一次访问几十个会话的网站,但每当我尝试设置超过9个会话时,它都会显示chromedriver.exe没有响应,会话开始关闭。



以下是我的代码:

 来自selenium import webdriver 
进口时间
$ b $ url =网站网址
金额= 36
$ b $ def generateBrowsers():
代表范围内的x(0,金额):
driver = webdriver.Chrome(executable_path =C:/Users/user/Documents/chromedriver_win32/chromedriver.exe)
driver.get(url)
time.sleep(3 )

generateBrowsers()

有谁知道什么可能是错的? / b>

解决方案

从逻辑上讲,您的代码块有无错误

但是,当您尝试每次打开 36个会话时,您需要考虑以下事实:


    <1每次调用 driver = webdriver.Chrome(executable_path =C:/Users/user/Documents/chromedriver_win32/chromedriver.exe) 将启动:

      1。一个新的WebDriver实例
    2.一个新的Web浏览器实例


  • WebDriver 实例和 Web浏览器 实例需要占用一些金额:

      1。 CPU 
    2.内存
    3.网络
    4.缓存


  • ul>

    现在,当您从系统执行测试套件时,它也会运行很多其他应用程序(其中一些可能位于 Start Up )试图在可用的 CPU 内存 网络 缓存 。因此,无论何时,上述参数的使用超出阈值级别,或者下一个新的 chromedriver.exe chrome.exe 将无法正确产生。在你的情况下, chromedriver.exe 无法产生。因此你会看到错误:

      chromedriver.exe没有响应
    解决方案



    如果您有要求每次产生 36个会话的要求您需要使用:


    • 网格配置中的Selenium Selenium Grid Hub 节点 ,您将能够在节点数量中分配所需的会话数量。


    I am trying to use Selenium to visit a website with a few dozen sessions at a time, but whenever I try and setup more than 9 sessions, it says "chromedriver.exe is not responding" and the sessions start closing themselves.

    Here is my code:

    from selenium import webdriver
    import time
    
    url = "website URL"
    amount = 36
    
    def generateBrowsers():
        for x in range(0, amount):
            driver = webdriver.Chrome(executable_path="C:/Users/user/Documents/chromedriver_win32/chromedriver.exe")
            driver.get(url)
            time.sleep(3)
    
    generateBrowsers()
    

    Does anyone know what could be wrong?

    解决方案

    Logically, your code block have No Errors.

    But as you are trying to open 36 Sessions at a time you need to consider the following facts :

    • Each call to driver = webdriver.Chrome(executable_path="C:/Users/user/Documents/chromedriver_win32/chromedriver.exe") will initiate :

      1. A new WebDriver instance
      2. A new Web Browser instance
      

    • Each of the WebDriver instance and Web Browser instance will need to occupy some amount of :

      1. CPU
      2. Memory
      3. Network
      4. Cache
      

    Now, as you execute your Test Suite from your system which also runs a lot other Applications (some of them may be on Start Up) tries to accomodate within the available CPU, Memory, Network or Cache. So whenever, the usage of mentioned parameters gets beyond the threshhold level, either the next new chromedriver.exe or the chrome.exe will be unable to spawn out properly. In your case chromedriver.exe was unable to spawn out. Hence you see the error :

    chromedriver.exe is not responding
    

    Solution

    If you have a requirement of spawning 36 Sessions at a time you need to use :

    • Selenium in Grid Configuration : Selenium Grid consists of a Hub and Node and you will be able to distribute required number of sessions among number of Nodes.

    这篇关于与Selenium开幕超过9次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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