How to find script execution machine details

Hi All,
I would like to know where the scripts is executing during the execution time.
Because I need to skip some steps if it is executing in the remote machine.

Thanks in advance

Try this:

String cname = System.getenv("COMPUTERNAME")
if(cname != "Einstein") {

  // do these steps when machine is NOT "Einstein"

}

Hi @Russ_Thomas,

I have tired the above scripts. But always cname contains the local machine name.

When I execute the scripts using remote option also cname displaying local machine name only.

That’s what I gave you.

If you want something else, change your question, please.

I need executing machine name.
If I am executing the scripts using the browsers then it should return current/local machine name.
But if I am executing the scripts in remote machine using remote option then it should return the remote machine name.

Can you please help me to find the current / remote machine name.

Please define what you mean by saying “machine name” here.
Any screenshot to indicate what you want to see?

Hi,

Local machine name means where katalon is installed
Remote machine name means where script is executing

Then, please define the word “Local machine name where katalon is installed”. How can you retrieve/observe it outside Katalon?

Looks like in fact you are executing Katalon on your local machine but using a remote machine browser (selenium grid or whatever else).
Is that correct?
If this is the case, the command from @Russ_Thomas won’t help.
It will work only if you actually execute katalon on a remote server/machine (through docker or a jenkins plugin or whatever else)

Perhaps you can retrieve somehow the execution profile in use from the test suite context … if i understand right what do you need.

Otherwise, you may have to somehow inject a script into the remote browser and grab the needed info from the output.
the actual machine name may not be possible to get but you may find some relevant info by digging into some network or browser data, see for example:

Now it becomes clear. Thank you.

No, it won’t.

Close enough.

@hariharakumar.kk I think what you need to do is use a predictive algorithm to figure out what the name of the target is. I don’t expect this is going to be easy. If you can give us as much info as you have at the outset of a suite, we may be able to help… a little.

Otherwise, like @bionel said, you need to execute Katalon remotely on the target, too. Anything you try to run remotely that reads stuff from the OS is likely to suffer security issues.

Like @bionel, I think your best bet is have the server inject something – but only if the server is working from the same domain as the AUT.

Any way I try to imagine a solution, it just gets messy.

at least will give a hint if the execution profile is local or remote.
and i am lazy to install katalon now, but grabing the name of the profile using a custom keyword should be trivial, plenty examples are available on the forum. the context is available to the test suite scope and contains lot of goodies if i remember it right

1 Like

Hi All,

Thanks for your support.
I have found the solution in another way. I am passing the projectName to the remote machine by adding the additional Desired Capabilities. While executing the script, I am retrieving the projectName value. If it has value then I am considering that script is executing in remote machine else it is executing in the local machine.

You can also retrieve certain goodies by using RunConfiguration API.
Something like this:

import com.kms.katalon.core.configuration.RunConfiguration

if (RunConfiguration.getExecutionProperties().drivers.system.size() == 0){
	host = RunConfiguration.getHostName()
} else {
	host = RunConfiguration.getExecutionProperties().drivers.system.Remote.remoteWebDriverUrl
}

println host

For a local execution i get:

2021-11-16 14:48:56.836 DEBUG testcase.New Test Case                   - 3: println(host)
myuser - localhost

using a pesudo remote address, i get:

2021-11-16 14:49:30.217 DEBUG testcase.New Test Case                   - 3: println(host)
some.remote.adress

there are also some other fields which you may find interesting:

[system:[Remote:[remoteWebDriverType:Selenium, remoteWebDriverUrl:www.google.ro, browserType:REMOTE_WEB_DRIVER]], preferences:[Remote:[:]]]
1 Like