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).
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.
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
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:
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 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:
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.
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.
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)
Thanks for your help. The code above worked great, however I did have 2 issues that came up that I addressed.
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.
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.