我无法获得Real iOS Device的剪贴板..所有结果都是空的..
driver.getClipboard(ClipboardContentType.URL); driver.getClipboard(ClipboardContentType.IMAGE); driver.getClipboard(ClipboardContentType.PLAINTEXT); driver.getClipboardText()); driver.getClipboardImage());
虽然我可以使用以下方法成功设置剪贴板。
driver.setClipboardText( “文本”);
有没有办法解决它,或者终端中是否有可以获取剪贴板的命令?
OS:MacOS的莫哈韦沙漠。 Appium 1.9 iPhone 10(12.2)。
Appium不提供任何用于在真实设备上复制剪贴板上下文的原语。相反,您可以将文本粘贴到任何文本字段中。我的申请使用以下内容。
TouchAction ta = new TouchAction(iDriver);
//For pasting content
ta.press(PointOption.point(x,y))
.waitAction(WaitOptions.waitOptions(Duration.ofSeconds(2)))
.perform();
By byPaste = By.xpath("//XCUIElementTypeMenuItem[@name='Paste']");
iDriver.findElement(byPaste).click();
//Get the text in the text field
element.getAttribute("value");