I have to build JMeter script using JSR223 Sample for chrome, I was wondering if there is a way that I can configure path in the script so that I don't need to host drivers in Jenkins. In Selenium Automation, I used webdriverManger to download new driver every time https://www.toolsqa.com/selenium-webdriver/webdrivermanager/
JSR223 Sampler:
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.support.ui.WebDriverWait;
**System.setProperty("webdriver.gecko.driver","/Users/geckodriver");**
FirefoxOptions options = new FirefoxOptions().setAcceptInsecureCerts(true);
WebDriver driver = new FirefoxDriver(options);
def wait = new WebDriverWait(driver, 20);
driver.get('https://google.com/');
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//input[@name='q']")));
You can do the same in JMeter:
Download WebDriverManager "fat" jar from the releases page and drop it to "lib" folder of your JMeter installation or at any other place in JMeter Classpath
Restart JMeter to pick the .jar up
Replace your
with
Enjoy
More information and another trick you can play: How to Reuse Your JMeter Code with JAR Files and Save Time