[英]groovy.lang.MissingPropertyException: No such property: Toolkit for class: custom.SampleKeyword
Uploading a file using robot class, but unable to upload it due to the exception. 使用机器人类上传文件,但由于异常而无法上传文件。
@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_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_V);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
Calling this method in Tc, CustomKeywords.'custom.SampleKeyword.uploadFile'( findTestObject('Object'),'Path') 在Tc,CustomKeywords.'custom.SampleKeyword.uploadFile'中调用此方法(findTestObject('Object'),'Path')
I think you're just missing an import
for Toolkit
. 我想你只是缺少
Toolkit
的import
。 Either add the following 添加以下内容
import java.awt.Toolkit
or replace 或替换
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
with 同
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.