I'm using React-Admin (4.2.0) with the adapted distribution of API-Platform (2.6.8) using Next.js.
I'm trying to test this application with Cypress (10.2.0).
The tests are structured in a way that they execute a database reset and login first, which work fine. After the login I want to navigate to the page under test using cy.visit() (e.g. cy.visit(#/processes)). In the launched browser I can see that the page is visited and all sub-requests are being made until the page is fully loaded. Unfortunately the cy.visit() method doesn't register that the loading is completed and instead times out.
The log shows output like:
TEST BODY
[...]
visit #/processes -> 308: http://host.docker.internal:2000/admin
CypressError
Timed out after waiting 60000ms for your remote page to load.
[...]
When I disable security the first visit() returns positively even before anything on the page is rendered. But all subsequent visits fail as discribed above.
As I understand it the visit() instruction waits for the page to fire the load event. React-Admin seems to not fire this event anymore. Those tests worked with React-Admin 3 (in Create-React-App).
What are my options to test a React-Admin application with Cypress when I want to navigate to pages directly through a URL?
What makes Cypress think that this visiting should return a 308 (permanently moved) status code when I navigate to a page by URL?
Related
I have Cypress tests failing only on Github CI with this error:
Your page did not fire its `load` event within `60000ms`.
I assume this is because the Cypress browser is stuck loading something Github Actions environment is blocking. Tests run fine locally. However, because I do not have access to the browser console, I cannot know what is causing the error.
Based on Cypress the service screenshot the page loaded fine, though.
How can I either
Disable load event check in my Cypress tests, as I assume this is not a real issue
Access JavaScript logs or Network tab logs though Cypress service to confirm what could be the issue in Github Actions run-time environment
This is a SvelteKit based site.
It's not currently possible to opt-out of waiting for the load event: https://github.com/cypress-io/cypress/issues/788
I have an extension with a background page and a sandbox page where most of the content scripts execute.
Whenever I need to do an Ajax call it has to run in the background environment as otherwise I get a CORS error. Recently as of last week I believe, the chrome.runtime is no longer available in the sandbox environment for some reason. I can't find any notes etc about it and trying to figure out a solution how to communicate with background page now.
I had this in the sandbox environment to initialize a connect port to pass messages from an Ajax request
var ajaxCall = chrome.runtime.connect({name: "ajaxCall"});
Is there any info out there that I'm missing on why this change occurred and what are some possible workarounds?
Here's the output for chrome. 1st is the background page and 2nd is the sandbox. They used to be identical in both.
When running ASPNetBoilerplate in debug mode, if I have a breakpoint in my controllers, when I access the site from the url, the breakpoint is accessed twice. is there something I might have changed that would cause this.
(breakpoint on HomeController/Index even fires twice).
try with different browser. some browsers resend the request if it fails. so when you wait on the debug line it might be trying to resend the request.
another option; clear breakpoints and write a log to see the behavior.
I am running a JMeter script to hit a web page that opens another link to a shopping cart. There are a few different urls that JMeter recorded for me using the HTTP Script Recorder. When running the JMeter script, I receive no errors in any logs ( JMeter log and a few summary report / View results tree logs ). I even added a Constant Timer to some of the pages that do actually take a few seconds to load when hitting them manually in a web browser. In the end, I cannot see what is happening, but JMeter also does not indicate any errors. How can I confirm that each url hit is actually succeeding so that the shopping cart actually gives me my item when JMeter is done?
If JMeter is able to make a http request successfully, it will be always green in View Results Tree (200 http code). It does not mean that your test is correct - ie even if the login is not successful JMeter does not report it as error/failure unless you validate the response.
I think you need assertions to ensure that the http response you get is as you are expecting.
Is there a universal way to detect when a selenium browser opens an error page? For example, disable your internet connection and do
driver.get("http://google.com")
In Firefox, Selenium will load the 'Try Again' error page containing text like "Firefox can't establish a connection to the server at www.google.com." Selenium will NOT throw any errors.
Is there a browser-independent way to detect these cases? For firefox (python), I can do
if "errorPageContainer" in [ elem.get_attribute("id") for elem in driver.find_elements_by_css_selector("body > div") ]
But (1) this seems like computational overkill (see next point below) and (2) I must create custom code for every browser.
If you disable your internet and use htmlunit as the browser you will get a page with the following html
<html>
<head></head>
<body>Unknown host</body>
</html>
How can I detect this without doing
if driver.find_element_by_css_selector("body").text == "Unknown host"
It seems like this would be very expensive to check on every single page load since there would usually be a ton of text in the body.
Bonus points if you also know of a way to detect the type of load problem, for example no internet connection, unreachable host, etc.
WebDriver API doesnot expose HTTP status codes , so if you want to detect/manage HTTP errors, you should use a debugging proxy.
See Jim's excellent post Implementing WebDriver HTTP Status on how to do exactly that.
If you just need to remote-control the Tor Browser, you might also consider the Marionette framework by Mozilla. Bonus: It fails when a page cannot be loaded: (see navigate(url) in the API)
The command will return with a failure if there is an error loading
the document or the URL is blocked. This can occur if it fails to
reach the host, the URL is malformed, the page is restricted (about:*
pages), or if there is a certificate issue to name some examples.
Example use (copy from other answer):
To use with the Tor Browser, enable marionette at startup via
Browser/firefox -marionette
(inside the bundle). Then, you can connect via
from marionette import Marionette
client = Marionette('localhost', port=2828);
client.start_session()
and load a new page for example via
url='http://mozilla.org'
client.navigate(url);
For more examples, there is a tutorial.