Katalon | File Upload | Using Robot Framework

Problem Statement:

Uploading a file is a common piece of functionality found on the web. But when trying to automate it you get prompted with a dialog box that is just out of reach for Selenium.

Solution:

Selenium Webdriver can’t handle these OS pop-ups/applications. To handle dialog box, people often look to a third-party tool to manipulate this window. Few of them are:

Note: Each option mentioned above has their own advantages and disadvantages. Choice should be purely based on our need/use case. We are going to see how Robot Framework works here as a reference.

A) Create Custom keyword:

Create new custom keyword so it can be utilized as and when needed through out the project. How to create custom keyword? please refer here.

B) Include Robot Framework Code:

Copy following Robot framework code to custom keyword. This keyword takes 2 parameters.

  • TestObject to — Name of the field on the web page you want to upload
  • String filePath — parameter is the path of the file in the locale.

C) Access Custom Keyword into Test Step:

Custom keywords in Scripting view

  • The Class CustomKeywords of Katalon Studio allows you to access all custom keywords. Enter the following syntax into the script editor:

Custom keywords in feature file / Step definition (Groovy)

  • In the custom keyword class and the BDD step definition class, custom keywords cannot be called directly as in test case via CustomKeywords class. They can be called as methods of a groovy class.

Complete code:

  • I have placed file to be uploaded under Project Dir itself.

Disadvantages of Robot Class

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -

  • Keyword/mouse event will only works on current instance of Window. During automation execution, In case, focus gets changed from current window then robot framework will tries to execute commands on other screen.
  • Most of the methods like mouseMove is screen resolution dependent so there might be a chance that code working on one machine might not work on other.

--

--

Agile Product Leader | Delivery Manager | Design Thinker (PRINCE2, CSPO™, CSM™, SFC™, ISTQB)

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Priyank Shah

Priyank Shah

Agile Product Leader | Delivery Manager | Design Thinker (PRINCE2, CSPO™, CSM™, SFC™, ISTQB)