Articles

Automatiser le Shadow DOM avec Selenium WebDriver

Selenium WebDriver offre une solution pour automatiser le Shadow DOM et simplifier le développement des applications web. Essayez-le dès aujourd’hui !

## J’ai rencontré un des cas de test dans mes projets précédents où je devais cliquer sur un bouton pour naviguer vers la page suivante. J’ai recherché le localisateur d’élément du bouton sur la page et j’ai exécuté les tests en espérant qu’il cliquerait sur le bouton et naviguerait vers la page suivante.

## Mais à ma grande surprise, le test a échoué car il n’a pas pu localiser l’élément et j’ai reçu NoSuchElementException dans les journaux de console. Je n’étais pas content de voir cette erreur car c’était un simple bouton que j’essayais de cliquer et il n’y avait pas de complexité.

I started to debug the issue and found out that the element was present in the DOM but was hidden from the view. I realized that the developers had used a coding technique to hide the button from the view, and that was why the test was failing.

J’ai rencontré un des cas de test dans mon projet précédent où je devais cliquer sur un bouton pour naviguer vers la page suivante. J’ai cherché le localisateur d’élément du bouton sur la page et j’ai exécuté les tests en espérant qu’il cliquerait sur le bouton et naviguerait vers la page suivante.

Mais à ma grande surprise, le test a échoué car il n’a pas pu localiser l’élément et j’ai reçu NoSuchElementException dans les journaux de la console. Je n’étais pas content de voir cette erreur car c’était un simple bouton que j’essayais de cliquer et il n’y avait pas de complexité.

J’ai commencé à déboguer le problème et j’ai découvert que l’élément était présent dans le DOM mais était caché de la vue. J’ai réalisé que les développeurs avaient utilisé une technique de codage pour cacher le bouton de la vue, et c’est pourquoi le test échouait.

Source de l’article sur DZONE

A shadow DOM element is one that has been programmatically added to an element with the use of JavaScript and whose content does not show up in the browser’s DOM. Automating Selenium tests on your website can save you time and money by ensuring the changes you make are not breaking anything or negatively impacting your user experience. There are multiple ways to do this, but in this guide, we will be going over how to automate shadow DOM elements using Selenium WebDriver.

Locate the Host Element

The first step is to locate the host element. The host element is the element that contains the shadow tree. It can be any type of element, such as a div, section, or span. Once you have found the host element, you need to use the findElement command to find the shadow root. In order to perform an action on the shadow root, we need to use the executeScript command. To perform an action on one specific node in the tree (e.g., all button nodes), we must find and identify it within our script (e.g., button).

Source de l’article sur DZONE

Alert windows are widely used across websites where an alert message acts as a mode to ‘interrupt’ the current flow of the user journey. A simple example of a JavaScript alert would be someone filling in details on the sign-up page and submitting the details without entering some mandatory information. This user flow also needs to be verified when Selenium automation testing is performed on the web product. 

Handling pop-ups and alerts are one of the common test scenarios that should be tested using Selenium WebDriver. In this post of the Selenium Python tutorial series, we look at how to handle JavaScript alerts in Python. It is worth mentioning that the core fundamentals of JavaScript alerts and popups remain unchanged irrespective of the programming language used for Selenium.

Source de l’article sur DZONE

What thoughts come to mind when you come across 404/Page Not Found/Dead Hyperlinks on a website? Aargh! You would find it annoying when you come across broken hyperlinks, which is the sole reason why you should continuously focus on removing the existence of broken links in your web product (or website). Instead of a manual inspection, you can leverage automation for broken link testing using Selenium WebDriver.

When a particular link is broken and a visitor lands on the page, it affects that page’s functionality and results in a poor user experience. Dead links could hurt your product’s credibility, as it ‘might’ give an impression to your visitors that there is a minimal focus on the experience.

Source de l’article sur DZONE

This article explains creating or setting up a cypress.io end-to-end testing framework from scratch using Typescript. Unlike another tutorial, this explains setting up the Cypress framework using Typescript in a simple and easy way. This article is helpful for whoever wants to set up the Cypress Typescript automation framework for the first time. Also, I know that there are many, migrating from different automation frameworks like Protractor, webdriver.io, etc. this will be helpful for them too.

This Tutorial shows page object model creation as well, however you can use it for any type of framework by skipping those steps.

Source de l’article sur DZONE


WebDriverIO: Next-generation Automation Framework

WebDriverIO is an open-source next-generation automation framework, that allows us to automate modern web and mobile applications. It has an extended set of built-in and community plugins that help in designing robust, scalable tests and easily integrate with third-party applications including cloud services (BrowserStack, Applitools, Sauce Labs), Docker, Jenkins, Bamboo, GitHub, and many more.

It helps in designing automation tests for web applications and native mobile applications in just a few lines of code, making it very popular among developers and testers. It runs on WebDriver protocol to support cross-browser testing, and Chrome DevTools protocol to support Chromium-based automation. 

Source de l’article sur DZONE

Assertions are an important part of any test automation framework, and Serenity gives us many options. You can, of course, use standard JUnit, Hamcrest or AssertJ assertions at any point in a Screenplay test. But more recent versions of Serenity Screenplay provide an alternative approach, which many developers find easier to use and faster to write: the serenity-ensure module.

Introducing serenity-ensure

The Ensure class produces a Performable, so you can integrate them directly into the attemptsTo() method. It also has a very readable DSL and lets you use code completion to discover the assertions you can use for different values, making writing assertions easier and quicker.

Source de l’article sur DZONE

In the days before web applications, programmers wrote applications for a specific platform and used that platform’s native development environment and user interface controls. Before the application’s final release, a tester would check that the application was ready. Some testers wrote elaborate documents that described complicated scenarios they performed on the software manually. Other, more adventurous, testers used fancy tools that were the quality assurance version of Microsoft’s Word and Excel macro recorders. A tester would record a series of actions on the software under test. These steps were recorded in a high-level language in which the tester could edit the code and add test conditions that would verify that the actual results of the test matched the expected results. Each time a test was run, a report was generated that showed which conditions had been passed or failed.

With web applications, the time it takes to write and deploy code has been reduced to seconds. In this environment, much of the responsibility for testing is now in the hands of developers, who have since created many code-based test automation platforms.

Source de l’article sur DZONE