Skip to main content

Posts

Showing posts with the label Selenium WebDriver

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.Fr...

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...

NxtGenTesting Conference

I've just bought my ticket for the  NxtGenTesting Conference  on May 23rd. A number of talks are appealing to me, but these are just some of the highlights for me personally and why: Building agile automated test scripts with Selenium WebDriver - This is a big highlight for me, and reason enough to go alone in my eyes. I've got a fair amount of experience with Selenium WebDriver, but only in one company, so I'm really looking forward to seeing how other people do it and to discuss the pros and cons of each approach. Mobile Testing - Obviously with such an increased amount of traffic coming through mobile devices to any website and with mobile browsing predicted by some to overtake fixed internet browsing in 2014, I'm interested to see how we can ensure they have the best experience as possible, but obviously this means testing on a number of new devices and OS, how can we manage that? I have a few ideas, mainly about prioritising user traffic and browser engines ba...