How to implement WaitForPagetoLoad in Web Driver Sampler

199 views
Skip to first unread message

Anisha Basnet

unread,
Jul 14, 2021, 3:13:32 AM7/14/21
to jmeter-plugins
I am trying to perform load testing in Jmeter through Web Driver Sampler. How can I implement WaitForPagetoLoad in Web Driver Sampler? I used Thread.sleep(); but it's not relaible.

DT

unread,
Jul 14, 2021, 11:45:09 AM7/14/21
to jmeter-plugins
I don't know what you mean by WaitForPagetoLoad, there are 2 types of "waits" in Selenium
  1. Implicit Wait:  like WDS.browser.manage().timeouts().implicitlyWait(10, java.util.concurrent.TimeUnit.SECONDS)
  2. Explicit Wait like:
var wait = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 10)
wait.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(org.openqa.selenium.By.id('some id')))

Take a look at ExpectedConditions documentation, most probably you will find a matching one, if not - it is possible to write your own custom condition (function or predicate). See The WebDriver Sampler: Your Top 10 Questions Answered article for more details. 

Anisha Basnet

unread,
Jul 16, 2021, 1:50:32 AM7/16/21
to jmeter-plugins
Well, I implemented like this and it worked: 

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.*;
import org.openqa.selenium.JavascriptExecutor;

var wait = new WebDriverWait(WDS.browser, 1000);
ExpectedCondition jQueryLoad = new ExpectedCondition() {
     public Boolean apply (WebDriver driver) {    
          return WDS.browser.executeScript("return jQuery.active", new Object[] {} ) == 0;
     } 
wait.until(jQueryLoad);

Nikita Raikar

unread,
Jun 10, 2024, 1:01:09 PMJun 10
to jmeter-plugins

Did any one get solution for above Query ..?
Reply all
Reply to author
Forward
0 new messages