Basically I've created a program using selenium webdriver (phantomjs) and if errors occur I gracefully close the drivers so no unwanted processes are hanging behind the scenes.
My concern though, is what would happen if my program got shut down for some reason (either by the user or the system). The remaining driver processes would hang behind infinitely which could raise some serious issues in the long run.
Is there any way to ensure that whenever I start my program, any existing phantomjs processes will get shut down (or even better, shut them down whenever the program is shut down)?
I'm using selenium webdriver using C# by the way.
You could try:
$ killall phantomjs
https://github.com/karma-runner/karma/issues/191
Related
This is not about pinning down the hang as such, its more about wondering if there is a way to make testcafe decide the test must be a failure after a given period of time.
Our test works fine on local machines, but occasionally when run in CI using a docker image on semaphore one of the selectors causes it to hang. I am fine ivestigating why that is, but it would be good if I could tesll the test to give up after say 5 minutes (it should finish in under 3) and exit gracefully so we can have the stack trace and video - if we have to kill the test run we don;t get either, so we end up having to debug by the logging we emit from the test code.
Currently, this functionality is not implemented in TestCafe. Please track the https://github.com/DevExpress/testcafe/issues/6096 issue to check our progress.
I changed the QUARANTINE_THRESHOLD and DISCONNECT_THRESHOLD in test_run_controller.ts file to 1 million each and built successfully however, my test still fails after around 1000-10000 restarts with the error :
ERROR The Chrome 89.0.4389.90 / Linux 0.0 browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues.
Is there something else that may be forcing testcafe to quit? or is the issue in browser perhaps?
Thank you
According to the error, your browser hangs for some reason. The problem could be in the way you organize your tests. It's likely that you have some code that leads to memory leaks, and after 1000-10000 restarts, your machine does not have enough RAM to run the browser.
Please clarify why you need to restart your tests 1000-10000 times.
I changed the QUARANTINE_THRESHOLD and DISCONNECT_THRESHOLD in
test_run_controller.ts file
We are working on the quarantine mode configuration, so you will have the capability to change quarantine options out of the box.
When I run my selenium tests using a chrome browser all my tests cases run fine. When using the phantomjs browser it would appear that the browser session does not get reset after each test case. In my tests cases, I log in as a user to then navigate to certain pages and then logout. A problem occurs when a test case happens to fail. The browser session is not reset so when the next test case begins, the test that failed was unable to logout. This causes all test cases after a single failure to fail.
When searching the internet for a solution to this issue it been known sine 2013. I can't seem to find anything regarding this issue that's recent. Is there any up to date workarounds?
Manually trying to delete the cookies before or after each test case does not appear to work. webDriver.manage().deleteAllCookies();
I'm using phantomjs ver 2.1.1.
First of all PhantomJS is dead, you are better off switching to Headless Chrome or Headless Firefox.
Secondly PhantomJS is a port of Webkit which is not thread safe. This means that if you try and run more than one test in parallel you will see threading issues, to fix this you would need to start multiple instances of PhantomJS and have each GhostDriver instance connect to a different instance of PhantomJS.
The particular problem that you are seeing is that PhantomJS doesn't clear itself down properly, again the only solution would be to kill the initial PhantomJS instance you are running after your test finished and then start up a clean new one, unfortunately that is not supported by GhostDriver.
The final problem is that GhostDriver is dead as well, there was no point in continuing development when PhantomJS died.
TLDR; Use Chrome/Firefox Headless mode instead.
I want my browser to start on startup. At the moment it works quite randomly. On some boots the browser flashes quickly and is running in the background. When this happens, I can't start a new browser session before I kill the existing one.
How can I prevent this from happening? I'm currently doing this with a shell script, but I've also tried the autostart method and both give me same results.
When running several tests synchronously using Selenium with IE, after about 10 minutes the browser starts to freeze. The browser will not render pages properly or respond at all. I can only diagnose that when these symptoms occur, the Memory reaches about 1.7G and hovers around there. I use Capybara so after every test, on average about every 30 seconds, it will reset the session. This issue does not occur when I use Firefox or Chrome.
Does anyone have any thoughts? I could try figuring out why it stops at 1.6G, but I imagine I'd hit the same issue once hit what ever new cap is set. I could also restart the process every few tests, but that would slow the test run down dramatically.
Configuration:
OS: Windows 7 64-bit
Selenium grid: v2.46.0
IEDriver: 32-bit
v2.46.0.0 (Tried using 64 bit but sending keys went very slow)
Browser: IE11
Thanks in advance for thoughts you might have.
We ran into the same problem and noticed that every character typed using sendKeys() consumes around 2 MB (!) in IE. We now restart the driver every 10 tests, which works for us.
Note: you could try replacing webElement.sendKeys with a Windows API call like SendInput and see if the problem in IE still remains.