Selenium's HTML unit driver does not click the button

I am facing an issue where I am unable to click on an element with the onclick tag using HtmlUnitDriver.

Page source:

I have tried different methods to resolve this problem.

  1. Using the click method;

    public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true); driver.get(appURL); WebElement dripBoxbutton = driver.findElement(By.xpath("//img[@class='idp-image']/..")); dripBoxbutton.click();

  2. Using the submit method;

    public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true);
    driver.get(appURL);
    WebElement dripBoxbutton = driver.findElement(By.xpath("//img[@class='idp-image']/.."));
    dripBoxbutton.submit();
    

    However, I encountered an error when using the submit button:

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

    import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Method Invocation dripBoxbutton.submit : at Line: 48 : in file: inline evaluation of:
    import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : dripBoxbutton .submit ( )

    Target exception: java.lang.StackOverflowError in inline evaluation of: ``import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' at line number 48

    Response headers:

    1. Trying key release

      import org.openqa.selenium.Keys; public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true); driver.get(appURL); WebElement dripBoxbutton = driver.findElement(By.xpath("//img[@class='idp-image']/..")); dripBoxbutton.sendKeys(Keys.ENTER);

Encountered errors while using key release:

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

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Error in method invocation: Method sendKeys( org.openqa.selenium.Keys ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitWebElement' : at Line: 49 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : dripBoxbutton .sendKeys ( Keys .ENTER ) in inline evaluation of: ``import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' at line number 49

Response headers:
  1. Attempting action method;

     import org.openqa.selenium.interactions.Actions;
        public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME, true);
        driver.get(appURL);
        WebElement webElement = driver.findElement(By.xpath("//img[@class='idp-image']/.."));
                Actions builder = new Actions(driver);
                builder.moveToElement(webElement).click(webElement);
    

    builder.perform();

Still searching for a way to successfully click the button using HtmlUnitDriver.

Answer №1

If you're encountering an error message that points to a syntax issue, one way to obtain a more detailed stack trace is by enclosing your code within a try block, as shown below:

try {
    // Insert your code here
}
catch (Throwable ex) {
    log.error("Encountered a problem in the script", ex);
}

This method allows you to pinpoint the root cause of the problem in the jmeter.log file.

In this scenario, it is possible that the error arises from using a function that Beanshell does not support. Consider switching to Groovy, which may resolve the issue automatically:

https://i.sstatic.net/YMML7.png

Furthermore, based on JMeter Best Practices, it is recommended to utilize Groovy for any scripting tasks in JMeter due to its superior performance compared to other scripting options.

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

Is there a way to sum up the values in my object without having to use Object.entries within?

