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

The majority of web products use AJAX (Asynchronous JavaScript and XML), where elements on the page are loaded at varying time intervals. This can lead to timing issues when automation testing is performed using the Selenium framework. What if a test is run on a WebElement that is not present in the DOM? The findElement function will raise ElementNotVisibleException.

Here are other scenarios that can cause issues in Selenium due to the dynamic loading of elements:

Source de l’article sur DZONE

By automating the entire test procedure, your company will not only save money and time but also deliver superior quality products. Selenium has reined top as the go-to tests framework for almost any sort of test requirement that includes a browser-based application. However, as the world of automation testing continues to step forward, the newest tools have emerged. Chief amongst them is Cypress.io, an automated test framework that is becoming a more and more popular alternative to Selenium. Is Cypress or Selenium a perfect choice for your automation test requirements? Keep reading this blog and understand some tips on why you might willing to choose one or the other – or even use both at a similar time.

Here are a few commonly asked queries that might come up when doing a Selenium vs Cypress comparison:

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

Selenium has gone through a tremendous evolution since its introduction and that’s the reason today it is the most popular and powerful automation testing tool. The newly released Selenium 4 is creating a lot of buzz and the complete testing community is looking forward to exploring its updated features. 

Before we dive into Selenium 4, let’s have a brief introduction to its previous versions. Selenium 1 was declared as the free open source automation testing framework in the year 2004 consisting of selenium IDE, RC, and web driver. Whereas, the Selenium 2 released in 2011 consisted of the IDE, Web driver, and Grid. The RC server was merged with the web driver, as the web driver facilitated easy automation scripting for the browsers. Selenium 3 was officially released in 2016. One of the most noticeable changes in selenium 3 was the replacement of the selenium core with the web driver-backed option, the introduction of the gecko driver, and W3C web driver integration.

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

Do you know the test automation market is all set to hit $35 billion by 2026? And when it comes to cross browser testing, JavaScript leads from the front? Javascript is probably the best alternative for Selenium automation, considering its protocol transformation to the W3C standard. In order to make the most of it, the first step is to choose the best test automation frameworks. Among all the JavaScript testing frameworks, two frameworks are most popular- Nightwatch and Protractor.

This article will be comparing Nightwatch vs Protractor and help you choose the perfect JavaScript testing frameworks. Let us start by diving deeper into each framework.

Source de l’article sur DZONE

We all know that Google Chrome is the most popular browser in the world. But do you know, with 17.24% of the overall browser market share, Safari is the second most popular one?

The reason behind Safari’s strong presence is that it is the default web browser for all Apple devices. And we know how much developers and coders love macOS, making it absolutely necessary to ensure that our websites’ are tested and optimized for all Safari versions.

Source de l’article sur DZONE

Selenium is one of the most prominent automation frameworks for functional testing and web app testing. Automation testers who use Selenium can run tests across different browser and platform combinations by leveraging an online Selenium Grid. Though Selenium is the go-to framework for test automation, Cypress — a relatively late entrant in the test automation game — has been catching up at a breakneck pace.

Like Selenium, Cypress is also an open-source test automation framework for testing web applications. And that’s where the big Cypress vs Selenium fight begins! Here are some of the most commonly asked questions that might come up when doing a Cypress vs. Selenium comparison:

Source de l’article sur DZONE