I am trying to use groovy script to launch my client using webdriver sampler and it doesn't work as expected.only JavaScript is working with the following code
var pkg = JavaImporter(org.openqa.selenium); //WebDriver classes
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait); //WebDriver classes
var wait = new support_ui.WebDriverWait(WDS.browser, 5000);
WDS.sampleResult.sampleStart(); //captures sampler's start time
WDS.sampleResult.getLatency();
WDS.log.info("Sample started");
WDS.browser.get('https://google.com/');
import
keyword instead var
keyword in Groovy/Java (unless you're using Java 10), you need to change it to def
keywordAssuming all above you need to amend your code to look like:
import org.openqa.selenium.support.ui.WebDriverWait
def wait = new WebDriverWait(WDS.browser,5000);
WDS.sampleResult.sampleStart(); //captures sampler's start time
WDS.sampleResult.getLatency();
WDS.log.info("Sample started");
WDS.browser.get('https://google.com/');
Demo:
Check out Apache Groovy - Why and How You Should Use It article to get started with Groovy scripting in JMeter