Sivakumar Velusamy
Katalon Apprentice
05/16/2018

Passing Proxy information using Test Listener

Hi Katalon Team,

Is it possible to pass the proxy information using the RunConfiguration?. I trying to do it with sampleBeforeTestSuite

def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
println testSuiteContext.getTestSuiteId()
RunConfiguration.setWebDriverPreferencesProperty("network.proxy.type", 1)
RunConfiguration.setWebDriverPreferencesProperty("network.proxy.http", "http://proxy.net")
RunConfiguration.setWebDriverPreferencesProperty("network.proxy.http_port", "8080")
RunConfiguration.setWebDriverPreferencesProperty("network.proxy.username", "username")
RunConfiguration.setWebDriverPreferencesProperty("network.proxy.password", "password")

also
RunConfiguration.proxyInformation.setProxyServerType("HTTP")
RunConfiguration.proxyInformation.setProxyServerAddress("http://proxy.net")
RunConfiguration.proxyInformation.setProxyServerPort("8080")
RunConfiguration.proxyInformation.setUsername("username")
RunConfiguration.proxyInformation.setPassword("password")

But it's not working. Kindly let me know the correct way to pass the information.

Thanks
Upvote
Quote

Comments

  • Vinh Nguyen
    Katalon Moderator
    05/17/2018
    Browser's connection settings are set before any execution including Test Listeners within a test script, so you can't pass your own settings like that. It should be passed BEFORE any 'Open Browser' step, e.g:

    def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
    println testSuiteContext.getTestSuiteId()
    RunConfiguration.setWebDriverPreferencesProperty("network.proxy.type", 1)
    RunConfiguration.setWebDriverPreferencesProperty("network.proxy.http", "http://proxy.net")
    RunConfiguration.setWebDriverPreferencesProperty("network.proxy.http_port", "8080")
    RunConfiguration.setWebDriverPreferencesProperty("network.proxy.username", "username")
    RunConfiguration.setWebDriverPreferencesProperty("network.proxy.password", "password")
    WebUI.openBrowser(URL)

    Upvote
    Quote
  • Sivakumar Velusamy
    Katalon Apprentice
    05/17/2018
    Thanks @"Vinh" for the reply. I tried setting the value as you have advised.

    Even I am getting the connection refused error. When I verified the log after setting the user preferences. Katalon is running the code with the proxyInformation which we set in the katalon studio preference  - katalon - Proxy. is it overriding the proxy information I have provided using RunConfiguration?

    Please find the log 

    05-17-2018 10:10:37 AM - [START]  - Start action : openBrowser
    10:10:38:493 >> Loading HP UFT Java Support (version 12.0.0.0) (SUN 1.8.0_102)
    05-17-2018 10:10:41 AM - [INFO]   - Opening browser
    05-17-2018 10:10:41 AM - [INFO]   - Starting 'Remote' driver
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['platform', 'LINUX']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['version', '']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['browserName', 'chrome']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['name', 'Siva5']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['network.proxy.type', '1']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['network.proxy.http', 'http://proxy.net']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['network.proxy.http_port', '8080']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['network.proxy.username', 'ProxyUsername']
    05-17-2018 10:10:41 AM - [INFO]   - User set preference: ['network.proxy.password', 'ProxyPassword']
    05-17-2018 10:10:41 AM - [INFO]   - Connecting to remote web server 'http://192.168.99.100:4444/wd/hub' with type 'Selenium'
    05-17-2018 10:10:41 AM - [INFO]   - Action delay is set to 0 seconds
    May 17, 2018 10:10:53 AM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS
    05-17-2018 10:10:53 AM - [RUN_DATA] - Logging run data 'sessionId' with value '8d75b00e6cfb2f72d013eebc0c8f09b5'
    05-17-2018 10:10:53 AM - [RUN_DATA] - Logging run data 'browser' with value 'Chrome 66.0.3359.170'
    05-17-2018 10:10:53 AM - [RUN_DATA] - Logging run data 'platform' with value 'Windows 7'
    05-17-2018 10:10:53 AM - [RUN_DATA] - Logging run data 'seleniumVersion' with value '3.7.1'
    05-17-2018 10:10:53 AM - [RUN_DATA] - Logging run data 'proxyInformation' with value 'ProxyInformation{proxyOption=NO_PROXY, proxyServerType=HTTP, password=, proxyServerAddress=, proxyServerPort=0}'
    05-17-2018 10:10:53 AM - [INFO]   - Navigating browser to: 'https://google.ca'
    Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
    05-17-2018 10:12:56 AM - [FAILED] - Unable to open browser with url: 'https://google.ca' (Root cause: org.openqa.selenium.WebDriverException: java.net.ConnectException: Connection refused (Connection refused)
    Command duration or timeout: 0 milliseconds)
    05-17-2018 10:12:56 AM - [FAILED] - Test Cases/SampleTestTable FAILED because (of) Unable to open browser with url: 'https://google.ca' (Root cause: org.openqa.selenium.WebDriverException: java.net.ConnectException: Connection refused (Connection refused)
    Command duration or timeout: 0 milliseconds)

    Upvote
    Quote
  • kazurayam
    Katalon Expert
    05/21/2018
    Once I have got a relevant issue at:
    https://forum.katalon.com/discussion/5873/katalon-studio-behind-proxy-is-unable-to-open-browser-on-browserstack
    I think Katalon Studio ver5.4.1 does not support communicating with Remote Selenium server over an organization's Proxy. The Katalon team replied: "We've added a ticket for it. It will be considered for efforts to fix it in later releases."
    Upvote
    Quote
Sign In or Register to comment.