Question about the time it takes to complete a script with a `for` loop

Hello community!!!

For example, I have this part of code below, which find some <a> elements where they are nested into a <ul> element of a page and then stores their href tags and their sum into those global variables:

WebDriver driver = DriverFactory.getWebDriver()

List<String> hrefs = []
List<WebElement> aTags = driver.findElements(By.xpath('//ul[5]/li/div/div[@class="heading-4"]/a'))

for (aTag in aTags) {
	String href = aTag.getAttribute("href")
	if (href != null) {
	} else {

GlobalVariable.urls = hrefs
GlobalVariable.urlsCount = hrefs.size()

def message_result = JOptionPane.showOptionDialog(null, hrefs.size() + " URLs found.", "Message", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE)

My problem is the time that this script takes to finish. And I want to know, is it normal this for loop to take 40 seconds for 144 elements, or is something wrong with my code?

And the strange thing is that I get the optionDialog with the result very soon, but the Log Viewer keep working and the Job Progress says < Running > until the Log Viewer ends. For example it takes 4 seconds to give me the optionDialog with the result and close to 35 seconds for Log Viewer to finish and the Job Progress to say < Passed >.

So, is this normal? Is there any problem with my code? Can I do something to make it faster?

Thank you in advance!!!

Are you using “Tree” mode in the log viewer?

The following thread might help - I’ve picked out the most salient points:


I switched “Log Viewer” from “Tree View” to “Table View”, I left enabled only “Failed”, “Error” and “Warning” messages and now… It is “flying”!!! :open_mouth:

Thank you very much for the answer and your time!!! :slightly_smiling_face:

1 Like

Good news.

Shout out: @duyluong @devalex88

@kazurayam We should pressure the devs to include this tip prominently in the docs somewhere. When a user runs some otherwise innocuous code, the affect on performance (as you noticed) can be quite dramatic.


I want Katalon Studio Free license to keep allowing users to switch the “Log Viewer” from “Tree View” to “Log View”. And in the “Log View”, I want Katalon Studio free license to keep allowing us to turn the “All button” off.


Please, at the very minimum, do not change these options to be the Enterprise features in the future versions.



Katalon Studio should be changed so that

  1. Log Viewer should default to show “Log View” rather than “Tree View” after a project is created.

  2. In the “Log View”, the “All” be should default to OFF after a project is created.


Hi @kazurayam and @Russ_Thomas

Thank you for letting me know. Our team is considering your suggestions.