JMeter WebDriver Sampler doesn't work and doesnt have headless

466 views Asked by At

I am using jp@gc - Firefox Driver Config plugin to hit some URL and assert some element in UI. But I am not able to launch firefox driver as I cant see an option to enable to run firefox as a headless browser .

JP@GC - WebDriver Sampler:

import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait

def wait = new WebDriverWait(WDS.browser,5000);

WDS.sampleResult.sampleStart(); WDS.browser.get('https://google.com/'); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//input[@name='q']"))); WDS.sampleResult.sampleEnd()

1

There are 1 answers

1
Dmitri T On

How about checking Headless box in the jp@gc - Firefox Driver Config?

enter image description here


Going forward be aware that you can always bypass any JMeter limitation by implementing whatever you want/need using JSR223 Test Elements and Groovy language, example code to kick off a headless Firefox would be something like:

System.setProperty('webdriver.gecko.driver','c:/apps/webdriver/geckodriver.exe')
def options = new org.openqa.selenium.firefox.FirefoxOptions()
options.addArguments('--headless')
def driver = new org.openqa.selenium.firefox.FirefoxDriver(options)
driver.get('http://example.com')
log.info('Current page title: ' + driver.getTitle())
driver.quit()

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It