我有一个函数setfieldvalue,可以将数据输入到文本字段中。然后我调用pressenter函数按Enter键。光标已经在文本字段中。我不确定UFT为什么不按回车键。
//connect
try {
session = jsch.getSession(user, host, port);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword( password );
session.connect();
Channel channel = session.openChannel( "sftp" );
channel.connect();
sftpChannel = (ChannelSftp) channel;
//make sure that file does not exist or
//user wants to overwrite the file
testStream = sftpChannel.get(destination);
if (testStream != null && !overwrite) {
throw new SftpException(ChannelSftp.SSH_FX_OP_UNSUPPORTED, "File already exists");
}
} catch (SftpException e) {
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE){
//file does not yet exist. continue.
} else {
resultComments = "SFTP Exception " + e.getMessage();
status = RunResult.FAIL;
e.printStackTrace();
}
} catch (JSchException e) {
resultComments = "Jsch Exception " + e.getMessage();
status = RunResult.FAIL;
e.printStackTrace();
}
try {
//if file does not exist or overwrite selected, transfer file
if (testStream == null || overwrite) {
ByteArrayInputStream fileByteInputStream = new ByteArrayInputStream(fileByteArray);
if (sftpChannel != null) {
String workingDirectory = destination.substring(0, destination.lastIndexOf("/") + 1);
String fileName = destination.substring(destination.lastIndexOf('/') + 1, destination.length());
sftpChannel.cd(workingDirectory);
sftpChannel.put(fileByteInputStream, fileName, sftpChannel.OVERWRITE);
try {
fileByteInputStream.close();
} catch (IOException e) {
resultComments = "SFTP Exception: Unable to close Input Stream." + e.getMessage();
status = RunResult.FAIL;
e.printStackTrace();
}
sftpChannel.exit();
}
if (session != null) {
session.disconnect();
}
}
} catch (SftpException e) {
resultComments = "SFTP Exception " + e.getMessage();
status = RunResult.FAIL;
e.printStackTrace();
}
如何编写一个按下光标所在位置的函数?
答案 0 :(得分:1)
尝试使用DeviceReplay
。
Set devRep = CreateObject("Mercury.DeviceReplay")
devRep.PressKey 28