JMeter-用于Safari中移动设备的客户端

JMeter-用于Safari中移动设备的客户端,jmeter,mobile-safari,performance-testing,client-side,jsr223,Jmeter,Mobile Safari,Performance Testing,Client Side,Jsr223,我在Win上安装了Safari浏览器,上面安装了webdriver,并在JSR223中为Safari编写了以下代码: import org.openqa.selenium.safari.SafariOptions; import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.WebDriver; import org.openqa.selenium.By; import org.openqa.seleniu

我在Win上安装了Safari浏览器,上面安装了webdriver,并在JSR223中为Safari编写了以下代码:

import org.openqa.selenium.safari.SafariOptions;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.util.concurrent.TimeUnit;

Map<String, Object> mobileEmulation = new HashMap<>();
mobileEmulation.put("userAgent", "vars.get("userAgent")");
Map<String, Object> safariOptions = new HashMap<>();
safariOptions.put("mobileEmulation", mobileEmulation);

SafariOptions safari = new SafariOptions();
options.setExperimentalOption("mobileEmulation", mobileEmulation);

SafariDriver driver = new SafariDriver(options);

driver.get("url");

WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("xpath")));
driver.findElement(By.xpath("xpath")).click();
  
vars.putObject("driver", driver);
Response code:500
Response message:javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script19.groovy: 2: unable to resolve class org.openqa.selenium.safari.SafariOptions
 @ line 2, column 1.
   import org.openqa.selenium.safari.SafariOptions;
   ^

Script19.groovy: 3: unable to resolve class org.openqa.selenium.safari.SafariDriver
 @ line 3, column 1.
   import org.openqa.selenium.safari.SafariDriver;
   ^

2 errors

你能帮我找到我遗漏了什么吗?

关于你得到的错误,你似乎没有,所以你需要下载相应的.jar,将它放到JMeter安装的“lib”文件夹中,然后重新启动JMeter来提取库

关于您的“Safari browser on Win”一节,您是否绝对确定这是您真正想要做的事情?Windows版本的,我认为您不应该投资于对8年历史的浏览器进行自动测试

展望未来,我认为这一行:

mobileEmulation.put("userAgent", "vars.get("userAgent")");
应该是这样的:

mobileEmulation.put("userAgent", vars.get("userAgent"));

我也没有看到JMeter的有效用例,如果您需要模拟不同的浏览器进行性能测试-您可以使用普通JMeter的采样器轻松发送相关的头并执行加载,如果您只是创建自动测试-您根本不需要JMeter

谢谢,Dmitri t!