I\'m trying to automate file attachment / file upload to gmail. While the rest of automation is working, the popup window to select file that needed to upload is not working. I already went through some file upload guide but still cannot get it done.
I use the Set text |imput_filename | path\nameoffile.doc
The script looks like this
WebUI.setText(findTestObject(āPage_Edit Business Card/input_FileNameā), āU:\Resume of a Tester.docā)
I had an issue finding the input object as Katalon didnāt record it directly, I end up using Spyweb to find it.
WebUI.setText(findTestObject(āPage_Edit Business Card/input_FileNameā), āU:\Resume of a Tester.docā)
you can try by specifying the xpath as ā//input[@type=āfileā]ā in the āinput_FileNameā test object.
or alternatively create a custom object and specify the xpath as ā//input[@type=āfileā]ā
2-You must add the following snippet in Keyword.
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable
public class testclass {
@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);
}
}
3-Finally, you should call keyword u in the corresponding step.
After the keyword is included in the project, the relevant test case step in the script field should be as follows.
CustomKeywords.ātest.testclass.uploadFileā(findTestObject(āTest_uploadfile_fieldā), 'C:\Users\\Desktop\test data)