Occasionally any large test automation suite leaves some stray browser and/or webdriver processes behind during test execution. They make our test suite slower and cause other issues, for example a stray process process may hold entire directory and prevent it from cleaning. Clean test environment is very important for test isolation and prevention of false positives. This is an example of process cleanup in Linux where we find the processes in question by their names and kill them.
And here is another example where we do the same process cleanup in Windows Powershell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo kill $(ps aux | grep '[f]irefox' | awk '{print $2}') | |
sudo kill $(ps aux | grep '[g]oogle-chrome' | awk '{print $2}') | |
sudo kill $(ps aux | grep '[g]eckodriver' | awk '{print $2}') | |
sudo kill $(ps aux | grep '[c]hromedriver' | awk '{print $2}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps *firefox* | kill -f | |
ps *chrome* | kill -f | |
ps *edge* | kill -f | |
ps *geckodriver* | kill -f | |
ps *chromedriver* | kill -f | |
ps *edgedriver* | kill -f |