Katalon Studio Web Testing

How to get the list of data from the web

Hi there! I am new to katalon and dont have much knowledge. I would be grateful if you could help me.
I have a list of projects and on that, I want to perform for functionalities:

  1. I want to click on any project (From the given list) and then edit some details.

  2. I want to get that list of projects and display it in katalon. Is that even possible? Sorry for such a query

1 Like

Probably possible, but your choice of words concerns me. You say “I want to click on any project”. No.

Assuming the list of projects is in a browser app, then you set up your test to have Katalon click on a project and check out your edits. In that respect, that’s probably doable. However, you may have to create multiple Test Cases to run your full list of projects. Since I don’t know how much you want to edit, you may have to have multiple Test Suites. Although each Test Suite can have multiple Test Cases, I would limit the number of TC (e.g. 4). Therefore, you should break your project up into multiple tests (by having multiple Test Suites or Test Collections).


So, I had another think and perhaps you could pause/delay your browser app running on the list of projects, say for 12 seconds, and manually select one. Then, you could have Katalon detect which line/project you selected and then run the appropriate test case. You would need to know how to read the HTML of your app, though, so you know which line was selected and code for it.
Personally, I would not do it this way. Just go with my first reply.

1 Like

Hi @grylion54 Sorry for the late response and I appreciate your reply.
I will make it simple. As you can see in the above Screenshot that the edit mode of the project URL has the Unique ID. Is that possible to fetch that ID and use it in the variable to access that project? IF yes, can you please tell me how?

You can get the site’s URL with WebUI.getUrl(), then use substring to get the ID.

def url = WebUI.getUrl()
def id = url.substring()

Later you can use the ID to navigate to any page you want.

WebUI.navigateToUrl('https://site/project/' + id + '/page/')
1 Like

Hi @daniel.makra thanks for your reply
I tried using your approach but this is the exception that I am getting.

Sorry, I was not clear about substring. Please check for groovy substring’s syntax.
Based on the URL you need to find out the begin/end index to get the ID

I did check it out. But as I don’t have much in-depth knowledge I can’t seem to divide the strings properly. This is the URL (example https://xyz.xyz.com/project/492512/edit?project=1 )from which I am trying to get the ID 492512. Can you plz tell me what would be indexed I should use? This is what I used def id = url.substring(28, 6) and it gave me this error java.lang.StringIndexOutOfBoundsException: String index out of range: -24

url.substring(28, 34) should work.
The second parameter is the end index (exclusive) and not the length of characters you need.

You should use java.net.URL to parse a URL.

try this test case script:

String urlStr = "https://xyz.xyz.com/project/492512/edit?project=1"
URL url = new URL(urlStr)

println "url.getProtocol(): ${url.getProtocol()}"
println "url.getHost()    : ${url.getHost()}"
println "url.getPath()    : ${url.getPath()}"
println "url.getQuery()   : ${url.getQuery()}"

List<String> pathComponents = url.getPath().split("/")
println "0 ${pathComponents[0]}"
println "1 ${pathComponents[1]}"
println "2 ${pathComponents[2]}"
println "3 ${pathComponents[3]}"

This will give you:

2022-11-16 21:29:53.189 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/parsingURL
url.getProtocol(): https
url.getHost()    : xyz.xyz.com
url.getPath()    : /project/492512/edit
url.getQuery()   : project=1
1 project
2 492512
3 edit
2022-11-16 21:29:53.830 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/parsingURL

1 Like

Thanks! It worked and I got the concept of substring as well.