IDEMPIERE-92 Adding capability to have testing for file upload panel

This commit is contained in:
Deepak Pansheriya 2013-06-14 11:54:07 +05:30
parent e62bef147d
commit d79d418a25
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@
*/ */
package fitlibrary.zk; package fitlibrary.zk;
import java.io.File;
import java.util.List; import java.util.List;
import org.idempiere.ui.zk.selenium.Widget; import org.idempiere.ui.zk.selenium.Widget;
@ -258,6 +259,21 @@ public class ZkFixture extends SpiderFixture {
actions.contextClick(element).build().perform(); actions.contextClick(element).build().perform();
} }
@SimpleAction(wiki = "|''<i>file upload</i>''|xpath, id or other locator|''<i>file path</i>''|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 * Causes the currently executing thread to sleep for the specified number
* of milliseconds, subject to the precision and accuracy of system timers * of milliseconds, subject to the precision and accuracy of system timers