[英]groovy.lang.MissingMethodException: No signature of method: is the following error while uploading a file using robot class
[英]groovy.lang.MissingPropertyException: No such property: Toolkit for class: custom.SampleKeyword
使用機器人類上傳文件,但由於異常而無法上傳文件。
@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);
}
在Tc,CustomKeywords.'custom.SampleKeyword.uploadFile'中調用此方法(findTestObject('Object'),'Path')
我想你只是缺少Toolkit
的import
。 添加以下內容
import java.awt.Toolkit
或替換
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
同
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.