Katalon custom "uploadFiles" keyword not loading files.
The Katalon website states that the Katalon keyword "UploadFile" will ONLY work when the tag exists on the page (the tag does NOT exist on my test page).
The suggested work-around is to use the following custom keyword; which I've added to my project. When I run the script the "uploadFile" keyword finds the object and opens "Windows Explorer" & just sits there. I think the issue is that the "uploadFile" keyword never passes the "file" to "Windows Explorer" for loading. Katalon passes the step because it has found the object. Not sure why the "keyword" is not working... Can anyone see where I am going wrong?
Package=tools.uploadFiless
//Added for uploadFiles keyword
import java.awt.Robot
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.awt.event.KeyEvent
public class uploadFiles {
@Keyword
def uploadFile (TestObject to, String filePath) {
WebUI.click(to)
StringSelection ss = new StringSelection(filePath);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
null);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
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);
}
}
//Added the following lines to the script's "import" header section
import com.kms.katalon.core.annotation.Keyword as Keyword
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
//Script test steps
WebUI.openBrowser('')
WebUI.navigateToUrl(GlobalVariable.testURL)
WebUI.maximizeWindow()
WebUI.delay(GlobalVariable.shortDelay)CustomKeywords.'tools.uploadFiles.uploadFile'(findTestObject('FILE_UPLOAD/Page_VirtualWealth/UploadFile0'),'C:\\\Users\\\eversda\\\Downloads\\\TestFiles\\\BlankCheque.png')
Windows Explorer opens without file name
Thanks Dave
Aucun commentaire:
Enregistrer un commentaire