【发布时间】:2018-08-25 23:25:23
【问题描述】:
我正在使用带有模拟器的 Chrome 驱动程序为移动设备进行 Selenium JAVA 测试。问题是我不能使用最先进的移动设备,如 iPhone 7,8 等,尽管在 devtools 中手动测试时它在我的下拉列表中。 这是驱动程序初始化。与许多移动设备完美配合:
if(browser.equalsIgnoreCase("mobileIPhone6")){
Map<String, String> mobileEmulation = new HashMap<String, String>();
mobileEmulation.put("deviceName", "iPhone 6");
String exePathChromeDriver = Consts.chromeDriverPath;
System.setProperty("webdriver.chrome.driver", exePathChromeDriver);
PropertyLoader.loadCapabilities();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
driver = new ChromeDriver(chromeOptions);
但是,当我将第 3 行更改为“iPhone 7”时,我收到此错误:
2018-03-16 21:25:49 INFO LogLog4j:210 - org.openqa.selenium.WebDriverException: unknown error: cannot parse capability: chromeOptions
from unknown error: cannot parse mobileEmulation
from unknown error: 'iPhone 7' must be a valid device
from unknown error: must be a valid device
知道为什么吗?非常感谢
【问题讨论】:
-
谢谢!我之前访问过您提供的第二个链接,我看到有 __"title": "iPhone 6/7/8",也适用于 iPhone X...
-
是的,我也看到了,不知道是怎么回事。
iPhone 6/7/8 Plus的图像以iPhone6Plus-landscape.svg作为其图像,所以它可能只是作为占位符吗? -
谢谢!这解释了很多。但是,我仍然很困惑。我之前访问过您提供的第二个链接,我看到有“标题”:“iPhone 6/7/8”,还有 iPhone X 等等……那是什么意思?它在这里列出了所有设备。甚至是新的
-
mmm...占位符可能是原因。非常感谢!
标签: java google-chrome selenium mobile emulation