How to store url obtained through "current url = WebUI.getUrl() " in test data(in Data files)

And how I input my url default profile variable into Test data?

the green bar indicated that the script ran without any error.

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI 
import internal.GlobalVariable as GlobalVariable 
File f = new File("./data.csv")
f.text = GlobalVariable.url + ",something\n"

Then you would find a file named “data.csv” in the project directory.

1 Like

I don’t understand this question. What do you want to do? Please restate it.


Do you want to update the “Test Data”?

As I wrote previously, the “Test Data” is read-only. Your test case script can not update the “Test Data”.

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
File f = new File(“./data.csv”)
f.text = GlobalVariable.url + “,something\n”

I added the code you mentioned to TS1 after designating it as TC3.
But I don’t know where the csv was saved… where is my Globalvariable.url?
“data.csv” can not be found…

The file should be found at <projectdir>/data.csv.

I am sure you would find it by Windows Explorer, or Mac Finder.

Do you want to see it in Katalon Studio?

While KS GUI opened, try F5 (Refresh). But, I know quite often the “Refresh” operation does not work in Katalon Studio GUI. See another post

In that case, you should close the project once, and reopen the project.

Yeh Finally I found it. thx for your reply

@kazurayam

I use the for function below to continuously issue new URLs and
I want to put the URL in a row in csv.
Which part should I fix?

for (def row = 1; row <= findTestData('New').getRowNumbers(); row++) {
    WebUI.click(findTestObject('Page_SSCSVNumatcheck/input_SS_SSnum'))

    WebUI.setText(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_SSnum'), findTestData('NEW').getValue(
            'a', row))

    WebUI.uploadFile(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SSCSV_csvFileSS'), findTestData('NEW').getValue(
            'c', row))

    WebUI.waitForAlert(5)

    WebUI.uploadFile(findTestObject('uploadObject/Page_SSCSVNumatcheck/input_CSV_csvFileNP'), findTestData('NEW').getValue(
            'd', row))

    WebUI.waitForAlert(5)

    WebUI.click(findTestObject('Object Repository/Page_SSCSVNumatcheck/input_SS_button'))

    WebUI.waitForPageLoad(60)

    WebUI.switchToWindowIndex(1 //switches to 2nd window
        )

    secondUrl = WebUI.getUrl()

    println('secondUrl: ' + secondUrl)

    GlobalVariable.url = WebUI.getUrl()

	WebUI.closeWindowIndex(1)
	
    WebUI.switchToWindowIndex(0)

    firstUrl = WebUI.getUrl()

    println('firstUrl: ' + firstUrl)
}

'Save the URL to csv.'
File f = new File('./data1.csv')

f.text = GlobalVariable.url

No way.
As I told you 2 times previously, you can not update the row variable as it is READ-ONLY.

I mean GlobalVariable to csv…


@kazurayam
I just want to get URL then return to csv.