0

I'm working on Jmeter with selenium but whenever I try to run jmeter with selenium on chrome browser, the browser opens up and closes immediately. On the log of Jmeter I found this error, I have searched all over the internet but couldn't find any solution to it. If anyone can help me on this than that would be great.

org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:56481/devtools/browser/63327648-5601-4baa-9367-c7f21bfd2b37

I'm not using eclipse to write any selenium code. This is just beginning of working with Jmeter with Selenium so I need to know how to start chrome browser with selenium jmeter. I have not made any change to Chrome driver config on Jmeter. I have just added chromedriver.exe file location and that's it. In Webdriver sampler I have made no changes except the website url. I have changed it to google.com.

WDS.SampleResult.sampleStart(); 
WDS.browser.get('http://google.com');
var searchBox = WDS.browser.findElement(org.openqa.selenium.By.name("q"));
searchBox.sendKeys("Test"); 
searchBox.sendKeys(org.openqa.selenium.Keys.Enter);
WDS.sampleResult.sampleEnd();

This is the WebDriver Sampler file.

1 Answers1

0

Check jmeter.log file and STDOUT for more entries as your question cannot be answered comprehensively in its current state

Blind shot: you're suffering from Selenium bug 11750, the workarounds are in:

  1. Add --remote-allow-origins=* option to the "Options" tab of your Chrome Driver Config

    enter image description here

  2. Roll back Chrome and Chromedriver to 110

  3. Upgrade to the latest version of the WebDriver Sampler using JMeter Plugins Manager, it will download new Selenium java client libraries with the fix.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thank you @Dmitri it worked well. But the only issue which I'm facing is, chrome shuts down immediately after searching. Is there any way we can let browser know to remain active after searching anything or do not close immediately – Rohit Mathur Mar 28 '23 at 09:51
  • I have updated the code written in webdriver sampler file. – Rohit Mathur Mar 28 '23 at 10:03
  • The browser closes when the thread (virtual user) doesn't have any more Samplers to execute. If the WebDriver Sampler is the only sampler in the Thread Group you can add i.e. [Flow Control Action](https://jmeter.apache.org/usermanual/component_reference.html#Flow_Control_Action) sampler after it and configure it to pause for the desired number of seconds. If there is another Sampler after it- you can add a [Timer](https://www.blazemeter.com/blog/jmeter-timer) as a child of that sampler. Or add `java.lang.Thread.sleep(10000)` to your script, it will create 10 s econds delay. – Dmitri T Mar 28 '23 at 11:14
  • also it's totally different question which is not related to the original one, instead of using comments you should rather start a new thread – Dmitri T Mar 28 '23 at 11:20