Playwright - URL is not loading sometimes - testing

when I start the test, the browser is opened but it does not load the URL.
After 10-15 seconds it stopped to load (see screenshot).
I had updated intelliJ, updated playwright to version 1.28.1 (doesn't help)
It happened 7 out of 10 trials.
Any idea why it suddenly becomes that behavior?
Many thanks!

there are 3 probabilities causing this error when hitting the URL:
Your browser version could be a outdated which the site is blocking, so try updating playwright browsers using the command 'npx playwright install'.
Check whether the site is being blocked due to any firewall or proxy setting and if so, get it whitelisted.
As the request also seems to be a crash due to timeout, kindly check whether you have decent internet speed.

Related

Manually setting QUARANTINE_THRESHOLD and DISCONNECT_THRESHOLD in testcafe does not work

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.

Testcafe caught in page reload loop

I have a set of Testcafe tests for our application, which since recently fails to run in some of our environments. The test only opens the browser, loads the start page specified in the fixture (or navigated to in within the test) and then only appears to continuously reload the page without proceeding with the test. This happening across all browsers (Chrome, Firefox, Edge) and different versions of NodeJs and Testcafe on Windows 10.
After enabling debug logging I found this message repeatedly in the log:
{
cmd: 'wait-for-file-download',
sessionId: '0X_DqYtz0'
}
The browser console also showed two page resources/scripts that failed to load with net::ERR_FAILED errors due to violating the Content Security Policy, so I assume that these might cause the problems. However it does not seem to have any impact on manual page interaction or automated test using other frameworks like PyTest.
While we are investigating on the conflicting resources, is there anything I can do in Testcafe to bypass the issue and allow the tests to run? Or alternatively is there a way to fail a Testcafe test when encountering this issue instead of reloading and possibly eventually timing out?

Chrome Headless - Firefox

I'm working on a monitoring tool for my website to log data. The actual logging is made on server. My goal is to calculate stats based on how long the user stays on the website.
Main question: I used chrome headless command --remote-debugging-port=80. I got logs for up to 10 minutes. Works perfectly. But how long will it work if left working? Is there a default timeout? If yes, how can I change it? If I want to run it exactly 30 minutes after page finished loading?
I'm trying to do the same on firefox (tried using PhantomJS but it wasn't loading the page correctly even though useragent was set to firefox) but firefox just throws an bank page when I'm trying to start a headless mode. I used "firefox -headless" and tried capturing an screenshot. It was just exiting my currently open firefox tabs without capturing any image. Any idea?
Using firefox quantum 59.0. I don't want to use selenium.
Also PhantomJS solution would be great. Currently I just want to collect logs. So, it only have to run all javascript (an jquery) code on the page which then sends the data using ajax. I tried page.onLoadFinished and then a wait function to make it stay on the page for the exact time after page loading.
Since no one answered, I will try to answer my own question after even more research and logical thinking.
Main question: Seems that there is no timeout but if need can be used --timeout X. Even though it's not perfect because it runs independently if the page if fully loaded or not.
As for the firefox, it's buggy. -new-instance (make headless run while you are already on firefox) is not working and -no-remote didn't help. Firefox is only working if running only one instance. So, if it's the PC you are working on and you want to run tests too, firefox is not for you. Headless runs only when no other instances of firefox are running, while chrome runs fine.
PhantomJS didn't work even though tried multiple solutions.
Best solution? Use chrome. Need portable? Use chromium and use headless. Or write your soft to use cefsharp which is based on chromium. Your browser with all libs will be around 120-200MB. Pretty big for portable but do it's work. Same as portable chrome or chromium. CefSharp have a privilege of integrating whatever you like into the browser since it's a... browser.

Is Phantomjs session isolation still not working?

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.

Why won't MicrosoftAjax.js load over SSL in google chrome on some PCs?

I'm using microsoft's CDN for pulling down the Ajax libraries. And I'm using SSL on some pages.
This URL resolves fine in Firefox and IE:
https://ajax.microsoft.com/ajax/4.0/MicrosoftAjax.js
However in google chrome (on my PC, today...) it seems to time out with a very odd response:
On other PCs it seems to work fine, however I know I'm not the only one experiencing the problem as we've had occasional complaints from some of our clients about certain pages timing out and failing, that seems to point to the same problem.
As per my comment, I experienced the same issue but with Firefox failing and Chrome and IE succeeding.
Restarting the browser and the computer had no affect. Clearing the browser cache did fix the issue. I can only assume there was some kind of corruption in the browser cache.