Need to launch a browser instance that uses a proxy

My automated tests use a proxy to ensure that the browser is not ip-authenticated. I need to do the same for the xk6-browser tests.
i used an example i found using playwright that supposedly launches it with proxy, but it does not work

here is the example of the code i used(scrubbed proprietary urls)

 const browser = chromium.launch({ headless: false, proxy: {
            server: 'http://apacheproxy02.my.example.org:80',
        }, });
    const page = browser.newPage();

Is this not supported yet ?

Hi @Jeet_S !

Unfortunately the proxy option is currently unimplemented, in the sense that it’s not being set when launching the browser. We have an issue open that relates to that and that you can use to track the availability of the feature.

Hi Team,

I amusing k6.exe v0.48.0 (commit/47c0a26798, go1.21.5, windows/amd64)

can we launch browser with proxy server setting

@arvindpatel5788

Could you try to launch the script with the K6_BROWSER_ARGS=“proxy-server=<proxy_host>:<proxy_port>” environment variable?
For me on linux it is working like this if I start a squid proxy on port 3128:

K6_BROWSER_HEADLESS=false K6_BROWSER_ARGS="proxy-server=127.0.0.1:3128" k6 run script.js

I hope it helps

2 Likes

Thanks @bandorko i need to skip few sites for proxy , can we pass it on BROWSER_ARGS

@arvindpatel5788
yes, you can like this:

K6_BROWSER_ARGS="proxy-server=127.0.0.1:3128,proxy-bypass-list=*k6.io*"

Here you can find possible command line arguments for chromium:
https://www.chromium.org/developers/design-documents/network-settings/

2 Likes

@bandorko what if i have a list of url to by pass

i tried

K6_BROWSER_ARGS=“proxy-server=127.0.0.1:3128,proxy-bypass-list=[k6.io,.okta.*,.google.com]”

is not working.
am i missing the syntax ?

proxy-bypass-list is a semicolon separated list according to the documentation: Network Settings

Try it with proxy-bypass-list=k6.io;.okta.*;.google.com

1 Like