Part 2: ServiceNow Selenium – Shadow DOMs

In our last post, we used execute_script() to navigate Shadow DOMs in ServiceNow, which required writing JavaScript to traverse into shadow roots. This method worked but was complex and hard to maintain. A Better Way: Directly Accessing Shadow DOMs with shadow_root Selenium’s Python shadow_root function now provides a simpler alternative. Here's how to approach this in a step-by-step guide. Step 1: Old Approach with JavaScript Let’s first recall the old approach. We needed to execute JavaScript to access the shadow DOM, as shown: This method allowed interaction but added complexity due to manually executing JavaScript to achieve the interactions we want. Step…

Continue ReadingPart 2: ServiceNow Selenium – Shadow DOMs

ServiceNow/Selenium – Shadow DOMs

Introduction If you're interested in a better solution to this problem, take a look at my follow up blog on this specific subject! There we utilize the shadow_root attribute as it was designed to be used to achieve the same goal. When you're developing software to last, building tests along the way is integral in maintaining a robust inflexible code-base. ServiceNow's ATF is an efficient, cost-effective way of doing regression testing in the ServiceNow platform, but it missed the mark on navigating Custom UI pages as well as third-party integration testing. That's where using Selenium come's in. Selenium is an automated testing…

Continue ReadingServiceNow/Selenium – Shadow DOMs