Add a bunch of data to a URL data entry loacation

I am trying to figure out how to enter a large amount of data to a URL object at one time. It is simply a lot of unique data, (in my manual example below it’s around 3,000 entries like aaa, bbb, ccc, ddd etc.), that are separated by a new line character, (/n).

I have a Test Case line like this that works:

> WebUI.setText(findTestObject('Object Repository/…), 'aaa\nbbb\nccc\nddd\n…)'

What I am looking for is how to create an entry from a spreadsheet that has all the data, and format it as above. It’s not a situation where I can loop over the data one-by-one, I have to enter it all at once. I cannot find any reference that will do this automatically from the spreadsheet. I was wondering if I have to first build a list item and then feed that into the “WebUI.setText” entry.

Any help would be appreciated.

Do you need a spreadsheet? Why not just make a string class to store your long strings?

// note TRIPLE double-quotes
String myLongString = """
and so on...

Using triple double-quotes you can also add parameters, if you need to:

String name = "Edward"
String myLongString = """
and so on...
1 Like

In Java, there is a StringBuilder class. So, “build” your String from a loop that reads the spreadsheet (either in a single for loop or multiple for loops). When you have finished building your String, then you set it.

int max = findTestData('YourDataFileName').getRowNumbers();
int col = 0;
StringBuilder myText = new StringBuilder();

for (int row = 0; row < max; row++) {
    myText.append(data.getValue(row, col)).append("\n")
WebUI.setText(findTestObject('myObject'), myText.toString())

Max capacity of StringBuilder:
maximum capacity that a StringBuilder Class can reach will be 2147483647,is%20reach%20will%20be%202147483647%20.

1 Like

Thanks for the answers. Using the information above I’m able to create the search string with no issues. But here is my second problem I was wondering if someone could help with. I now have a search string with 3,449 lines of data. The data lines are small, (IP addresses with a “\n”). It takes over 11 minutes to basically copy that information into the URL object using the command below:

> WebUI.setText(findTestObject('Object Repository/…), StringName)'

It works but amounts to a copy/paste operation that manually takes 15 seconds taking 11 minutes. Is there another command I could use? Is there any way to make the process faster?

I’m confused. Precisely WHAT takes 11 minutes?

I have an application with a Web UI shown below:

I created a Katalon performance test script running against the app UI. I create a string containing 3,449 lines of data that is made up of IP addresses with a new line character sequence, (\n). The data in the string is subject to changes depending on what analysts wish to enter into the “Containing the following expressions” block so it is not static data.

Typically the analysts manually do a copy/paste of the data into the Web UI here. The test script was built to simulate these steps.

The building of the search string is done in Katalon and is quick - no problem there. It’s the “paste” of the search string into the “Containing the following expressions” block that is taking 11 minutes. To get the search string data into this block, I use the Katalon command below:

> WebUI.setText(findTestObject('Object Repository/…), StringName)'

Normally doing a copy/paste from a data file into the “Containing the following expressions” block takes 15 seconds, (the longest part of that is the data highlighting process from the data file of the 3,449 lines of data). But having Katalon paste the search string into the block is what’s taking the 11 minutes.

I was wondering if there was a faster technique to accomplish the paste process within Katalon.

1 Like

Thanks. Now I see what you’re dealing with.

So, the WebUI.setText() API is the slow bit. Deep down, that API is using selenium, which does a little more than just copy the text into the control. Even for the Katalon side of things, there is much more than simply copying the text to the control – see: katalon-studio-testing-framework/SetTextKeyword.groovy at master · katalon-studio/katalon-studio-testing-framework · GitHub . You’ll notice, it resorts to using webElement.sendKeys(text) – it’s passing the whole string one character at a time :scream:

If I were you, I’d ditch both the Test Object and the setText() API and copy the string into the control using JavaScript:

String myCrazyBigString = """ ...
String js = "document.querySelector('your_css_selector').value = '${myCrazyBigString}';"
WebUI.executeJavaScript(js, null)

You could put the whole big string into Javascript, if you prefer.

Let me know how it goes!

Russ_Thomas, is it possible for you to create a ~template~ for the integration of JavaScript and Katalon for this issue? I was not aware that you could run JS directly from Katalon nor can I find any Katalon documentation on the subject. I tried the code you have above but nothing worked at all.

The code I posted is all the template you’ll need. All you need to do is

  1. Decide how you’re going to assign the big string.
  2. Replace your_css_selector with the selector for the textarea “Containing the following expressions”.

To read more on JS in Groovy in Katalon:

And since I talk about it a lot…

I tried your suggestion but I’m getting the following error;

invalid element state: Failed to execute 'querySelector' on 'Document': 'Object Repository/SearchRawGataSetUp.obj/Page_Attributes - Dev MISP/textarea_Containing the following expressio_d8d50e' is not a valid selector.

I ran a Katalon “Record Web” to capture the UI objects and placed them in the “Object Repository”;


My code is simply this:

String js = "document.querySelector('Object Repository/SearchRawGataSetUp.obj/Page_Attributes - Dev MISP/textarea_Containing the following expressio_d8d50e').value = '${s_mispSearchString}';"
WebUI.executeJavaScript(js, null)

Any ideas on what I’m doing wrong?

Yes. I made the mistake of expecting you to understand what this means:

A reference to a Text Object (which is what you’re trying to use) is not a CSS selector.

You can use the browser’s DevTools to help you build a selector.

It will be a string which might look something like this:

div.someclass textarea.anotherclass

If you’re lucky, it might have an id something like…


If you have trouble, post your HTML showing that textarea and I’ll try to make one for you.

What I was able to fine is this:

Can we build something from this?

Cool – you have an id attribute: :sunglasses:

String js = "document.querySelector('#AttributeValue').value = '${s_mispSearchString}';"
WebUI.executeJavaScript(js, null)

Thanks for your help. The code above worked great, however I did have 2 issues that came up that I addressed.

  1. When I ran the code with 1 entry in the string it was fine. If I added any more I got an “Invalid or unexpected token” error. I found when I originally built the string, I added a “\n” to each entry. Adding more gave me the error. I escaped the new line entry, “\n”, and things were fine.

  2. Once I filled in the text area, the processing seemed to just stop. I discovered I had to add the line below to scroll to the bottom of the UI to see the “Search” button.

WebUI.executeJavaScript(‘window.scrollTo(0, document.body.scrollHeight)’, null)

Everything is working fine now. Thanks for all your help on this one.

1 Like

Glad you got it working.

Yes, be careful with \n and the like – sometimes you absolutely need them, other times the universe crumbles :wink: