So I found the method to upload files using katalon here (Katalon Studio : Popup Window and Upload File) however what I am struggling with, is finding the test object in the final step. I am assuming that this is the Test Object of the pop up window? I am not sure quite what to use for this. Can someone please inform me of how I get this please?
I have added the code that I used below, most of it is unnecessary, except for the last two steps. You will see that I have left open the “findTestObject()” at the end because thats where I am unsure of what to place.
I also included a screenshot of the Keyword that I am using.
Any help would be greatly appreciated.
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
WebUI.openBrowser('')
WebUI.navigateToUrl('https://inscape-connect-staging.stratusolvecloud.com/UserManagement/login/')
WebUI.maximizeWindow()
WebUI.setText(findTestObject('Object Repository/UploadTest/Page_Inscape Connect - Account Management/input_Login to_c1'),
'Thomas')
WebUI.setEncryptedText(findTestObject('Object Repository/UploadTest/Page_Inscape Connect - Account Management/input_Login to_c2'),
'p4y+y39Ir5PEPmX20UxFKw==')
WebUI.click(findTestObject('Object Repository/UploadTest/Page_Inscape Connect - Account Management/button_Login'))
WebUI.click(findTestObject('Object Repository/UploadTest/Page_Connect - Members - Individual Overview/a_System Configuration'))
WebUI.click(findTestObject('Object Repository/UploadTest/Page_Connect - Members - Individual Overview/a_Documents'))
WebUI.click(findTestObject('Object Repository/UploadTest/Page_Inscape Documents - Document Overview/button_Add Document'))
WebUI.setText(findTestObject('Object Repository/UploadTest/Page_Inscape Documents - Document Overview/input_Document Name_c14'),
'KatalonUploadTest')
WebUI.click(findTestObject('Object Repository/UploadTest/Page_Inscape Documents - Document Overview/a_Select All_mark_universal'))
WebUI.setText(findTestObject('Object Repository/UploadTest/Page_Inscape Documents - Document Overview/textarea_Document Description_c15'),
'KatalonUploadTest')
WebUI.selectOptionByValue(findTestObject('Object Repository/UploadTest/Page_Inscape Documents - Document Overview/select_-Please Select-SA Induction Inductio_461d79'),
'12', true)
// Click Choose File(s) button <-- This brings up the upload file popup
WebUI.click(findTestObject('Object Repository/UploadTest/Page_Inscape Documents - Document Overview/label_Choose File(s)'))
CustomKeywords.'file_upload.FileUpload.uploadFile'(findTestObject(),
'C:\\Users\\tomgb\\Pictures\\random random.jpg')
In HTML there is only one element that deals with file uploading:
So find the <input type="file" ... > and create your Test Object from that.
Note: The input element itself is fairly ugly – most websites hide it and/or wrap it with prettier, styled elements. Don’t let that confuse you. If you find the input element itself, that’s the thing you need.
Will this be the TestObject of the file? If so, will this automatically grab the file path?
And I know this is maybe a dumb further question, but how does one create the Test Object from HTML? I am still learning Katalon and a lot of this is very new to me.
Although it is a small bit, you have the boolean in the above statement set to true. This means you want to use Regular Expression (RegEx), but nothing in ‘12’ requires RegEx. So, set it to false unless you need RegEx. That way you use normal comparison to your value and nothing unexpected should occur.
@ Russ_Thomas and @ grylion54
Hi there. So I believed that I followed your advice correctly, however it for some reason doesn’t want to work. I attached my code, as well as a screenshot of the HTML and the Katalon Log Viewers.
It seems as though when it gets to the last step, it just hovers and doesn’t do anything until it fails.
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys
import com.kms.katalon.core.testobject.ConditionType as ConditionType
email = "OTPTesting16@gmail.com"
WebUI.openBrowser('')
WebUI.navigateToUrl('https://inscape-connect-staging.stratusolvecloud.com/UserManagement/login/')
WebUI.setText(findTestObject('Object Repository/File_Upload/Page_Inscape Connect - Account Management/input_Login to_c1'),
email)
WebUI.setEncryptedText(findTestObject('Object Repository/File_Upload/Page_Inscape Connect - Account Management/input_Login to_c2'),
'p4y+y39Ir5PEPmX20UxFKw==')
WebUI.click(findTestObject('Object Repository/File_Upload/Page_Inscape Connect - Account Management/button_Login'))
WebUI.click(findTestObject('Object Repository/File_Upload/Page_Connect - Operations - ApplicationAccess/div_Continue'))
WebUI.click(findTestObject('Object Repository/File_Upload/Page_Connect - Operations - Student Enrolment/button_Upload'))
xpath = '//*[@id="FileInput"]'
TestObject uploadButton = new TestObject(xpath)
uploadButton.addProperty("xpath", ConditionType.EQUALS, xpath)
WebUI.uploadFile(uploadButton, "C:\\Users\\tomgb\\Pictures\\random\\random.jpg")