2016-04-14 16 views
3

Bir web uygulaması aracılığıyla veri yüklemek için Selenium kullanan Java programımdan aradığım bir AutoIt komut dosyası var. Komut dosyası, dosyadan değeri kullanarak ancak Java programı ön planda çalıştığında dosyayı karşıya yüklemeye çalışır. Muhtemelen bu program arka planda çalışacaktır.Bir dosya yüklemek için arka planda bir Autoit komut dosyasını çalıştırabilir miyim?

Arka planda çalışırken program çalışacak şekilde nasıl kurabilirim?

Java:

Thread.sleep(2000); // wait for page load 
Runtime.getRuntime().exec("C:\\Users\\Janet\\Documents\\uploadFile.exe " + uploadFile); 

AutoIt: Aslında komutlar önce kelime Kontrolünü kullanarak bu sorunu çözdük

#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}") 
+0

Dosyayı yüklemek için sadece Selenyumlu SendKey'leri kullanamaz mısınız? Bunun temel dosya yükleme düğmesi olduğunu ve javascript kütüphane uygulamasının olmadığını varsayıyorum. –

+1

Arka plan programında bir odaklama yapabileceğinizi düşünmüyorum. – IkeRoyle

+0

Hayır Yapamam. İlk ekranda bir dosya adı girmek için metin kutusu yoktur. Bir kepçe aracına gidip dosya gezgini iletişim kutusunu açmak için bunun içine tıkla. Şayet sadece selenyumdaki göndericileri kullanıyor olsaydım, bunu yapardım. – Janet

cevap

1

. İşte benim senaryo.

#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 
İlgili konular