因此,要做到这一点,首先需要将移动功能添加到驱动程序中(请参阅Mobile
Emulation):
Map<String, String> mobileEmulation = new HashMap<>();mobileEmulation.put("deviceName", "Galaxy S5"); // Choose a device available in your version of chromimumMap<String, Object> options = new HashMap<>();options.put("mobileEmulation", mobileEmulation);capabilities.setCapability(ChromeOptions.CAPABILITY, options);RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);然后,当您需要触摸操作时,就需要“增强”驱动程序,以便对其进行投射:
TouchActions builder = new TouchActions(newAugmenter().augment(remoteWebDriver));
然后,您可以从该构建器执行所需的
builder.down(), move(), scroll(), up()...任何操作。



