0
votes

I am using JMeter Version 5.4.1

Chrome Browser Version 91.0.4472.114 (Official Build) (64-bit)

I setup Chrome Driver Config in JMeter and added the path to my downloaded ChromeDriver exe in my C Folder: C:\Tools\chromedriver_win32\chromedriver.exe

I added JMeter Sampler (WebDriver Sampler) The Script language is Java Added below Script:

*WDS.sampleResult.sampleStart();
WDS.browser.get('https://google.com');
var searchBox = WDS.browser.findElement(org.openqa.selenium.By.name("q"));
searchBox.sendKeys("Automation");
searchBox.sendKeys(org.openqa.selenium.Keys.ENTER);
WDS.sampleResult.sampleEnd();*

When I run in JMeter, I get the error below: *

javax.script.ScriptException: Sourced file: inline evaluation of: ``WDS.sampleResult.sampleStart(); WDS.browser.get('https://google.com'); var searc . . . '' Token Parsing Error: Lexical error at line 2, column 19.  Encountered: "t" (116), after : "\'h": <at unknown location>
 in <unknown file>
at bsh.engine.BshScriptEngine.evalSource(BshScriptEngine.java:93)
at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:46)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler.sample(WebDriverSampler.java:86)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.base/java.lang.Thread.run(Thread.java:831
2
Use double quotes ("https://google.com") - user7294900

2 Answers

0
votes

I'm also using the same version of chrome browser. and I'm using your code, it works fine didn't face any issues. Your chrome driver may be the cause of that issue or Jmeter version. PFA

Jmeter Webdriver Integration
0
votes
  1. There is no "Java" language available for scripting in the WebDriver sampler, what is called "Java" is Beanshell interpreter so I would recommend reconsidering the language choice because:

  2. Your code won't compile either in Java or Beanshell because single quotation marks are reserved for Char and you're using String. So change this line:

    WDS.browser.get('https://google.com');
    

    to this

    WDS.browser.get("https://google.com");
    

    and the code will start working normally (however it will work without any changes in Groovy)