Issue encountered while running Java scripts in Selenium with JMeter due to method invocation error

When attempting to run JavaScript in my Selenium code, I encountered the following error:

Error: Response message: javax.script.ScriptException: Sourced file: inline evaluation of:

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Typed variable declaration : Error in method invocation: Method executeScript( java.lang.String ) not found in class 'org.openqa.selenium.htmlunit.HtmlUnitDriver' : at Line: 47 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : executor .executeScript ( "document.getElementById('icon-2')[0].click()" ) in inline evaluation of: ``import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' at line number 47

Response headers:

Code:

public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME,true);
JavascriptExecutor executor = (JavascriptExecutor)driver;
driver.get(appURL);
executor.executeScript("document.getElementById('icon-2')[0].click()");

What is the correct way to run JavaScript within Selenium?

Page dom structure :

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

The element is implicitly defined as of 'any' type because a type of 'string' expression cannot be used to index an empty type

Having trouble with TypeScript here. It seems that I can't access accountProps using account in this map function export type AccountTypes = "TB1" | "GBB" | "MS1" | \"28D\" | "RS1"; type Acc ...

Initial Year Setting for MUI X datepicker

For a project I am working on with my client, they have requested that the datepicker in MUI X default to the year 2023. They would like the datepicker to automatically display the year 2023 with the option for them to change it if needed, as most of the d ...

What is the proper way to add an object to an array within an object in TypeScript?

import {Schedule} from './schedule.model'; export class ScheduleService{ private schedules:Schedule[]=[ new Schedule("5:00","reading"), new Schedule("6:00","writing"), new Schedule("7:00","cleaning") ]; getSchedule(){ ret ...

Can you explain the meaning of the StaleElementReferenceException in Selenium?

Every time I attempt to find an element, I encounter the StaleElementReference error. When I use a WebDriver instance and try to locate the element using driver.findElement(By.xpath(Element)), it throws the staleelementreference exception. My code is wri ...

What distinguishes res.send from app.post?

I'm just starting to learn about express and HTTP. I've heard that the express library has app.get, app.post, and res.send methods. From what I gather, app.get is used for GET requests and app.post is used for POST requests. How does res.send fit ...

Webpack in Vuejs does not have access to the keys defined in dev.env.js file

The framework utilized here is vuejs-webpack, with build and config files located here. No modifications have been made to these files. According to the information on Environment Variables, the keys specified in dev.env.js should be accessible during the ...

Is there a correct way to properly duplicate a JSON array in Redux?

As a newcomer to Redux, I found the concepts somewhat confusing at first. For instance, imagine that there is an array in the redux state. const state = [ {show: false, id : '1'}, {show: false, id : '2'}, {show: false, id : &apo ...

Instructions for deactivating a drop-down list using radio buttons in JavaScript

I am working on a project where I have 3 radio buttons and 3 different combo boxes in my HTML. I want to use JavaScript to enable/disable the combo boxes based on which radio button is selected. For example, when the G1 radio button is clicked, I want on ...

Click a button to load a different view in CodeIgniter

How can I show another view of Controller using Ajax/Javascript when clicking a button? I attempted something, but it's not working as expected. Javascript: <script> $(document).ready(function(){ $("#details").click(function(){ $( ...

What is the mechanism by which AngularJS manages all of my module dependencies with jest?

Updated: Since this is an older project, I didn't use any module loader. Instead, I imported all dependencies in my index.html using the script tag. The structure of my AngularJS looks like this: app.js angular.module('app', ['Loca ...

Execute the calculation on the user's AWS account

In my Node.js and Vue.js project, the goal is for a user to input their AWS credentials, provide a link to an online data source containing a large amount of data, and run an algorithm on this data using their provided AWS account. I am facing two challen ...

Leverage the power of JavaScript strings within PHP

In my JavaScript code, I have a string variable. <script type="text/javascript"> Var string='String to use'; </script> Now I need to retrieve the text from the string variable in PHP. What is the best way to access or utilize it? ...

What is the method to retrieve the current window's URL in C# using Selenium WebDriver?

After signing into my application, it automatically redirects to a new page. I am currently using WebDriver in selenium C# and need to retrieve the URL of this new page. I have tried methods such as driver.Url, driver.getLocation(), and driver.getCurrent ...

In Bootstrap 5, clicking inside a dropdown should not cause it to open or close unexpectedly

Check out the code snippet below: <html> <head> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d1f1212090e090f1c0d3d48534e534e">[email protected]</a>/d ...

Tips for boosting the efficiency of nested ng-repeat in AngularJS

I'm currently working on incorporating infinite scrolling into my AngularJs project. I've been using nested ng-repeat and binding data through a JAVA API. The data returned by the service is quite large, which is causing a significant drop in per ...

Attempted to remove Child Div using Jquery, but it did not get removed as expected

Trying to remove child divs inside a parent div? There are several methods, such as: $(".ChildDiv").html(""); $('.ChildDiv > div').remove(); $(".ChildDiv").html(""); $("#ParentDiv").html(""); $(".ChildDiv div").remove(); $(".ChildDiv di ...

Is there a similar feature to Wait.Until in Atata?

When I encounter certain scenarios in my work, I often find myself needing to wait for expected conditions such as the presence of a value, the value having specific text or state, or until more complex rules are met. An example code snippet for this is: ...

Effortlessly handle form submission with jQuery AJAX, automatically redirecting upon successful

I am working on a project using ASP.Net MVC where I have a view that submits form data to a controller action. In order to make this form submission more dynamic, I am trying to utilize jQuery to post the form via an AJAX call with the following code: $(" ...

Including input within a component causes the input to capture all click events

I've been working on a project where I need to create a color picker component. When you click on the .swatch element, a popover opens up with a .cover div that covers the whole screen. Clicking on the cover closes the popover, following standard beha ...

Guide on inputting text into the Facebook Ad Library Search Box with Selenium using Python

I am currently in the process of setting up a basic web page automation script using Selenium. I encountered an issue after resolving a previous xpath error, now receiving an error about needing a form to use my submit button. The specific function causin ...