Encountering a Selenium error related to opening the shadowRoot in JavaScript

I'm currently in the process of setting up automated tests for a web application I've been developing, and I've encountered an issue that has left me puzzled.

Since it's a browser-based app, I decided to start off with a basic static server setup:

import http from 'http';

let serve = serveStatic(path);
server = http.createServer(function(req, res) {
    var done = finalhandler(req, res);
    serve(req, res, done);
});

However, during my testing phase, I kept encountering an error message stating HTTP method not allowed

let options = new firefox.Options();
options.headless();
let capabilities = webdriver.Capabilities.firefox().set('acceptInsecureCerts', true);
let driver = new webdriver.Builder()
    .forBrowser('firefox')
    .setFirefoxOptions(options)
    .withCapabilities(capabilities)
    .build();

await driver.get('http://127.0.0.1:3030/index.html');
let tab = await driver.findElement(state.By.css('ps-tabpanel'));
tab = await tab.getShadowRoot(); // HTTP method not allowed

Upon a gut feeling, I decided to switch to an HTTPS connection

import http from 'https';

Surprisingly enough, this change led to a completely different error popping up

await driver.get('https://127.0.0.1:3030/index.html');
// Reached error page: about:neterror?e=nssFailure2&u=https%3A//127.0.0.1%3A3030/index.html&c=UTF-8&d=%20

So, my primary question at this point would be: what am I doing incorrectly in attempting to access the shadowRoot using Javascript Selenium?

Just to provide some context, I am working with:

  • mocha + selenium + firefox
  • gitpod environment
  • Prior to this issue, I had managed to successfully run a test verifying connectivity to example.com.

Answer №1

To troubleshoot the issue, I decided to utilize the javascript executor as an alternative solution. However, this approach resulted in a new error message related to cyclical objects.

As a result, I sought guidance from another thread on Stack Overflow

According to the information provided in that response, it was identified as a known bug within GeckoDriver/Firefox.

In light of this discovery, I switched over to ChromeDriver/Chrome and successfully accessed the ShadowRoot element.

https://www.npmjs.com/package/chromedriver

let driver = new webdriver.Builder()
    .forBrowser('chrome')
    .build();
await driver.get('http://127.0.0.1:3030/index.html');
let tab = await driver.findElement(state.By.css('ps-tabpanel'));
tab = await tab.getShadowRoot();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering problem while initializing RemoteWebDriver in C# utilizing SpecFlow

I am struggling with implementing a RemoteWebDriver instance in my Selenium C# project. Every time I try to run my test, I encounter the error 'Object reference not set to an instance of an object' Here is how I started my hub... java -jar "C:& ...

How to display the name of the parent object using JavaScript's prototypal inheritance

I've been delving into JavaScript prototypal inheritance and the prototype property, and I decided to create a fiddle to gain a deeper understanding. However, I'm struggling to comprehend why my example isn't functioning as expected. In the ...

Error message stating that there is no property 'collection' in Firestore when using Firebase v9 modular syntax in Firebase Firestore

Working on a React application that makes use of Firebase Firestore for handling database operations, I recently upgraded to Firebase version 9 and adopted the modular syntax for importing Firebase services. Nevertheless, when attempting to utilize the co ...

Cities cannot be obscured by a rotating globe

In my latest project, I have created a jsfiddle showcasing a Bostock spinning globe implementation. After successfully plotting a few city markers, I encountered a problem where not all cities were being displayed. Additionally, the script intended to hid ...

Updating table width using AngularJS/jQuery after completion of ajax request

One of my challenges involves a table that defaults to a specific width, such as 80% of its parent div. Initially, the table remains hidden using 'ng-if' until an ajax call is completed in this manner: This is reflected in the HTML code snippet ...

The event "click .className" within the Marionette module is failing to trigger

I'm facing an issue with some code that I've written. Here's a snippet of what it looks like: myApp.module(args, function(args){ Views.MainView = Marionette.ItemView.extend({ //template, tagName, className down: false, events: ...

issues with jquery progress bar not updating value

How can I display two progress bars with the same value specified in the data attribute? Here is the HTML code: <div> <div class="p" data-value="54"></div> </div> <div> <div class="p" data-value="45"></div> < ...

There was an error in the <tspan> attribute dy: the expected length was not received, displaying as "NaN"

Encountering multiple errors while attempting to toggle the visibility of objects created in raphael. Specifically, I have a raphael-created house where clicking a button displays and animates a gauge; upon subsequent clicks, the house is shown and animate ...

The push() function is triggering an error where db._checkNotDeleted is referenced incorrectly as a

I'm attempting to save an object in the database. Here's the code snippet I've been using: app.post('/newOrderWithObject', (req, res) => { var msg = {"name":"Harry"}; push(ref(db,"test/orders&qu ...

The Fetch API's Post functionality is currently experiencing issues

fetch('http://localhost:9000/api/app/contact', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ email: this.state.email, contactNumber: ...

Error encountered: Selenium pageFactory NullPointerException related to driver issue

Dealing with a Selenium pageFactory issue where I'm encountering a NullPointerException. Any assistance would be highly appreciated. The setup works fine for the login in the setUp() method, but later on, the driver becomes null. public class TestBas ...

Steps for executing a function within a fs.stat callback

Utilizing npm papercut for image uploading has been a game-changer. With the following function, saving an image is flawless: uploader.process('image1', file.path, function(images){ console.log(images.avatar); // '/images/uploads/image1 ...

The Maven build is failing to run the csv file reader

I am encountering an issue where I cannot extract values from a CSV file within a Maven project. Oddly enough, it works flawlessly when implemented with TestNG. Could someone please assist me in identifying what else may be missing? Below is a snippet of ...

Is it necessary to install Chrome binaries on the Selenium grid in order to prevent receiving the error message "WebDriverError: unknown error: cannot locate Chrome binary"?

Recently, I have configured a new selenium grid on a Linux server using the following steps: The first command used was: 'java -jar ./selenium-server-standalone-3.141.59.jar -role hub' Then, the second command followed as: 'java -Dwebdrive ...

What is the best way to implement a custom NgbDateParserFormatter from angular-bootstrap in Angular 8?

Currently, I am working on customizing the appearance of dates in a form using Angular-Bootstrap's datepicker with NgbDateParserFormatter. The details can be found at here. My goal is to display the date in the format of year-month-day in the form fi ...

What is the best way to use CSS to ensure that dynamic, data-driven characters can be properly displayed within a div

I'm in the process of updating a data-centric website that relies on information from an automated database engine. In the HTML, there's a fixed-size button containing text pulled from the database. I'm looking to incorporate some CSS styles ...

Stay connected with AJAX's latest updates on Twitter with just 13 bytes

Twitter sends a POST request of only 13 bytes when someone follows an account. This small amount of information helps to reduce latency and server load, providing advantages for web developers. However, removing unnecessary cookies and extra information f ...

Error: The object of type 'WebElement' cannot be iterated

Why is the script able to click like on the first profile, but fails on the next one? import time from selenium.webdriver import Chrome from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options driver = Chrome( ...

No default export function available on this page

Recently delving into Nextjs, I'm currently in the process of setting up a MongoDB connection using middleware configuration. Let me showcase my code: import type { NextApiRequest, NextApiResponse } from 'next' import { connectMongoDB } fro ...

Using jQuery's .html function to insert images

I have a unique counter that counts in currencies, such as Yen and Euro. Each number, as well as the currency sign and separator, are all displayed on the webpage using custom-designed icons. I utilize the display: flex; property in my container div and ap ...