Katalon File Upload with Custom Keyword


#1

Totally new to Katalon.

I’m using a custom Keyword in Katalon to upload a file to my owncloud server.

public class WebUICustomKeyword {
	@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);
	}
}

When calling it in a for-loop just the first iteration is successful. The other stop at uploading in the explorer. (debian 9 stretch)

Surprisingly when calling the keyword twice in a row everything works fine:

CustomKeywords.'aCustom.WebUICustomKeyword.uploadFile'(findTestObject('Object Repository/Page_Files - ownCloud/label_Upload'), '/home/timo/Downloads/Ba_MyDigital_School.pdf')    
CustomKeywords.'aCustom.WebUICustomKeyword.uploadFile'(findTestObject('Object Repository/Page_Files - ownCloud/label_Upload'), '/home/timo/Downloads/Ba_MyDigital_School.pdf')

WebUI.click(findTestObject('Page_Files - ownCloud/label_New_Files'))
WebUI.click(findTestObject('Object Repository/Page_Files - ownCloud/button_Continue'))

Any ideas why?


#2

@linusaegor Hello

Please take the port considering the connection located. Try to implement it step by step. If you have any problems, please contact me.


#3

Well, I just added a Thread.sleep(100) between every line in the customKeyword and now it works somehow.


#4

Hi @linusaegor,

Take a look at AutoIt tool https://www.autoitscript.com/site/ , it can help you to upload your files using scriptin mode.

I use it always and it is perfect as tool.

I can help you if you need it, but have a look at it first.

Regards Youness