【问题标题】:Get Clipboard from Real iOS Device从真实 iOS 设备获取剪贴板
【发布时间】:2019-06-26 12:44:30
【问题描述】:
我无法获取 Real iOS 设备的剪贴板..所有结果都是空的..
driver.getClipboard(ClipboardContentType.URL);
driver.getClipboard(ClipboardContentType.IMAGE);
driver.getClipboard(ClipboardContentType.PLAINTEXT);
driver.getClipboardText());
driver.getClipboardImage());
虽然我可以成功设置剪贴板..使用下面的方法。
driver.setClipboardText("Text");
有没有办法修复它,或者终端中是否有可以获取剪贴板的命令?
操作系统:MacOS Mojave。 Appium:1.9 iPhone X (12.2)。
【问题讨论】:
标签:
ios
macos
terminal
appium-ios
【解决方案1】:
Appium getClipboardText issue
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");