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