How to Upload a file from windows explorer

Hi, the scenario works for txt file.

Hi Emine,

i repeat my question once again

Iteration 1:Will open application and upload the file and close the Application and this process will repeat for 5 iterations…

does ur scenario help me on the above 5 iterations iterations…??

Thanq

With Regards,
Mikky

@mikkili.rahul.tej
Hello , In the application you can find the solution using the custom keyword u for 5 times.
The keyword we create allows you to upload any file on your computer to the corresponding area.
This process will automatically select and load the file from the windows popup.

Hi Emine,

I had stucked at step 1 only .The Test object is having issue …i cannot able to click on the specific object .

the object is in IFrame and object is hidden . i had tried in many ways but all in Vain .

Without Test object can we able to try ur code …?? if Yes can u guide me …

Thanq

With Regards,
Mikky…!

hello @mikkili.rahul.tej

In the recording phase of the test, it will be added to the object repostory folder by right-clicking it.
Then use this object path and file url for the custom keyword.

Tried Emine …cannot able to click on the object .

Issue :need to click on upload object but object property cannot click exactly over their .it s doing operation on entire field.so thts why cannot able to get window popup

object is in the IFrame .

Refer to the screen shot attached for image and object properties .

Thanq

With Regards,
Mikky …!!

UploadIssue|690x163
Uploadissue2|534x122

@Keyword
def uploadFile2 (TestObject to, String filePath , String file , String file2) {
WebUI.click(to)
StringSelection ss = new StringSelection("""+filePath+"" " +"""+ file +"" "+ file2 );
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);
}
}

Hello Again @mikkili.rahul.tej
Then remove the object click from the Keyword code and try again.
Of the above codes, I’m marking bold ones related to object clicks. Wipe them off the code. Recall Keyword and try.

Hi Emine,

thank you for the code …that works for me without using Test Object .

now when i am trying your code to give the Path from Excel.its not working .i had followed your steps from the above responses.

My code:
CustomKeywords.‘keywordPackage.UploadSingleFile.uploadFile01’(‘findTestData(‘Delete’).getValue(1,60)’)

Your Code

CustomKeywords.‘dosya.dosyayukleme.uploadFile’(findTestObject(testobject), findTestData(‘New Test Data’).getValue(1, 1) )

Attached the screen shot for your reference

Thanq

With Regards,
Mikky

Hi

Remove the quote
CustomKeywords.'keywordPackage.UploadSingleFile.uploadFile01'(findTestData('Delete').getValue(1,60))

Hello @mikkili.rahul.tej

CustomKeywords.‘dosya.dosyayukleme.uploadFile this code should only take one parameter, it should be your file path.
When defining the file path, please make sure that it is double as C: // User // …
If you are pulling this file path from Excel content, please let // be defined in the statements in excel.

Hi HeleneB

its working …but i am looking for the code to retrieve the value from excel using custom keyword.

CustomKeywords.‘keywordPackage.UploadSingleFile.uploadFile01’(findTestData(‘Delete’).getValue(1,2))

can we do something with the above code …??

Thanq

With Regards,
Mikky

Import your Excel doc on the Data File from KatalonStudio
Right click on Data Files folder then New / Test Data / Excel File / Browse your file. Then your keyword should work

let me try and get back to u …

Thanq

With Regards,
Mikky…!

Issue Resolved …

Thanks for your contribution @emine and @HeleneB

Thanq

With Regards,
Mikky…!

1 Like

Thanks a lot, that is working well!

1 Like

Using above script, i have added “WebUI.delay(3)” two times… it’s working fine…

@Keyword
def uploadFile (TestObject to, String filePath) {
	WebUI.click(to)
	WebUI.delay(3) //Delay after click on Browser Button
	StringSelection ss = new StringSelection(filePath);
	Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
	WebUI.delay(1) //Delay after paste the text
	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);
}

@Dave_Weil1 your code works great I have successfully uploaded my file.
Do we have any other code for uploading multiple files one after the other in a loop If YES please ping your code here if anything is there so that I can implement in mine
Thanks in advance Your help is appreciated :slight_smile:

Hi @Dave_Weil1

I refer to your post from Feb 2018 (How to Upload a file from windows explorer) by using autoIT to send a file. There was a response below where the person asked how and if you can parameterize that file we send via AutoIT.

So my string looks like yours ie. autoit_prj = ‘C:\insertVariableExplorerWindow.exe “C:\#1151182.pdf”’

I have a file with 840 locations of files that I need to iterate over and upload to test our system.

I have and still am busy trying with Keywords etc but this one feels like its working the best.

autoit_prj = ‘C:\insertVariableExplorerWindow.exe “{parameterfile}”’ in the fake world

Can you assist further on this?

Regards

Hendri