skip to Main Content

I’m working in a few stress test in Jmeter, but using Selenium (With javascript), but I have problem pressing the next button in the script:

Press the image to see the code of the buttom

I have already used by.xpath, by.id, by.linkText but none of these work.

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

Is there another way to press this button?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks, i'm aware of all of that. But I have to do it for a situation with the login and menu. But after that button, and can use and http Request. However, the response to the xpath you give me is:

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

  2. You’re using 3 mutually exclusive terms in one sentence: "stress test", "Selenium" and "javascript"

    Be aware that using real browsers for stress testing is not recommended by:

    1. Selenium developers:

      Performance testing using Selenium and WebDriver is generally not advised. Not because it is incapable, but because it is not optimised for the job and you are unlikely to get good results.

    2. WebDriver Sampler developers:

      Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.

    If you think you’re smarter than they the only piece of advice I can provide is using XPath locator and partial text, something like:

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

    because there are starting and trailing whitespaces all around the element is not a "link", it’s a button

    Also be careful with this JavaScript, it has been removed from JDK 15 and you will either need to put an extra effort or downgrade to older JVM in nearest future.

    However the best option would be switching to JMeter’s HTTP Request samplers, given you properly configure JMeter to behave like a real browser there will be no difference from network footprint perspective and you will save a lot of time, money and trees.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search