Here is a snippet from my JSON data: const jsonData = { "08/23/2022": { "One": 254, "Two": 92, "Three": 8 }, "08/13/2022": { "One": 327, "Two": 86, }, " ...

Limit the API call to only respond to requests from the localhost

I'm currently working on a website that uses API calls within the same node project. I would like to restrict most of these API calls to only be accessible by the localhost website. Is there a way to achieve this without implementing OAuth and simply ...

What is a way to utilize Javascript in order to copy a JSON object by referencing a specific key within the object?

If you had the following JSON object example given, how could you utilize Javascript to replicate each object based on the value indicated in the "Count" key? Example Input: [ { "name":"David", "Count":2 }, { "name":"John", "Count":3 }, ] Desired Out ...

Having trouble activating the onclick event on a radio button

In my testing framework, I have implemented a keyword-based approach using Selenium 3.x and Java. One of the web elements I am working with is: <input id="radiobutton" name="webserviceBarFlg" onclick="setReadOnly(this)" class="foo-input-radio-margin fo ...

Issue with AngularJS filter not functioning properly

I have a specific situation where I am using an ng-repeat directive in the following manner: {"ng-repeat" => "city in cities() | filter: search"} In this context, each city object is structured like so: { attributes: {name: 'Boston'} } Furt ...

Instruction on inserting NativeBase footer into my React Native application?

As someone new to React Native, I am trying to include a footer bar in my app. Below is the code snippet from my dashboard.js file where I attempted to add the footer bar, but it doesn't seem to be working as expected: import React, { memo } from &ap ...

How can I use jQuery to merge the values of two <h> tags?

There are two <h4> tags, one with a price and the other with a percentage value. I need to calculate the percentage and display it in a new <h4> tag. My previous attempts at calculation resulted in NaN. Even using alert(parseFloat(price)+parseF ...

The error "Not a key modifier" is displayed when trying to use the Capybara click method with

I’m attempting to utilize the Capybara Node::Element click function with an offset as specified in the Rdoc. Essentially, I aim to perform the click action on an element but not directly at the center of the element. Instead, I want it to be offset towa ...

What is the best way to use jQuery to listen for a container resizing event?

I am confident that I can achieve this: $(window).resize(function() {funkyfunc();}); The above code will execute funkyfunc() whenever the window is resized. However, my issue lies in wanting to resize one control after another has been resized. I've ...

What is the method to retrieve the label linked to a checkbox in Selenium automation tool?

Is there a way to display the label associated with a checkbox, such as 'checkbox 1' or 'checkbox 2', in the example provided below? Checkbox Items: <input type="checkbox" value="cb1" name="checkboxes[]">Checkbox 1 & ...

The PDF document appears quite different from the original HTML page it was created from

Is there a way to create a PDF document that mirrors the appearance of a web page using jsPdf? When attempting this, it seems that the font size, text alignment, and table alignment of the resulting PDF do not match that of the original web page. Additiona ...

Import failures in Three.js could be attributed to potential issues with Webpack

Please note: I am utilizing create-react-app along with three.js v0.99.0. In my current project, I am faced with the challenge of importing specific modules from three.js to avoid bundling the entire library, which results in a large uncompressed file siz ...

How to Disable PDF Viewer in Chrome when Downloading PDFs with Python and Selenium

What I am currently observingWhen attempting to download a PDF by clicking on the button designated for that purpose, Chrome automatically opens the PDF Viewer. To prevent this behavior, I have implemented code that stops the viewer from displaying the PDF ...

Creating a JSFiddle with sprites using source and image files from Github with THREE.JS - a step-by-step guide

Greetings! I am currently working on creating a JSFiddle based on the official THREE.js HUD Sprites example. However, I am facing an issue where the sprite images do not seem to load or apply using the URLs specified in the original file:- //... URL' ...

What is the process for building a series of HTML elements using jQuery?

Is it possible to create a moving conveyor belt of html elements (such as divs) using jQuery, and if so, how can this be done? For example: (as shown above, rectangles move from left to right; new ones are added and the last one is removed) And then: [ ...

Using withRouter() to redirect will display all components

I'm brand new to Reactjs and am currently diving into routing. In my journey, I stumbled upon the use of withRouter() for programmatic redirection. I had assumed the flow would follow: constructor->Willmount->render, but it seems the current or ...

How can I incorporate a feature in my Angular application that allows users to switch between different view types, such as days, using JavaScript

Greetings, community! I am currently utilizing version 5 of the fullcalendar library from https://fullcalendar.io/ in my Angular 9 application. I have noticed that the calendar offers various options to change the view type as shown below: https://i.stac ...

ng-repeat failing to display the final two divs

I'm having trouble with the following code. The second to last div inside the ng-repeat is not being rendered at all, and the last div is getting thrown out of the ng-repeat. I can't figure out what's wrong with this code. Can anyone spot th ...

Retrieve the route from a specific node in the jstree structure

Looking to retrieve the paths of selected nodes in jstree? You'll need the complete path of the nodes. I have a php file that generates the JSON, structured like this: header("Content-Type: application/json; charset=utf8"); echo json_encode(dir_to_ ...

Using the spread operator in ES6 allows for arguments to be placed in a non-con

When working in nodeJS, my code looks like this: path = 'public/MIN-1234'; path = path.split('/'); return path.join( process.cwd(), ...path); I was expecting to get: c:\CODE\public/MIN-1234 but instead, I got: `‌publ ...