Close residual instances of Selenium WebDriver after forced stop

I would like to find some new conceptual ideas, but concrete solutions are welcome.

Technology

  • Version control system: SVN
  • Continuous Integration Tool: TeamCity
  • Agent: Windows (no administrator rights!)
  • Language: Java
  • WebDriver: InternetExplorerDriver
  • Testing: JUnit
  • Build: ant

Problem

If someone stops the setup (a string in the TeamCity GUI) while it is running, the method afterClass

fails (it closes the browser) and the browser becomes leftover.

Structure

enter image description here

( beforeClass

starts the driver, but afterClass

closes it)

Flow

enter image description here

(where you see a red arrow, someone stops the setup -> For example: (s) he noticed the test failed and wants to run it again, but it creates a residual browser because it afterClass

fails)

Previous attempts

  • Go to the agent and restart it manually (1 time / 1-4 weeks) - works, but has important drawbacks.
  • Go to agent and try to use taskkill

    and taskkill /F

    - doesn't work
  • Other Java attempts (run "cleaner" before tests - Windows native commands), but without success

Do you have any ideas? They can be related to agent, TeamCity, Java code, ant, specific configurations, etc.

+3


source to share


1 answer


If I understand the question correctly, stopping the configuration kills the jvm, leaving the remains of the browser. I'm right? If so, you can try adding a shutdown faucet and handle browsers closing at shutdown. those. you can put a browser close lock in a method and call it both with the completion hook and after the Class with proper exception handling.



Hope this answer helps you.

0


source







All Articles