I am running my Selenium test on CentOS for some time now and lately I encountered a lot of stability issues and crashes for my test runs. I went on to find that Selenium browser profiles created under the temp
folder were never getting deleted. I manually deleted all temp files and now the system seems stable. Is there a check I can put in place to handle this and ensure temp files are deleted once the browser instance is terminated by driver.quit()
?
You could delete all cookies before quitting the driver. That should do it.
driver.manage().deleteAllCookies();
That's all you could do for wiping data before quitting the driver.
I did not find a permanent fix for this but here is a workaround I implemented to clean the temp directories created by my browser(chrome)
#!/bin/bash
#file that has a list of all server IPs that need the temp folder cleaned
server_lists=/etc/server_lists
#command to clean temp with chromium directories created prior to 30 minutes
cmd='echo "Clean temp"; find /tmp/ -maxdepth 1 -mmin +30 -iname ".org.chromium*" -type d -exec rm -rf "{}" \; && echo Done'
for ip in $( < $server_lists )
do
ssh -o StrictHostKeyChecking=no $ip "$cmd"
done
I run this shell script every 30 minutes to check and clean all temp directories created by my browser
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.