简体   繁体   English

groovy.lang.MissingPropertyException:没有这样的属性:类的工具包:custom.SampleKeyword

[英]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 . 我想你只是缺少Toolkitimport 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.

相关问题 groovy.lang.MissingMethodException:没有方法签名:使用机械手类上传文件时出现以下错误 - groovy.lang.MissingMethodException: No signature of method: is the following error while uploading a file using robot class org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:Script7.groovy:1:无法解析class - org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script7.groovy: 1: unable to resolve class java.lang.UnsupportedClassVersionError:.class文件中的错误版本号 - java.lang.UnsupportedClassVersionError: Bad version number in .class file 将驱动程序/对象传递给其他页面/类-java.lang.NullPointerException - Passing driver/object to other page/class - java.lang.NullPointerException 从父类获取属性调用 - Get property call from parent class 线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件的路径必须由:系统属性设置 - Exception in thread "main" java.lang.IllegalStateException:The path to the driver executable must be set by the : system property 为 selenium webdriver 类获取 java.lang.NullPointerException - Getting java.lang.NullPointerException for selenium webdriver class 在类中找不到JMETER Beanshell(java.lang.String) - JMETER Beanshell ( java.lang.String ) not found in class 自定义类数组作为TestNG中的@DataProvider - Custom class arrays as @DataProvider in TestNG 错误:无法初始化主类基引起:java.lang.NoClassDefFoundError:org/openqa/selenium/Capabilities - Error: Unable to initialize main class base Caused by: java.lang.NoClassDefFoundError: org/openqa/selenium/Capabilities
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM