level 2
猛虎虎出笼
楼主
系统信息如下:
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172'
Chrome version: 89.0.4389.82
Chrome Driver version : chromedriver_win32.zip 2021-01-28T17:30:57.154Z
Selenium version :3.141.59
代码如下:
public void setUp() throws IOException, InterruptedException {
String startChromeCMD = "chrome --remote-debugging-port=9222";
// 启动chrome浏览器
Runtime.getRuntime().exec(startChromeCMD);
Thread.sleep(1000);
System.setProperty("webdriver.chrome.driver", DRIVER_TOOLS_DIR);
//配置参数
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir", CHROME_WORK_DIR);
options.setExperimentalOption("debuggerAddress", DRIVER_DEBUG_ADDRESS);
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
mobileEmulation.put("deviceName", "Moto G4");
options.setExperimentalOption("mobileEmulation", mobileEmulation);
driver = new ChromeDriver(options);
driver.manage().window().setSize(new Dimension(1280, 890));
}
结果程序运行时报错,提示出错行是这一行:driver = new ChromeDriver(options);
查了很多信息,都说是driver与chrome不对,但我是按关联关系下载的,其它功能都可以正常使用,但唯独模拟移动模式不可以。应该不是版本不符造成的。实在没撤了,救助。
异常信息如下:
org.openqa.selenium.InvalidArgumentException: invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: unrecognized chrome option: mobileEmulation
remote stacktrace: Backtrace:
GetHandleVerifier [0x00EFB963+483]
GetHandleVerifier [0x00EFB941+449]
GetHandleVerifier [0x012A3308
+3
832712]
GetHandleVerifier [0x012B5190+3906064]
GetHandleVerifier [0x012B7724+3915684]
GetHandleVerifier [0x012B29AE+3895854]
GetHandleVerifier [0x012DDA42+4072130]
GetHandleVerifier [0x012DD5BE+4070974]
GetHandleVerifier [0x012DE6BB+4075323]
GetHandleVerifier [0x012DE56C+4074988]
GetHandleVerifier [0x012DB2EB+4062059]
GetHandleVerifier [0x012BED14+3945876]
GetHandleVerifier [0x012BFBCE+3949646]
GetHandleVerifier [0x012BFB59+3949529]
Ordinal0 [0x00EBB5CC+46540]
Ordinal0 [0x00EB9F53+40787]
Ordinal0 [0x00EB9B12+39698]
GetHandleVerifier [0x011C1468+2907368]
GetHandleVerifier [0x010071EE+1096302]
GetHandleVerifier [0x00FC3E8D+821005]
GetHandleVerifier [0x00FC396B+819691]
GetHandleVerifier [0x00FC3881+819457]
GetHandleVerifier [0x00FEF463+998627]
BaseThreadInitThunk [0x746F62C4+36]
RtlSubscribeWnfStateChangeNotification [0x775F0FD9+1081]
RtlSubscribeWnfStateChangeNotification [0x775F0FA4+1028]
2021年03月09日 09点03分
1
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_172'
Chrome version: 89.0.4389.82
Chrome Driver version : chromedriver_win32.zip 2021-01-28T17:30:57.154Z
Selenium version :3.141.59
代码如下:
public void setUp() throws IOException, InterruptedException {
String startChromeCMD = "chrome --remote-debugging-port=9222";
// 启动chrome浏览器
Runtime.getRuntime().exec(startChromeCMD);
Thread.sleep(1000);
System.setProperty("webdriver.chrome.driver", DRIVER_TOOLS_DIR);
//配置参数
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir", CHROME_WORK_DIR);
options.setExperimentalOption("debuggerAddress", DRIVER_DEBUG_ADDRESS);
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
mobileEmulation.put("deviceName", "Moto G4");
options.setExperimentalOption("mobileEmulation", mobileEmulation);
driver = new ChromeDriver(options);
driver.manage().window().setSize(new Dimension(1280, 890));
}
结果程序运行时报错,提示出错行是这一行:driver = new ChromeDriver(options);
查了很多信息,都说是driver与chrome不对,但我是按关联关系下载的,其它功能都可以正常使用,但唯独模拟移动模式不可以。应该不是版本不符造成的。实在没撤了,救助。
异常信息如下:
org.openqa.selenium.InvalidArgumentException: invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: unrecognized chrome option: mobileEmulation
remote stacktrace: Backtrace:
GetHandleVerifier [0x00EFB963+483]
GetHandleVerifier [0x00EFB941+449]
GetHandleVerifier [0x012A3308
+3
832712]
GetHandleVerifier [0x012B5190+3906064]
GetHandleVerifier [0x012B7724+3915684]
GetHandleVerifier [0x012B29AE+3895854]
GetHandleVerifier [0x012DDA42+4072130]
GetHandleVerifier [0x012DD5BE+4070974]
GetHandleVerifier [0x012DE6BB+4075323]
GetHandleVerifier [0x012DE56C+4074988]
GetHandleVerifier [0x012DB2EB+4062059]
GetHandleVerifier [0x012BED14+3945876]
GetHandleVerifier [0x012BFBCE+3949646]
GetHandleVerifier [0x012BFB59+3949529]
Ordinal0 [0x00EBB5CC+46540]
Ordinal0 [0x00EB9F53+40787]
Ordinal0 [0x00EB9B12+39698]
GetHandleVerifier [0x011C1468+2907368]
GetHandleVerifier [0x010071EE+1096302]
GetHandleVerifier [0x00FC3E8D+821005]
GetHandleVerifier [0x00FC396B+819691]
GetHandleVerifier [0x00FC3881+819457]
GetHandleVerifier [0x00FEF463+998627]
BaseThreadInitThunk [0x746F62C4+36]
RtlSubscribeWnfStateChangeNotification [0x775F0FD9+1081]
RtlSubscribeWnfStateChangeNotification [0x775F0FA4+1028]