0

I have 10 threads on Jmeter all going into the same website but each thread has different accounts. I keep getting the Stale Element Reference Exception error on 1-3 threads per each test. The weird thing is that the threads that fail are different each time I run a test, and they all have the exact same path/code (besides the login credentials). What can I do to fix it?

When the a thread fails, it says "This site can't be reached" "examplewebsite.com took too long to respond" in the UI

enter image description here

Aerrop
  • 1
  • See https://stackoverflow.com/questions/12967541/how-to-avoid-staleelementreferenceexception-in-selenium and some of the answers such as https://stackoverflow.com/a/12967602/7058266 – Michael Mintz Jan 13 '22 at 19:27

1 Answers1

0

Looking at Stale element reference page:

The stale element reference error is a WebDriver error that occurs because the referenced web element is no longer attached to the DOM.

So it means that you're trying to interact with the element which no longer exists.

Given This site can't be reached error it might be the case your application is overloaded or has another problem preventing proper displaying/rendering controls

You could try taking a screenshot in case of failure and/or printing the page source to jmeter.log file, this way you will have more information regarding what's going on when the page cannot be opened or element cannot be found/interacted with.

Example code:

try
{
   WDS.browser.get('examplewebsite.com')
   wait.until(conditions.presenceOfElementLocated(pkg.By.linkText('some-link')))
}
catch (err)
{
   WDS.log.error(err.message)
   var screenshot = WDS.browser.getScreenshotAs(pkg.OutputType.FILE)
   screenshot.renameTo(new java.io.File('screenshot.png'))
   WDS.log.info('Page source:')
   WDS.log.info(WDS.browser.getPageSource())
   exception = err
}
finally
{
   throw (exception)
}

More information: The WebDriver Sampler: Your Top 10 Questions Answered

Dmitri T
  • 159,985
  • 5
  • 83
  • 133