Home > OS >  Jmeter webdriver wait funtion - Can not create new object with constructor org.openqa.selenium.suppo
Jmeter webdriver wait funtion - Can not create new object with constructor org.openqa.selenium.suppo

Time:11-09

I am trying to use the JMeter Selenium Webdriver wait function but getting error output as -javax.script.ScriptException: TypeError: Can not create new object with constructor org.openqa.selenium.support.ui.WebDriverWait with the passed arguments; they do not match any of its method signatures. in at line number 2

var ui = JavaImporter(org.openqa.selenium.support.ui) var wait = new ui.WebDriverWait(WDS.browser,120)

Code in the webdriver sampler:

var ui = JavaImporter(org.openqa.selenium.support.ui)
var wait = new ui.WebDriverWait(WDS.browser,120)
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
WDS.sampleResult.sampleEnd()

I am using the latest version of Jmeter (5.5) and the latest selenium webdriver support package (4.5.1). This use to work before. Can someone help here please? thanks!!

I have tried upgrading and degrading the Jmeter, but no luck.

CodePudding user response:

WebDriver Sampler 4.5.1 comes bundled with selenium-support 4.5.0 and WebDriverWait constructor for this version expects 2nd argument to be Duration object

So you need to do something like:

var wait = new ui.WebDriverWait(WDS.browser, java.time.Duration.ofSeconds(120))

Also be informed that since JMeter 3.1 it's recommended to use Groovy language for scripting mainly for performance reasons so you might want consider switching, it would be way easier to debug your test.

  • Related