diff --git a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java index 7218a029b1..13683ed91b 100644 --- a/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java +++ b/org.idempiere.ui.zk.selenium/src/fitlibrary/zk/ZkFixture.java @@ -3,6 +3,7 @@ */ package fitlibrary.zk; +import java.io.File; import java.util.List; import org.idempiere.ui.zk.selenium.Widget; @@ -258,6 +259,21 @@ public class ZkFixture extends SpiderFixture { actions.contextClick(element).build().perform(); } + @SimpleAction(wiki = "|''file upload''|xpath, id or other locator|''file path''|path of file|", tooltip = "Uploads file from the given path.") + public boolean fileUploadFilePath(String locator, String filePath) throws Exception{ + if(filePath.equals("")){ + throw new Exception("file path is not specified."); + } + File file = new File(filePath); + String ext = filePath.substring(filePath.trim().lastIndexOf("."), filePath.length()).toLowerCase(); + if(!file.exists() || !(ext.endsWith(".jpg") || ext.endsWith(".bmp") || ext.endsWith(".png") || ext.endsWith(".ico"))){ + throw new Exception("Upload an image of type jpg, bmp, png or ico."); + } + WebElement fileInput = webDriver.findElement(By.xpath(locator)); + fileInput.sendKeys(filePath); + return true; + } + /** * Causes the currently executing thread to sleep for the specified number * of milliseconds, subject to the precision and accuracy of system timers