An issue most of us have seen!
Some web-elements are dynamically generated as a result of a previous action. For example, selecting a check-box in a web-form might populate the UI with another panel or field. Often these elements similarly have a dynamically generated Class or Attribute name and no static ID or Class we can reference when running cy.get(). A great example of this can be found over at Amazon, inspecting the DOM there should give you an idea of just how dynamic everything is. The following is a div Amazon use which contains a list of products:
<div…
File uploads are a hit and miss with Cypress. There are no built-in commands that handle file uploads and you typically need to get creative with jquery events or install a node package such as cypress-file-upload to try and get your files uploaded through the frontend. In this post, I’ll be demonstrating how I’ve tackled this and what I use to test endpoints with file uploads.
To send a file directly to the API, we need to process it a bit first, such as converting it into a Blob (Binary Large OBject); this can be accomplished through the usage of Cypress.blob. All you need to ensure is that you to pass the correct encoding type for that file before you convert it to a Blob. For example, binary string to blob or base 64 to blob, this depends on the data in the file and the file type that you want to upload. …
As we query the various endpoints as part of an API we are typically given a response. This response follows a specified schema set by the developers when they built the API and is traditionally returned as JSON. There are different schemas for different endpoints and even schemas based on the status of the API call. As QA, we could/should go the extra distance and verify that the schema returned is valid.
Cypress has a marvelous post that you can read through on schema validation using JSON Schemas here
Personally, I will be using AJV which is one of many schema validation tools available, it’s well maintained and it’s excellent documentation can be found here. …
About