Class ProxyInformation should be public

**OS : **Windows 7

Katalon Studio Version : 5.3.1.1

## Katalon Studio logs:

I think log is not necessary for this case

## Environment (for Web testing)

Browser : Firefox 52

## Environment (for Mobile testing)

## Steps to reproduce -

I have developed a set of Java classes as Custome Keyword. The keyword accepts a URL string as argument, makes HttpURLConnection object and do connect() itself. This keyword is designed to check accessibility of the URL.

package com.happymigration;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.URL;
import java.util.Optional;

public class HttpURLVerifier {
    private HttpURLVerifier() {}
    public static Optional<VerifiableHttpURLConnection> connect(String urlString) {
        try {
            URL url = new URL(urlString);
            return connect(url);
        } catch (MalformedURLException e) {
            return Optional.empty();
        }
    }

    public static Optional<VerifiableHttpURLConnection> connect(URL url) {
        HttpURLConnection conn = null;
        try {
            if (GlobalVariable.G_http_proxy_host != null && 
                GlobalVariable.G_http_proxy_port != null) {
                Proxy proxy = new Proxy(Proxy.Type.HTTP,
                    new InetSocketAddress(GlobalVariable.G_http_proxy_host,
                        Integer.parseInt(GlobalVariable.G_http_proxy_port)));
                conn = (HttpURLConnection) url.openConnection(proxy);
            } else {
                conn = (HttpURLConnection) url.openConnection();
            }
            conn.setRequestMethod("GET");
            conn.setConnectTimeout(10000);
            // will not follow REDIRECT
            conn.setInstanceFollowRedirects(false);
            // now try to GET the URL
            conn.connect();
            return Optional.of(new VerifiableHttpURLConnection(conn));
        } catch (ProtocolException e) {
            System.out.println(e);
            return Optional.empty();
        } catch (IOException e) {
            System.out.println(e);
            return Optional.empty();
        }
    }
}

## Actual Behavior -

I had to make HttpURLConnection capable of going through Proxy server of my organization. Therefore I added GlobalVariables to inform of Proxy settings.

if (GlobalVariable.G_http_proxy_host != null && GlobalVariable.G_http_proxy_port)

However I am aware that I put Proxy preference to Katalon Studio as the document says. https://docs.katalon.com/display/KD/Proxy+Preferences

I want my Custome Keyword refer to the Proxy preference set to the Katalon Studio, rather than duplicating the proxy info as GlobalVariables .

I check the Katalon API document https://api-docs.katalon.com/studio/v5.0/api/com/kms/katalon/core/configuration/RunConfiguration.html. In there I found RunConfiguration#getProxyInformation method is available. getProxyInfomation methos seems to return an instance of ProxyInfomation. I suppose the ProxyInformation instance contains information I need.

Howerver ProxyInformation class seems to be NOT public.

## Proposed Behavior -

I hope ProxyInformation class made public and accessible for my Java code as Custome Keyward.

## Screenshots / Videos

RunConfiguration.PNG

1 Like

The Release note of Katalon Studio v5.3.1 (https://docs.katalon.com/display/KD/Version+5.3.1) informs of

Support Proxy in Console Mode Execution

Then I would require the Proxy prefereces set by commandline arguments are also made public as ProxyInformation instance.

1 Like

kazurayam said:

The Release note of Katalon Studio v5.3.1 (https://docs.katalon.com/display/KD/Version+5.3.1) informs of

Support Proxy in Console Mode Execution

Then I would require the Proxy prefereces set by commandline arguments are also made public as ProxyInformation instance.

Hi kazurayam,

We have tested and able to get the proxy information. Refer to the code below


import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.network.ProxyInformation
ProxyInformation proxyInfo = new ProxyInformation();
proxyInfo = RunConfiguration.getProxyInformation()
println proxyInfo.proxyServerType

Thank you for using Katalon Studio,
Liam

Thank you for your reply.

The Katalon Studioa API documentation at https://api-docs.katalon.com/index.html does NOT include the com.kms.katalon.core.network package.

Is the API site outdated?

1 Like