简体   繁体   English

测试对于本地Web应用程序运行太慢。 使用C#Selenium WebDriver

[英]Tests are running too slow for local web app. using C# Selenium WebDriver

I'm using C# selenium WebDriver(latest version), and I have written some tests for a web application 我正在使用C#硒WebDriver(最新版本),并且已经为Web应用程序编写了一些测试

The tests have been run perfectly when the web app. 该测试已在Web应用程序上完美运行。 is hosted on a server, but when I were trying to run the same tests for the same web app. 托管在服务器上,但是当我尝试为同一Web应用程序运行相同的测试时。 and is hosted on my machine locally, they are very slow, any help would be appreciated 并托管在我的本地计算机上,它们的运行速度非常慢,不胜感激

Thanks 谢谢

I had the same issue you're experiencing. 我遇到了您遇到的相同问题。 I have two suggestions. 我有两个建议。 As @BugFinder mentioned, odds are that you need a more powerful local machine. 正如@BugFinder提到的,可能需要一个功能更强大的本地计算机。 That will help a ton, however there could be two other issues that you're experiencing that cause massive slowdown. 这将大有帮助,但是您可能还会遇到其他两个导致大量速度下降的问题。

Whenever a test runs, if it fails and you do not have a [TearDown] (or if you ONLY have a [OneTimeTeardown]) the system does not dispose of the driver or the console host that Selenium uses to run tests, so there is a chance that you have massive memory leaks that could slow down testing heavily. 每当运行测试时,如果测试失败并且您没有[TearDown](或者如果您只有[OneTimeTeardown]),则系统不会处理Selenium用于运行测试的驱动程序或控制台主机,因此存在您可能会遇到大量内存泄漏,这可能会严重降低测试速度。 I created a simple batch script that ends all processes related to the tests that has these two simple commands (If you aren't using IEDriverServer replace that with ChromeDriver or whatever you use): 我创建了一个简单的批处理脚本,该脚本结束了与具有这两个简单命令的测试相关的所有过程(如果您不使用IEDriverServer,请用ChromeDriver或任何您使用的命令替换它):

taskkill.exe /F /IM IEDriverServer.exe /T
taskkill.exe /F /IM conhost.exe /T

If you are running locally you can run the batch file yourself or you can implement this into your remotely run tests through AutoIT or a similar program. 如果在本地运行,则可以自己运行批处理文件,也可以通过AutoIT或类似程序将其实现到远程运行的测试中。 If this issue is one that persists for you, you can have 5mb of memory for EACH IEDriverServer (or whatever driver you use) and a couple mb of memory for each conhost process running. 如果这个问题仍然存在,那么您可以为每个IEDriverServer(或您使用的任何驱动程序)提供5mb的内存,并为每个运行的主机进程提供2mb的内存。 If you run 100s of tests, you can see how that can add up quickly. 如果您运行100项测试,则可以看到它们如何快速相加。

I hope that this answer either directly helps or gets your mind thinking about the solution to your problem. 我希望这个答案可以直接帮助或者让您思考解决问题的方法。

As you guys said, the whole thing is because the local machine I have noticed that my anti-virus was running a full scan recently, so that the tests were too slow. 就像你们说的,整个过程是因为我注意到本地计算机最近在运行我的防病毒程序的全面扫描,因此测试太慢了。 Things are normal now on the local machine :) 现在在本地计算机上一切正常:)

Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM