Skip to main content

Dealing with Selenium WebDriver Driver.Quit crashes (Where chromedriver.exe is left open)

We recently came across a problem with Selenium not quitting the webdriver and this would then lock a file that was needed on the build server to run the builds.

We were using Driver.Quit() but this sometimes failed and would leave chromedriver.exe running. I looked around and found this was a common issue that many people were having. We (I say we, as we came to the solution through paired programming), came up with the following, that would encapsulate the driver.quit inside a task and if this task takes longer than 10 seconds, then it will clean up any processes started by the current process, in the case of the issue on the build server, it would kill any process started by Nunit.

[AfterTestRun]
        public static void AfterTestRun()
        {
            var nativeDriverQuit = Task.Factory.StartNew(() => Driver.Quit());
            if (!nativeDriverQuit.Wait(TimeSpan.FromSeconds(10)))
            {
                CleanUpProcessByInheritance();
            }
       }

        private static void CleanUpProcessByInheritance()
        {
            var currentProcessPid = Process.GetCurrentProcess().Id;
            foreach (var process in Process.GetProcesses())
            {
                using (var mo = new ManagementObject("win32_process.handle='" + process.Id.ToString(CultureInfo.InvariantCulture) + "'"))
                {
                    mo.Get();
                    var parentPid = Convert.ToInt32(mo["ParentProcessId"]);

                    if (parentPid == currentProcessPid)
                    {
                        process.Kill();
                    }
                }
            }
        }

I've read quite a bit around this subject and it seems to be a common issue, that the driver.quit can leave the chromedriver.exe open, hence the need for the above method. Since implementing this fix we've not seen the locked file anymore on the build server, so hopefully it's solved. If not then I'll be sure to update this blog with (hopefully) a new workaround.

