1

I am running C#-Selenium on IE11 on Windows 7/10. All the while when running the Script, the IE11 Memory keeps increasing until it reaches 1.5GB of Memory. Note I can't close or quit anything since I need my test to keep running. The Problem is IE11 keep getting bigger as the test progresses

In comparison, When running the same script with QTP, none of it happens. 32 bit WebDriver Version: 3.8 & 3.141

The Web Application itself is a propriety one Do you have any idea Where do I start looking to resolve the Issue?

Thanks

Tried reducing my code, sniffing for memory leaks

Shmulik b
  • 19
  • 4
  • run 'taskkill /f /im iexplore.exe' which should clean up the unresponsive windows. see the original [answer](https://stackoverflow.com/questions/36729512/internet-explorer-11-does-not-close-after-selenium-test) – lloyd Jan 03 '19 at 09:46
  • I have no Problem closing or killing IE. The Problem occurs when and while Running the Script – Shmulik b Jan 03 '19 at 11:06

3 Answers3

0

The issue might be that your test scripts actually don't close the browser(s).

I've experienced a bug in selenium IE that it doesn't close the browser with the .close, or .quite commants. That means it will open a lot of windows and that could cause the memory leaks..

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Gem
  • 1
  • 2
  • It happens while the Script is Running. – Shmulik b Jan 03 '19 at 10:03
  • Forgot to mention: I'm using 32bit version of the WebDriver – Shmulik b Jan 03 '19 at 10:22
  • Have you seen the tests work in IE? (no problems with security pop-ups inside the IE window?) Does this problem also occur with a subset of the tests? – Gem Jan 03 '19 at 11:45
  • Do you close the IE windows after each test? Or are you keeping them open? Because then the problem can also occur while the script is running... Had a virtual machine run out of memory due to many unclosed windows. – Gem Jan 03 '19 at 11:50
0

Some sample code snippet of WebDriver and Web Browser initialization/closure process would have given us some hint why using IEDriverServer and IE11 memory keeps increasing until it reaches 1.5GB.

Perhaps as per best practices always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully as follows:

driver.quit() // Python
// or
driver.quit(); // Java
// or
driver.Quit(); // DotNet

You can find a detailed discussion in PhantomJS web driver stays in memory

Incase the IEDriverServer processes are still not destroyed and removed you may require to kill the processes from tasklist.

  • Python Solution(Cross Platform):

    import os
    import psutil
    
    PROCNAME = "IEDriverServer" # or chromedriver or geckodriver
    for proc in psutil.process_iter():
        # check whether the process name matches
        if proc.name() == PROCNAME:
            proc.kill()
    

You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?

Additionally,

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • The Problem is I can't close or quit anything since I need my test to keep running. The Problem is IE11 keep getting bigger as the test progresses – Shmulik b Jan 03 '19 at 13:28
  • this doesn't answer the question – Corey Goldberg Jan 03 '19 at 17:20
  • @Shmulikb _Selenium_ is extensively used for _Test Automation_ where each _testcase_ is based on _usecases_. IMO, _...need my test to keep running..._ is not a valid _usecase_. Perhaps you may require to take help of an _Application Server_ e.g. _Tomcat_. – undetected Selenium Jan 04 '19 at 06:10
  • @DebanjanB As mentioned, QTP does the job well and Selenium somehow causes IE11 memory to explode in a span of 5-10 minutes of Running. – Shmulik b Jan 05 '19 at 09:17
  • @Shmulikb Can't comment about QTP but Selenium by design is a bit different from QTP. Moreover IE is another big challenge which one need to master. – undetected Selenium Jan 05 '19 at 09:21
0

After a lot of searching I somewhat solve the issue by disabling the "Script Debugging (Internet Explorer)" in IE11 under Tools --> Options --> Advanced.

on my Selenium Code there's a listening to this ScriptExecuted events (which is a must in my code):

    firingDriver.ScriptExecuted += firingDriver_ScriptExecuted;

Can it be related?

So for now, I have no Idea why Disabling script debugging dramatically reduced the Memory Leaks. When running the same QTP scenario there is no Memory Leak.

and If anyone has an Idea, I would love to hear it

Thanks!

Shmulik b
  • 19
  • 4