【发布时间】:2020-11-06 00:58:45
【问题描述】:
我必须在不同的移动视图中运行一些测试用例。我正在尝试使用 Google Chrome 在移动仿真模式下测试运行。如果选择了现有列表中的设备但尝试从此处创建自定义设备,则测试用例工作正常:
并使用以下代码运行测试:
@Test
public void responsive() {
String driverPath = "/Users/resources/drivers/chromedriver";
System.setProperty("webdriver.chrome.driver", driverPath);
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Pixel 3");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.com");
}
导致以下异常:
org.openqa.selenium.InvalidArgumentException:无效参数:条目 'firstMatch' 的 0 因参数无效而无效:无法解析 能力:来自无效参数的goog:chromeOptions:无法解析 来自无效参数的 mobileEmulation:“Pixel 3”必须是有效的 来自未知错误的设备:必须是有效的设备构建信息:版本: '3.13.0',修订:'2f0d292',时间:'2018-06-25T15:24:21.231Z'
是否有任何额外的东西需要在自定义设备中运行测试?
【问题讨论】:
标签: java selenium google-chrome automated-tests selenium-chromedriver