Comments

  1. really the way of explanation about selenium concept was so superb.. Software Testing Training in Chennai | Selenium Training in Chennai

    ReplyDelete
  2. Awesome blog with informative content. Thank you for blogging such a excellent blog. Dot Net Training in Chennai | Java Training in Chennai

    ReplyDelete
  3. Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me...
    Software Testing Training in Bangalore
    AWS Training in Chennai

    ReplyDelete
  4. Thanks for your informative post. Your article helped me a lot to understand the future..Web Designing Training Institutes in Chennai | Web Designing Training Institutes in Velachery.

    ReplyDelete
  5. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    selenium training in bangalore|
    python training in bangalore|

    ReplyDelete
  6. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!

    data science training in bangalore

    ReplyDelete
  7. I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
    "Devops Training in Chennai"

    ReplyDelete

  8. The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .
    office 2010 professional plus key deutsch

    ReplyDelete
  9. It is really a great work and the way in which you are sharing the knowledge is excellent.Thanks for your informative article

    selenium training in chennai|

    ReplyDelete
    Replies
    1. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

      Java Training In Bangalore

      Delete
  10. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site."Devops Training in Bangalore"

    ReplyDelete
  11. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    Besant technologies Marathahalli

    ReplyDelete
  12. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!

    Data Science Training in Bangalore

    ReplyDelete
  13. The best thing is that your blog really informative thanks for your great information..Final Year Projects Center in Chennai | Final Year Projects Center in Velachery

    ReplyDelete
  14. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me…
    Power System Project Center in Chennai | Power System Project Center in Velachery

    ReplyDelete
  15. Thanks for your informative article. Your post helped me to understand the future and career prospects. Keep on updating your blog with such awesome article.
    Android Project Center in Chennai | Android Project Center in Velachery

    ReplyDelete
  16. Great tips and its so easy to understand. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog. RPA Training Institute in Chennai | UI Path Training Institute in Chennai | Blue Prism Training Institute in Chennai

    ReplyDelete
  17. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Final Year Project Center in Chennai | Final Year Project Center in Velachery

    ReplyDelete
  18. Awesome blog, you explain everything in detailed manner, it was very interesting to read. Thanks for sharing such an informative blog. Automation Anywhere Training in Chennai | RPA Training Institute in Chennai | UI Path Training Institute in Chennai

    ReplyDelete
  19. Really Great blog about Selenium Wed Drive and Very good explanation. Thank you , keep updating regularly.

    NO.1 CLOUD SERVICES | Oracle Cloud PAAS | MASSIL TECHNOLOGIES

    ReplyDelete
  20. Useful and very informative post. Could you update your upcoming post related selenium and other software testing course.?

    Here few course details
    Big data training in Chennai

    ReplyDelete
  21. Thanks for the useful information of software testing courses, give more updates on software testing development.

    software testing training

    ReplyDelete
  22. You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate. Selenium Training In Bangalore | Best Selenium Training in Bangalore

    ReplyDelete
  23. t's interesting that many of the bloggers to helped clarify a few things for me as well please go for DevOps Training call +91- 9999201478.

    ReplyDelete
  24. It is extremely an extraordinary work and the manner by which you are sharing the learning is excellent.Thanks for your educational article.
    Read Beard Press

    ReplyDelete
  25. It is a one of the great discussion which is very essential for me as well. I must follow the handy discussion and sure that the content will be very useful to me as well. Keep it up.
    Tata Sky New Connection | Tata Sky DTH | Tata Sky DTH New Connection

    ReplyDelete
  26. This is very good blog for learners, Thanks for sharing valuable information...DotNet Project Center in Chennai | DotNet Project Center in Velachery

    ReplyDelete
  27. Really Very Informative Blog.Just Simply cleared All my doubts through your post.Very happy For sharing,Coming to Ourself We Are the leading Providers for Restaurant Parts In Us.Really Thanks For Sharing Such an Informartive Post.

    ReplyDelete
  28. This blog will get more thoughts. This is exceptionally useful for Software Testing students. Much thanks to you for sharing this great site.
    Selenium Training in Chennai | Selenium Course in Chennai | Selenium Training Institute in Chennai| Selenium Training Chennai

    ReplyDelete
  29. Excellent blog with useful concept. Really I feel very happy to see this informative...PHP Project Center in Chennai | PHP Project Center in Velachery

    ReplyDelete
  30. Great post! Thanks for sharing this valuable information.

    Selenium Training in Chennai

    ReplyDelete
  31. I feel really happy to have seen your webpage and look forward to so
    many more entertaining times reading here. Thanks once more for all
    the details.

    hadoop training in chennai

    ReplyDelete
  32. Thanks For Sharing Valuable Information, Very Useful For U Medical Residency in USA

    ReplyDelete
  33. Great blog! Thanks for giving such valuable information, this is unique one. Really admired.

    Selenium Training in Chennai | QTP Training in Chennai

    ReplyDelete
  34. Thanks for sharing this useful post.It was really helpful for me.Keep it up. I am waiting for your next blog. Warehouse Audit | Visibility Audit | Inventory Audit

    ReplyDelete
  35. I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post.

    selenium training in chennai

    ReplyDelete
  36. Thanks for giving a great information about dealing-with-driverquit-crashes Good Explination nice Article
    anyone want to learn advance devops tools or devops online training
    DevOps Online Training contact Us: 9704455959

    ReplyDelete
  37. Really Thanks For Sharing Such an Informative Post and also thanks for posting

    24Layouts

    ReplyDelete
  38. This idea is mind blowing. I think everyone should know such information like you have described on this post. Thank you for sharing this explanation.Your final conclusion was good.
    Hadoop Training adyar
    Hadoop Training in adyar
    Big Data Training in adyar
    Selenium Training in Chennai
    iOS Training in Chennai
    Loadrunner Training in Chennai

    ReplyDelete
  39. Hi admin...your blog was interesting.All the Details were explained in clear manner. Thanks for sharing this blog. Duplicate Payment Audit
    Duplicate Invoice Audit | AP Vendor Helpdesk

    ReplyDelete
  40. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
    best big data training in chennai
    Big Data Hadoop Training
    Hadoop training institutes in chennai
    hadoop big data training in chennai
    big data training institute in chennai
    Best Hadoop Training in Chennai

    ReplyDelete
  41. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
    Selenium Training in Chennai

    ReplyDelete
  42. Thanks for your sharing such a useful information. this was really helpful to me.

    Education
    Technology

    ReplyDelete
  43. Super and Nice Blog with bunch of Real Time Examples.............

    selenium training in chennai

    ReplyDelete
  44. I think things like this are really interesting. I absolutely love to find unique places like this. It really looks super creepy though!! Machine learning training in chennai
    python machine learning training in chennai
    artificial intelligence and machine learning course in chennai

    ReplyDelete
  45. InstantPcApps
    It's a hub for free mac, pc, android and ios software. You can get any kind of game, software and mobile application free of cost. ByteFence Anti-Malware Pro Crack With Activation key

    ReplyDelete
  46. InstantPcApps
    It's a hub for free mac, pc, android and ios software. You can get any kind of game, software and mobile application free of cost. Magix Music Maker 2018 Crack With Serial Key

    ReplyDelete
  47. Torrentsformac
    A free download hub to activate, crack your softwares for windows and you mac. you can download keygen, generator and activators to crack your desired Guitar Pro Crack With Product Key

    ReplyDelete
  48. Keep up the great work, I read few blog posts on this site and I believe that your website is really interesting and has loads of good info.


    Selenium Training in Chennai
    Selenium Training
    iOS Training in Chennai
    French Classes in Chennai
    Big Data Training in Chennai
    iOS Training Institute in Chennai

    ReplyDelete
  49. This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
    JAVA Training in Chennai
    Java Training
    Digital Marketing Course in Chennai
    Hadoop Training in Chennai
    Android Training in Chennai

    ReplyDelete
  50. Thanks for the marvelous posting! I quite enjoyed reading it, you can be a great author.I will ensure that I bookmark your post and will often come back down the road. I want to encourage one to continue your great job, have a nice evening! website seo services

    ReplyDelete
  51. My wife and i were quite peaceful when Albert managed to finish up his basic research through the precious recommendations he was given out of the web pages. It is now and again perplexing just to always be giving away instructions which other folks have been making money from. We really remember we need you to give thanks to for this. The illustrations you have made, the straightforward blog navigation, the friendships your site help engender - it's got most unbelievable, and it's really leading our son in addition to us feel that this situation is cool, and that's extraordinarily important. Thanks for the whole thing!search engine marketing services

    ReplyDelete
  52. Great blog. The information you provide were useful. Keep updating this for more information.
    Selenium Webdriver Training Online

    ReplyDelete
  53. I just could not depart your site before suggesting that I really enjoyed the standard information a person provide for your visitors? Is going to be back often in order to check up on new posts singapore truck

    ReplyDelete
  54. Very Clear Explanation. Thank you to share this. I am waiting for your new blog posting..Keep posting..
    Regards,
    Best Devops Training in Chennai | Best Devops Training Institute in Chennai

    ReplyDelete
  55. I have to voice my gratitude for your generosity supporting women who really want help on this important question. Your very own dedication to passing the message across turned out to be extremely informative and has all the time empowered people like me to realize their dreams.cannabis seed bank usa

    ReplyDelete
  56. I don't know what I would have done if I hadn't come upon such a thing like this. I can at this point look forward to my future. Thank you very much for your skilled and sensible help. I will not hesitate to endorse your web sites to anyone who needs to have recommendations about this subject.wedding photography melbourne

    ReplyDelete
  57. Hello! This is kind of off topic but I need some help from an established blog. Is it tough to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about making my own but I'm not sure where to begin. Do you have any tips or suggestions? Thanks orland park il real estate

    ReplyDelete
  58. What i don't understood is actually how you are not actually much more well-liked than you might be right now. You're so intelligent. You realize therefore significantly relating to this subject, produced me personally consider it from so many varied angles. Its like women and men aren't fascinated unless it is one thing to do with Lady gaga! Your own stuffs great. Always maintain it up! search engine marketing

    ReplyDelete
  59. Such a great article which i read before, it's a valuable suggestion to do in the process we can do.
    SEO training in chennai
    SEO course in chennai
    Digital marketing training in chennai


    ReplyDelete
  60. I believe this is one of the such a lot important information for me. And I'm glad reading your article. But should commentary on few normal issues, The web site taste is great, the articles are actually nice: D. Good task, cheers His comment is here: Eight Ways To Improve Encryption Software & Haven’t You Heard About The Recession: Top Ten Reasons Why You Should How To Encrypt A Password For Free.

    ReplyDelete
  61. This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
    Regards,
    Tableau training in Chennai | Tableau Courses Training in Chennai | Tableau training Institute in Chennai

    ReplyDelete
  62. Thanks for sharing this video! I'm loving this poem. It's true, tester's home is work with a team.
    https://qawerk.com/process/automated-testing/

    ReplyDelete
  63. I’m not sure where you are getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for fantastic info I was looking for this info for my mission. web design studio

    ReplyDelete
  64. I used to be very pleased to seek out this web-site.I wished to thanks for your time for this excellent read!! I definitely enjoying each little bit of it and I've you bookmarked to take a look at new stuff you blog post. a math tuition singapore

    ReplyDelete

