Save the current URL as a csv file(The URL changes after loading time)

I want to save the current URL as a csv file. However, a certain (loading) time is required to open the contents in the new URL and receive url.

I tried to contain the current URL 30 seconds later (after the loading time) in csv using the wait alert function. But it does not work. please let me know another way.

After the loading time, the url also changes.

@hojun.lee, maybe use WebUI.waitForPageLoad(30) before Get Url

I tried to use WebUI.waitForPageLoad(30) before Get Url… but It does not work.
What should be noted here is. The URL I want to obtain is to calculate an equation of something, and it takes 30 to 40 seconds to represent the calculated equation.
In addition, after the equation appears, the URL of the page changes.
However, when the changed URL is received as get url, url is contained before being changed.

Maybe wait for the calculation to complete:
Thread.sleep(60000) //60 seconds or
WebUI.delay(60) //60 seconds

It does not work too…

I think after pressing the “Send” button on the first web page, I go to the second web page, but "UI."When you use the code getURL, it seems to obtain the first web page URL, not the second web page URL. If you know how to obtain the URL of the second web page, please let me know.

Maybe try one of the following:
WebUI.switchToWindowIndex(1) or
WebUI.switchToWindowTitle(‘Page title’) or
WebUI.switchToWindowUrl(‘www.gmail.com’)

For example:

WebUI.switchToWindowIndex(1) //switches to 2nd window
secondUrl = WebUI.getUrl()
println("secondUrl: " + secondUrl)

To go back:

WebUI.switchToWindowIndex(0) //switches to 1st window
firstUrl = WebUI.getUrl()
println("firstUrl: " + firstUrl)

Check in the Console tab to see the results.

@Dave_Evers

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)

=============== ROOT CAUSE =====================
Caused by: org.openqa.selenium.InvalidArgumentException: invalid argument:

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

01-26-2022 04:56:52 午後 Test Cases/upload

Elapsed time: 1m - 47.402s

Test Cases/upload FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to upload

this is an error Reason