JSR223 无法捕获 chromeOptions

JSR223 cant catch chromeOptions

有人可以帮助 chrome Jmeter 中 JSR223 采样器的选项和功能吗? 此代码在 eclipce 中正常工作,但似乎 JSR Sampler 没有看到选项:

ChromeOptions options = new ChromeOptions(); 
options.addArguments("--start-maximized"); 
options.addArguments("--disable-infobars"); 
options.addArguments("--user-data-dir=C:/Users/AntonK/AppData/Local/Google/Chrome/User Data/Default"); 
DesiredCapabilities dc = DesiredCapabilities.chrome(); 
dc.setCapability(ChromeOptions.CAPABILITY, options); 
driver = new RemoteWebDriver(new URL("http://localhost:9999/wd/hub"), dc);

chrome 开始于 window 而不是最大化 并指定了临时配置文件。

我无法使用 selenium-chrome-driver-2.52.0.jar (comes with JMeter WebDriver Sampler plugin) and selenium-server-standalone-2.53.0

重现您的问题

  1. 确保添加必要的imports,即:

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import java.net.URL;
    
  2. 检查 jmeter.log 文件是否有任何可疑条目
  3. 确保选择 groovy in the Language dropdown, don't be confused with java language option which is not real Java but Beanshell 解释器