Navigate to Relative URL

In selenium I could pass the base url as a parameter when executing it command line from a script.

In my test cases for navigate to url I would just put in relative urls for the target.

This way I can easily change my base url in one place and be able to test different websites for all my test cases.

You can use relative URL completely based on your current absolute URL. It will be simple like this:

WebUI.openBrowser(yourFullURL)

//Navigate to relativeURL based on your full URL
WebUI.navigateToURL(yourFullURL + '/view1')
1 Like

Vinh Nguyen said:

You can use relative URL completely based on your current absolute URL. It will be simple like this:

WebUI.openBrowser(yourFullURL)//Navigate to relativeURL based on your full URLWebUI.navigateToURL(yourFullURL + '/view1')

Doesn’t answert the question. How do you set the FullUrl from command line?

So in this case just create that FullURL as a GlobalVariables and use it

David Ay said:

In selenium I could pass the base url as a parameter when executing it command line from a script.

In my test cases for navigate to url I would just put in relative urls for the target.

This way I can easily change my base url in one place and be able to test different websites for all my test cases.

Why did you decide to use selenium instead of katalon?

I’ve just recently hit the same issue. There is basically a “hole” in the hierarchy and scoping mechanism provided by Katalon which I hope they fix:

There needs to be a way to create variables that have suite-scope. GlobalVariables are project-scope, test-case variables are local to a test case, but we need a scope that is maintained across an entire suite. Only then will writing test suites which work across multiple domains become easy.

This:

WebUI.openBrowser(yourFullURL)//Navigate to relativeURL based on your full URLWebUI.navigateToURL(yourFullURL + '/view1')

does not work. There is no way to communicate the dynamic value in yourFullURL to 2, 3, N, different suites. We need Suite-Scope variables.

As a workaround, is there a way to use:

@SetupTestCase(skipped = false)
def setupTestCase() {
  TARGET_URL = "https://mysite.com/"
}

And then, in a test case, reference TARGET_URL?

That script worked for me. Thanks.

You should go to Global variables and set up :

Name: yourFullURLValue: enter your basic urlAfter that you will be able to insert this code in test case:
WebUI.openBrowser(yourFullURL)WebUI.navigateToURL(yourFullURL + 'view1')where 'view1' is page path

Russ Thomas said:

I’ve just recently hit the same issue. There is basically a “hole” in the hierarchy and scoping mechanism provided by Katalon which I hope they fix:

There needs to be a way to create variables that have suite-scope. GlobalVariables are project-scope, test-case variables are local to a test case, but we need a scope that is maintained across an entire suite. Only then will writing test suites which work across multiple domains become easy.

This:

WebUI.openBrowser(yourFullURL)//Navigate to relativeURL based on your full URLWebUI.navigateToURL(yourFullURL + '/view1')

does not work. There is no way to communicate the dynamic value in yourFullURL to 2, 3, N, different suites. We need Suite-Scope variables.

You can put the URL in a data file and bind it to the test case in the suite, as a workaround

Ibus said:

You can put the URL in a data file and bind it to the test case in the suite, as a workaround

Or, do like I did and import all your “globals” from an external json file and manage the file yourself.

Russ Thomas said:

Ibus said:

You can put the URL in a data file and bind it to the test case in the suite, as a workaround

Or, do like I did and import all your “globals” from an external json file and manage the file yourself.

Yes, that is also an option, i use it for a different case,.

But I am not importing globals, I created a dummy test data with default values and i am parsing it before the execution to replace with the actual values. This can be used on globals file too, is just an xml

Kudos 4u! Thanks a lot!