este es el sitio web q el profe utiliza en este curso
cy.visit('https://demoqa.com/links')
Introducción al curso
Presentación del curso
Instalación de recursos
Cookies y Localstorage
Cookies
Local Storage
Emulando dispositivos
Emulando dispositivos
Instalando plugins
Usando xpaths
Flaky tests
¿Qué son los Flaky Tests?
Interceptando Network Requests
Interceptando request
Buenas prácticas
Patrones de diseño: Page Object Model
Custom commands
Variables de entorno
Cypress.env
Visual testing
Visual testing
Seguridad
Seguridad en Cypress
Navegación entre pestañas del mismo sitio
Navegar entre diferentes dominios en diferentes tests
Navegar entre diferentes dominios en diferentes tests y compartir información entre ambas páginas
Data Driven Test
Cypress fixtures
BDD
Configuración de plugins y steps dinámicos
Shared Step Definitions
Data Driven Test por medio de Scenarios Outline
Reportes
Múltiples reportes
Allure report
Docker
Cypress con docker container
Dashboard
Usando dashboard de Cypress
Alternativas gratuitas al Dashboard de Cypress
CI/CD
Jenkins
Final
Cypress Scenario recorder plugin
You don't have access to this class
Keep learning! Join and start boosting your career
Often when performing automated testing with Cypress, we encounter the challenge of handling the behavior when a web application opens new links in different browser tabs. This usually happens when an HTML link has a target="_blank"
attribute, which typically opens the link in a new tab or window. Cypress, for security reasons, runs the tests within a single tab, which can complicate testing applications that rely on this behavior. However, there is a trick we can use to avoid this behavior by keeping everything within the Cypress context.
To handle this particular case, we can modify the link behavior before Cypress triggers it. The strategy is to use the invoke
method to remove the target
attribute from the links.
cy.get('selector').invoke('removeAttr', 'target').click();
With this code snippet, what we do is select the link and use the invoke
method to remove the target
attribute. Thus, we ensure that the link is opened in the same tab as the application we are testing, and we can continue to validate the functionality without leaving the Cypress context.
Before implementing the above solution, it is critical that our test environment is properly configured. This includes making sure you have Cypress installed and updated. Occasionally, if an installation error occurs, the error message provided is usually descriptive and guides us on how to resolve it.
In the event that running Cypress detects that some installation is missing, the error usually mentions the need to reinstall Cypress. Regularly, this is because the machine's cache has been cleared and some files needed for execution have been lost. Here's how to do it in general:
Once we have our configuration ready, we can proceed with the tests. By operating within the Cypress context and having controlled the opening of new tabs, we can perform additional validations such as verifying the presence of certain elements or validating the expected behavior when interacting with the application.
It is important to always remember to run only the tests relevant to the changes we make, to avoid confusion and ensure that the test is actually running as expected.
By applying this knowledge, users will benefit by getting more robust and secure tests within the environment that Cypress provides. These tips not only improve testing efficiency, but also provide an additional layer of security and control over how our scripts interact with the browser. Keep learning and optimizing your approach to automated testing!
Contributions 1
Questions 1
este es el sitio web q el profe utiliza en este curso
cy.visit('https://demoqa.com/links')
Want to see more contributions, questions and answers from the community?