Having trouble clicking a button with Selenium in JMeter

Currently, I am conducting stress tests in Jmeter using Selenium (with JavaScript). However, I am encountering an issue when trying to click the next button in the script:

Click on the image to view the code for the button

I have tried using by.xpath, by.id, and by.linkText, but none of these methods are working.

var idsin = WDS.browser.findElement(pkg.By.linkText('Consultar'))
idsin.click()

Is there a different approach that can be used to successfully click this button?

Answer №1

In one sentence, you are combining the terms "stress test", "Selenium", and "javascript" which are mutually exclusive.

It is important to note that using actual browsers for stress testing is not recommended by:

  1. Developers of Selenium:

    They advise against using Selenium and WebDriver for performance testing, as it is not optimized for such tasks and may not yield accurate results.

  2. Developers of WebDriver Sampler:

    The project's aim is not to replace JMeter's HTTP Samplers but to work alongside them to measure end user load time.

If you believe you can do better than them, consider using XPath locator with partial text, like this example:

var idsin = WDS.browser.findElement(pkg.By.xpath('//button[contains(text(),"Consultar")'))

Keep in mind that the JavaScript mentioned has been removed from JDK 15, so you may need to exert extra effort or revert to an older JVM in the near future.

However, the optimal solution would be switching to JMeter's HTTP Request samplers. If properly configured to simulate a real browser, there should be no difference in network activity and you'll save time, money, and resources.

Answer №2

Thank you for the information. I understand the context of needing to do it for a login and menu situation. Despite that, I will need to utilize an http Request after interacting with that particular button. However, when attempting to use the xpath provided, I encountered this response:

Response code:500
Response message:invalid selector: Unable to find element with the xpath expression //button[contains(text(),"Consultar") due to the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//button[contains(text(),"Consultar")' is not a valid XPath expression.

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

modifying the identification value in HTML and then reverting it

Although this may seem like messy code, I'm really in need of assistance with a problem that has stumped me. Currently, I am working on an E-shop project where I have modals for displaying products. Within these modals, there is a button that allows u ...

Is there an array containing unique DateTime strings?

I am dealing with an Array<object> containing n objects of a specific type. { name: 'random', startDate: '2017-11-10 09:00', endDate: '2017-11-23 11:00' } My goal is to filter this array before rendering the resu ...

Step by step guide on inserting a message (memo/sticky note) onto an HTML page

Wondering how to accomplish this: I've designed an HTML5 homepage and I'm looking to display a message to visitors, such as "Dear visitor, I am currently on vacation from....", in the form of a memo or sticky note positioned in the top right cor ...

Ensure form is validated using regula.validate() and display a customized error message

I needed to implement form validation with custom error messages as shown below: <input type="text" name="numberdigit" class="numberClass" placeholder="Number Digit" data-constraints='@Required(message = "Number Digit is required.")' />< ...

Selenium - Issue arises with script malfunction following Firefox's recent update

After updating Firefox to version 43.0.1, a script that previously worked fine has started failing. Interestingly, the same script works flawlessly in Google Chrome. The error message being displayed is: org.openqa.selenium.firefox.NotConnectedExcepti ...

Can a complete form be encapsulated within a single AngularJS directive?

While I have come across several instances of individuals utilizing a blend of HTML and directives to craft an AngularJS form (as seen here), my goal is to develop a self-contained widget. This widget would encompass all the necessary HTML for the form w ...

My element is not being animated by Elementbyclass

Without Using JQUERY The animation I'm trying to create isn't functioning properly. I attempted to utilize document.getElementsByClassName, but it's not working as expected. There are no errors, but the element is not animating correctly. ...

Is it possible to replace the prototype of an object with a different object?

When an entity is generated, its prototype is established as another entity. Is it possible to alter the prototype of a previously created entity to point to a different object? ...

Is the browser automatically closed after running a selenium script?

While writing a selenium script, I encountered an issue where my browser automatically closes when the code is running. How can I prevent this from happening? public static void main(String args[]) { System.setProperty("webdriver.chrome.driver", ...

What is the most efficient way to prevent duplicate items from being added to an array in a Vue 3 shopping cart

I currently have a functional shopping cart system, but I am facing an issue where it creates duplicates in the cart instead of incrementing the quantity. How can I modify it to only increment the item if it already exists in the cart? Also, I would like t ...

Ideas and Recommendations for Building a Laravel and Vue.js Hybrid Structure for MPA/SPA Applications

Consider the innovative approach I've been pondering - a combination of MPA and SPA, where each page functions as a Single Page Application, yet still reloads when navigating from one page to another (e.g. index.blade.php to posts.blade.php) like a tr ...

An Alternative Approach for Executing a Function within an AngularJS Directive

I am currently working on a unique element directive that displays a user's picture and name. This directive has various configuration attributes, one of which is the uc-on-hover attribute. The purpose of this attribute is to determine what element sh ...

Error encountered while trying to implement sleep function in script

Good evening. I've been attempting to implement the sleep function from the system-sleep library, but my script keeps crashing. This is the code snippet I'm working with: page.html <html lang="en"> <head> <meta charset= ...

Creating a Dynamic Input Validation Range with JQuery

Greetings and thank you for taking the time to review this! :-) The form validation is functioning correctly with required fields, but I am facing a challenge with setting up numeric range validation dynamically for an autocomplete feature. The JQuery val ...

Tips for displaying a child React component for a specific duration

One of the React components I have is called PopUpBanner, which is utilized to display messages. For instance, in my login component, I employ it in this manner. If an error arises, the bannerMessage state is updated to showcase the message on the banner: ...

Tips for retrieving data for client components on the server side

When referring to Client Components, I am talking about files that use use client at the top, while Server Components are files that utilize use server accordingly. I haven't come across any mention of fetching data on the server side and directly pa ...

Apply design to a dynamically generated JavaScript id using Stylus

Currently, I am utilizing a jquery datepicker widget, and my goal is to customize the CSS for its input field. However, it seems that the id assigned to that field is dynamically generated upon page load: <input type="text" id="dp1382434269539" style= ...

selenium.common.exceptions.InvalidArgumentException: Error message: The get() function in Selenium Webdriver with Python was called with an invalid argument

I'm currently developing a GUI that prompts users for a search term, navigates to eBay, and retrieves the average price for that item. However, I'm encountering difficulties with opening Selenium in my project. Despite researching extensively, I ...

What is the best way to fill a "multiselect" element with information from a JSON object?

I'm struggling to populate the multiselect field with data from a JSON object. No matter which multiselect I use, the data shows in inspect mode but not on the frontend. It was supposed to look like this. https://i.sstatic.net/FVz2H.png but it comes ...

Transmit information via ajax and receive responses in json format

Looking to send a string and receive JSON format in return. The current method is functional but lacks the ability to return JSON code. $.ajax({ url: "getFeed.php", type: "post", data: myString }); Attempts to retrieve JSON string result in ...