The Java Selenium script encountered an illegal type error when trying to execute JavaScript through JavaScriptExecutor: driverFactory.CustomWebElement

I have a CustomWebDriver class that extends the functionality of JavascriptExecutor. Here is my implementation:

@Override
public Object executeScript(String script, Object... args) {
    return ((JavascriptExecutor) driver).executeScript(script, args);
}

However, when I try to use this code snippet below, I encounter an error:

Argument is of an illegal type: driverFactory.CustomWebElement

    WebElement testElmtBy = returnSearchLists().get(i);
    WebDriver vDriver = driver.get();
   ((JavascriptExecutor)vDriver).executeScript("arguments[0].scrollIntoView(true);", testElmtBy);

The method returnSearchLists().get(i) returns an object of type CustomWebElement, which contains a public element iElement.

Even though I declared testElmtBy as a WebElement, it is still being recognized as a CustomWebElement.

Am I missing something in my code?

Answer №1

Here is the solution I discovered to resolve the issue:

I made sure that CustomWebElement implemented the interface WrapsElement and added an override as shown below:

public WebElement innerElement;    
@Override
public WebElement getWrappedElement() {
    return innerElement;
}

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

Easy Steps for Mapping Json Data into an Array

Here is the JSON Format I am working with: { "Data": { "-template": "Parallax", "Explore": { "IslandLife": { "TourismLocation": [ { "Title": "Langkawi", "Latitude": "6.350000", "Longitude": "99.800000", "YouTub ...

The comparison between Spring AMQP's return callback and retry callback

To ensure my app can handle connection issues when sending messages to RabbitMQ, I am looking for a way to store and resend unsent messages when the connection is restored. After reviewing the information in the official documentation, I am still unsure a ...

Tips for utilizing useQuery in React JS class component:

Currently, I'm working on an app that is exclusively built using React JS class components. Since UseQuery only functions with function components and the Query tag has been deprecated, I'm facing some challenges in getting the data I need. Any s ...

Revised Post | Guide to executing TestNG tests from the main method: I've created the main class - what should be my next step?

I am currently trying to execute my XML file using a 'Main' class, following a template I discovered. How should I proceed from this point onwards? Do I have to utilize: 'Export' -> '.Jar' And then initiate the main cl ...

SheetJS is experiencing difficulties parsing dates correctly

Need help exporting an HTML table to an Excel file using the SheetJS library. Here's my code snippet: var table = document.getElementById("tableToExport"); var ws = XLSX.utils.table_to_sheet(table, { sheet: "Raport Odorizare", da ...

How to selectively filter an array of objects using another array in JavaScript

Imagine you have an array filled with objects: people = [ {id: "1", name: "abc", gender: "m", age:"15" }, {id: "2", name: "a", gender: "m", age:"25" }, {id: "3 ...

The pause option in urql's useQuery function offers a temporary halt to the request and does not freeze it completely

I'm attempting to ensure that the urql useQuery function is only executed once in my code. Unfortunately, it seems to be getting called on every re-render. According to the documentation at , this query should start off paused when rendered and shoul ...

Setting the y-axis range in d3.js and nvd3.js: A complete guide

I'm attempting to define the y-axis range of the chart to be between 1 and 100. After reviewing the API documentation, I came across a potential solution involving axis.tickValues which can be found here: https://github.com/mbostock/d3/wiki/SVG-Axes# ...

Integrate fullCalendar event creation with Spring MVC using an AJAX request

I am looking to integrate a new event into fullCalendar and send this event as a JSON object to the server side, which is running on SpringMVC, through an AJAX request. However, every time I make the request, I receive a "400 Bad Request" response. Here i ...

Building VSCode on Windows: A step-by-step guide

I am currently in the process of compiling https://github.com/Microsoft/vscode from the source code, but I am facing some challenges. After successfully running scripts\npm.bat install, I proceeded to run scripts\code.bat and a strange window app ...

What could be the reason for the malfunctioning of this JavaScript code?

Regarding the content found in this post: How to display a loading image while the actual image is downloading. I have implemented the following code snippet, however, I am facing an issue where the #loader_img element does not hide. Additionally, I would ...

What are the steps for displaying multiple input fields using the onchange method?

$(document).on("change","#noofpack",function(){ count = $(this).val(); for(i=1;i<=count;i++){ $("#packageDiv").html('<input type="text" class="form-control" name="unit_price[]" placeholder="Unit Price" required="">'); ...

Using Vue Formulate to effortlessly upload multiple images

One of my projects involves using a Vue Formulate component for uploading multiple images to an Express.js backend. Here is the code snippet for the Vue Formulate component: <FormulateInput type="image" name="property_ ...

Ways to retrieve a grandchild element of a specific element using its tag name

I'm struggling to access elements that are nested within various levels of parent elements with and without IDs. The usual method getElementByTagName doesn't seem to be working for me, especially when the target element is three levels deep. Is t ...

Adding a CSS class to a Vue component with a custom prop

I am looking to create a custom component in Vue that has the following props: text = the text to display in the link. icon = the identifier of the icon to display next to the link. < sidebar-link text="Home" icon="fa-home"> Below is the .Vue ...

Exploring the integration of Django Rest Framework with Angular

I am just starting out with Django Rest Framework (DRF) and AngularJs. I am trying to figure out the best way to integrate these two technologies. Combining DRF and AngularJs in one project (Most of the tutorials recommend this) Using DRF as the backend ...

Press the delete button located on the child component to trigger an action in the

I'm in the process of developing a simple to-do application from scratch in order to familiarize myself with ReactJS. One challenge I'm facing is implementing the delete functionality for todos, as I want to keep the button within the Todo compon ...

Unable to figure out why information is not being transferred to an array through Mongoose

Seeking assistance as I am unable to figure out how to place a set of information into an array named "teamDetails". Here is the relevant /post item from server.js: app.post('/create', (req, res) => { console.log('Post command receiv ...

How many files are being monitored by Grunt?

Recently, I received a new project using Angular + Node from a client and successfully set it up on my local machine. However, one major issue arose when running the grunt command - my CPU spiked to 100% causing my system to hang. Strangely, the same proje ...

The time selector does not appear in the v-date-picker widget

I need help figuring out how to select a time range using v-date-picker on vCalender within my Vuetify project. Despite setting the mode of v-date-picker to dateTime, I am unable to find an option to choose the time along with the date. Is there something ...