Post a Comment

Popular posts from this blog

Coding something simple.... or not! Taking a screenshot on error using Selenium WebDriver

I recently wrote a little function that takes a screenshot at the end of a test if it has errored. What sounded very simple at the start turned out to be quite a bit of work, and quite a few lines of code to handle certain scenarios! It's now over 50 lines of code! I'll start with what I had at the beginning, this was to simply take a screenshot in the working directory, we are using SpecFlow and Selenium to run the tests, so we are going to check if the ScenarioContext.Current.TestError isn't null, if it is, then using Selenium, take a screenshot (note the below code is a simplified version of what I had at the beginning). [AfterScenario]         public static void TakeScreenShotOnError()         {             if (ScenarioContext.Current.TestError == null) return;             var screenshotDriver = Driver as ITakesScreenshot;             if (screenshotD...

How to manage resources within new teams?

Working where I work we are constantly spinning up new teams to take on new workloads as business come up with new demands and new features they want developed and tested. The problem with this is how do we ensure the work of the newly spun up team is of sufficient quality. One method is by taking people from other established teams and placing them on the new team. This works great for the new team, but unfortunately it will oftenl eave the established team lacking in a resource whilst they try and fill the gap left by the person who has left. We are seeing this often with our offshore teams, it can be damaging to the team structure and the teams velocity, but try as I might, I can't think of another way around it. It's far easier to take 1 person from a team that is established than it is to build a whole new team from scratch. At least by leaving the core of a team in place, you should be guaranteeing that the new team are aware of any coding standards or any QA standard...

Considerations when creating automated tests

We recently released to a number of teams our automated regression pack that has been worked on over the past few months. This regression pack tests legacy code, but contains a large number of tests.  As a bit of background, a number of teams are working on new solutions whilst some are still working on legacy code. With this in mind we constructed an email with a list of guidelines when creating new tests that need to be added to this regression pack.  I figured that these can be quite broad so should apply for any organisation, so thought it would make an interesting blog post...  So here goes,  when creating automated tests, it's important to consider and adhere to the following: - Think about data . The tests need to retrieve or set the data they need without any manual intervention - This should help them be more robust and easier to run without manual intervention. - The tests need to be idempotent - By making it so that each test is standalone and does...