Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我可以在后台运行Autoit脚本来上载文件吗_Java_Selenium_Autoit - Fatal编程技术网

Java 我可以在后台运行Autoit脚本来上载文件吗

Java 我可以在后台运行Autoit脚本来上载文件吗,java,selenium,autoit,Java,Selenium,Autoit,我有一个从Java程序调用的AutoIt脚本,该程序使用Selenium通过web应用程序加载数据。脚本使用文件中的值上传文件,但仅当Java程序在前台运行时。这个程序很可能在后台运行 我如何设置它,使程序在后台运行时能够正常工作 爪哇: 自动IT: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=C:\Users\Janet\Documents\uploadFile.exe

我有一个从Java程序调用的AutoIt脚本,该程序使用Selenium通过web应用程序加载数据。脚本使用文件中的值上传文件,但仅当Java程序在前台运行时。这个程序很可能在后台运行

我如何设置它,使程序在后台运行时能够正常工作

爪哇:

自动IT:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\Janet\Documents\uploadFile.exe
#AutoIt3Wrapper_Outfile_x64=C:\Users\Janet\Documents\uploadFile_x64a.Exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
ControlFocus("File Upload","","Edit1"); Name of the file upload window (Windows Popup Name: Open)
ControlSetText("File Upload","","Edit1",$CmdLineRaw); File name
Send("{ENTER}")

实际上,我通过在命令之前使用单词Control解决了这个问题。这是我的剧本

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\Janet\Documents\uploadFile.exe
#AutoIt3Wrapper_Outfile_x64=C:\Users\Janet\Documents\uploadFile_x64a.Exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;
;*   Script Name:   uploadFile.au3
;*   Author:        Janet Frank
;*   Date Created:  04/04/16
;*   Description:
;*     This script receives a file name from a Java program that needs to upload a file for the purpose
;*     of a profile image or an asset to the VTS site.   The file name is passed from the Java program
;*     via the command line used to execute this script.  Using the $CmdLineRaw function the program can
;*     extract that file name from the command line.
;
ControlFocus("File Upload","","Edit1"); Name of the file upload window (Windows Popup Name: File Upload)
ControlSetText("File Upload","","Edit1",$CmdLineRaw); File name passed from Java program
ControlSend("File Upload","","Button1","{Enter}") ;Press the Enter key whe on the Open button to exit the file explorer.
Exit

您是否可以将SendKeys与Selenium一起使用来上传文件?我假设这是一个基本的文件上传按钮,而不是一些javascript库实现。我认为你不能在后台程序上设置焦点。不,我不能。在初始屏幕上,没有用于输入文件名的文本框。进入裁剪器工具并在其中单击以打开“文件资源管理器”对话框。如果只是在selenium中使用sendkeys,我就会这样做。
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=C:\Users\Janet\Documents\uploadFile.exe
#AutoIt3Wrapper_Outfile_x64=C:\Users\Janet\Documents\uploadFile_x64a.Exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;
;*   Script Name:   uploadFile.au3
;*   Author:        Janet Frank
;*   Date Created:  04/04/16
;*   Description:
;*     This script receives a file name from a Java program that needs to upload a file for the purpose
;*     of a profile image or an asset to the VTS site.   The file name is passed from the Java program
;*     via the command line used to execute this script.  Using the $CmdLineRaw function the program can
;*     extract that file name from the command line.
;
ControlFocus("File Upload","","Edit1"); Name of the file upload window (Windows Popup Name: File Upload)
ControlSetText("File Upload","","Edit1",$CmdLineRaw); File name passed from Java program
ControlSend("File Upload","","Button1","{Enter}") ;Press the Enter key whe on the Open button to exit the file explorer.
Exit