Jmeter webdriver implicit wait implementation

683 Views Asked by At

im writing a Java code on Jmeter (webdriver) in order to perform a load test, i need to implement implicit wait, something like :

WDS.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

But seems Jmeter is not understanding it, also i tried to use:

def wait = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 5); wait.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(org.openqa.selenium.By.xpath("//a[contains(text(),'More information')]")))

with no use.

The only thing worked with me is :

Thread.sleep(2000);

but it will not work with me when i will run the test with high load.

test plan and CSV files can be found in below URL: https://drive.google.com/file/d/1k5ZjhSEXiFPObwysNYKcwRZN0xxOkAHl/view?usp=sharing

Please have a look on the code and tell me what can i do :(

noting that script language is JAVA there is no option for JavaScript on Jmeter.

1

There are 1 best solutions below

4
On BEST ANSWER

There is no JAVA in JMeter's WebDriver Sampler, it's Beanshell interpreter and in order to be able to use Explicit Wait with the above code snippet you will need to switch the language to groovy (moreover it's recommended scripting option since JMeter 3.1)

You won't have to change a single line or even character, valid Java code in majority of cases is valid Groovy code.

Given you switch to Groovy the piece of code implementing the explicit wait which you copied and pasted from somewhere will start working.

Also don't mix implicit and explicit waits:

Warning: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example, setting an implicit wait of 10 seconds and an explicit wait of 15 seconds could cause a timeout to occur after 20 seconds.