Katalon Studio Native Popup Window and Upload File

Hello @tracy_ellis
To download the file on the web page first click on the relevant field. If you do not detect it, right click on the mouse with the mouse to detect this area and add it to the object repostory part.

example field picture


After this step, the test case steps are opened as shown in the following image and custom keywords are selected. You should follow the steps in the image below.

The next step assigns the keyword e.
The first parameter is the path of the file upload area, the part I mentioned above, which can be detected by the right click if it is not detected by the recorder. Please can you look above example field picture

the second parameter refers to the path of the file in the local.
For example: C: \ TEST \ test.txt

regards …

2 Likes

Thank you, this works great when I’m running a single test, but when I’m running a suite(or collection) of tests the native fileUpload window get lost behind all of the other open windows on my desktop and I find Robot trying to write text in places I don’t want it written. Is there anyway to ensure the FileUpload Windows desktop window is in the front before Robot tries to write to it? I know how to ensure a browser window is on top, but I cannot figure out how to ensure a native Windows window(fileUpload) is on top(or in front).

1 Like

This is a known issue with Robot. You need to cover all the circumstances it is likely to encounter; but if you’re executing suites, that might prove extremely difficult (if not impossible).

My advice: To keep yourself sane, restrict these kinds of tests to single-purpose testing desktops

1 Like

Hi, I also have the issue with robot. After opening new window, it paste the path to the file in the right place, but it doesn’t click enter. I have tried to set the delay but it also didn’t help. Any idea how to fix that?

Regards,
Maria

1 Like

You can use the command WebUI.delay ()

1 Like

This may help too: How to use the 'Robot Framework' to load files using a custom keyword

1 Like

In general two code doing the same thing.

1 Like

True, but the delays allowed my code to work for me:
The delays can be adjusted by the coder where needed.
robot.delay(1000); //Millisecond 1 second delay only if needed
Thread.sleep(2500) //Millisecond 2.5 second delay only if needed

2 Likes

Yes, but it doesn’t have to do it in the keyword, it can provide the waiting time for WebUI.delay () in the Test case.
Thus, the keyword will not need a waiting time.

1 Like

That might have been true for you but I tested with and without…
In my case it was needed.

1 Like

You’re right, our way of doing things is different.
Thank you for your contribution.

1 Like

Hi @emine.,

Currently Katlon provides "uploadFile " keyword as default. IS there any difference with that or same?

1 Like

I actually need to see the same function but I couldn’t get a solution with the uploadfile keyword.
Therefore, I was able to create a custom keyword by using the robot class and get a definite solution.

1 Like

Hi @emine

I tried as you said…i added custom keyword as you mentioned above.(snapshot attached here). But when i type ‘dot’ mark after type ‘CustomKeywords’ word ,it is not suggesting anything. can you please help me to find the case?

1 Like

Hello Again @rushantha

For Custom Keyword, please add the libraries below to the top of the code.

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 com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.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
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import java.awt.Robot
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import java.awt.event.KeyEvent

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

1 Like

Hi… now added above mention libraries and i think now keyword is ok.

But when i type ‘CustomKeywords’ word in test script it is showing error as below and it is not suggesting anything

1 Like

Hello Again @rushantha

1.Step : Please refresh the keyword folder.

2.Step : Open your Test Case page and add a custom keyword from the ADD field.

1 Like

It’s missing @Keyword before def uploadFile(TestObject tp, String filePath)

1 Like

Hello @HeleneB

In the custom keyword definition, the relevant phrase exists, has it added? couldn’t tell where missing.

1 Like

Thanks @emine… you did great help for me… thanks a lot… now it is successfully happening…:grinning::grinning::grinning::+1::+1:

2 Likes