2017-02-24 33 views
1

這是AutoIt腳本無法使用機器人及的AutoIt腳本

ControlFocus("File Upload","","Edit1") 
ControlSetText("File Upload","","Edit1", "file path") 
ControlClick("File Upload","","Button1") 

而且機器人腳本是做文件上傳功能在詹金斯:

StringSelection stringSelection = new StringSelection(string); 
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null); 
Robot robot = new Robot(); 

robot.keyPress(KeyEvent.VK_CONTROL); 
robot.keyPress(KeyEvent.VK_V); 
robot.keyRelease(KeyEvent.VK_V); 
robot.keyRelease(KeyEvent.VK_CONTROL); 
robot.keyPress(KeyEvent.VK_ENTER); 
robot.keyRelease(KeyEvent.VK_ENTER); 

我只是試圖與上述腳本jenkins執行,但它不起作用。 任何人都可以請建議我與正確的執行腳本。

回答

0

如果您使用Selenium,你加了標籤的問題,上載文件的正確方法是使用sendKeys,這裏有一個例子:

string File = "SomeTextFile.txt"; 
string FilePath = @"C:\Whatever\" + File; 

driver.get("http://the-internet.herokuapp.com/upload"); 
driver.findElement(By.id("file-upload")).sendKeys(FilePath); 
driver.findElement(By.id("file-submit")).click(); 

您的詹金斯的腳本可能是失敗的,你有多種原因當它發生時觀看它。可能是你點擊一個錯誤的按鈕,或者你沒有在你的奴隸等活躍的桌面...