我在Katalon中使用自定义关键字将文件上传到我自己的cloud服务器。
public class WebUICustomKeyword {
@Keyword
def uploadFile(TestObject to, String filePath) {
WebUI.click(to)
StringSelection ss = new StringSelection(filePath);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
}
在for循环中调用它时,第一次迭代才成功。另一站是在资源管理器中上传。 (Debian 9拉伸)
令人惊讶的是,连续两次调用关键字时,一切正常:
CustomKeywords.'aCustom.WebUICustomKeyword.uploadFile'(findTestObject('Object Repository/Page_Files - ownCloud/label_Upload'), '/home/timo/Downloads/Ba_MyDigital_School.pdf')
CustomKeywords.'aCustom.WebUICustomKeyword.uploadFile'(findTestObject('Object Repository/Page_Files - ownCloud/label_Upload'), '/home/timo/Downloads/Ba_MyDigital_School.pdf')
WebUI.click(findTestObject('Page_Files - ownCloud/label_New_Files'))
WebUI.click(findTestObject('Object Repository/Page_Files - ownCloud/button_Continue'))
任何想法为何?可能是造成中断的原因吗?