How to prevent removing error pictures in Cypress? - automation

I want to prevent removing screenshots in Cypress. Each time the previous one is getting removed.
How can I prevent that in Cypress?
Because I want to keep all screenshots.
/Users/mac/cypress/cypress/screenshots

In cypress.json
Set "trashAssetsBeforeRuns": false

Related

Instagram Login Failure Issue

enter image description here
When i try to login my instagram through the web this blank screen doesn't load. Tried clearing cache and cookies on the browser but still the issue persists. On inspecting the page on console this error is displayed
https://i.instagram.com/api/v1/business/account/get_web_pro_onboarding_eligibility/
The resource https://www.instagram.com/static/bundles/es6/FeedSidebarContainer.css/f627ebef4169.css was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.
Subsequent non-fatal errors won't be logged; see https://fburl.com/debugjs.
Same errors here. Feed site is empty. I can open my profile site or profiles from other users, that is working.
See the screenshot. On the feed site is a GET request and in the status I get "429 Too Many Requests". I have no glue what is going wrong here. On my two other Instagram profiles the feed is working.

How to mark a test as xfail (expected failure)?

I have a Testcafe test that looks for a link and clicks on it. Depending on the environment that I run it in, it may or may not be a valid link, and that is okay. What matters is that the link is found and clicked on, not that it goes to a valid page. For example, it may go to a domain that does not exist.
How can I ignore the error resulting from the click() call? I tried suppressing it in a try/catch, but it did not work.
Another alternative, how can I mark the testcase as XFAIL, so that it will be treated as an expected failure?
Unfortunately, TestCafe does not have built-in tools to suppress this error or treat a test as an expected failure. The only way to suppress the error on clicking on an invalid link is to use try/catch.
However, if your only goal is to find the link on a page, you can use Selector.exists to verify that the selected element exists.
Before clicking on a link you can check whether link exists and it is visible like
await selector.exists && await selector.with({ timeout: 5000}).visible

Cypress making a duplicate of DOM element

The Cypress for some reason produces a duplicate of an element, which makes it hard to make certain assertions.
We're working in the WordPress environment with our plugin and the flow of the test is:
Creating a page with our plugin
Adding an element (Post Grid in this case)
Changing some attributes
Saving the page
Viewing the page
E.g. A post grid is a usual div element which contains two items (links to blog posts) in it, but due to its being duplicate, the following assertion fails.
cy.get('.vce-posts-grid-list')
.find('.vce-posts-grid-item')
.its('length')
.should('be.eq', 2)
Our plugin utilizes an iframe and generates content (HTML) inside it.
Note: This issue occurs only sometimes, NOT 100% of the time.
Is it a Cypress specific issue or a reaction for WordPress and possibly our plugin environment?

What is the proper way to test mandatory field in selenium

I am testing my web application using Selenium. All the form validation in the web application is done by HTML5 and some JS(for safari browser). I want to know what is the proper way to test the form validation.
Currently I am using one approach, i.e Before I filled up a mandatory field I clicked on the submit button. If the page is not refreshed then I assume the form validation working correctly. But I think there should be a better approach to do it. I am unable to find any proper solution. Any suggestion will be highly appreciated.
I also go through this link. But it is not working for me because it is not enough to have required attribute (eg required attribute does not work in older Safari browser).
Rather than checking if the page is refreshed or not, you should instead expect that it is not and that a certain error message or field highlighting or something is applied to the current page. When in an error state, the input fields probably get given an extra class, or an error div/span might be added to the DOM, try checking for that sort of thing

Trouble with Karma + AngularJS Scenario Test Runner and a form

Ok, I'm having issues with my Test Runner where it is filling out the fields on the form but when I then submit the forms it refers to these fields as blank.
If I write to the field using element('some_element).val('some_val') this works fine.
If I then check the field with expect(element('some_element').val()).toBe('some_val') it passes without any problem
BUT
If I submit this form, it returns saying all these elements are empty. However I can change just one character manually and it accepts it without any issues.
Could anyone explain what would cause such an issue? And also any possible solutions on how to get round it?
The issue was with KendoUI and not the test runner.