Configuring Proxy and setCapability for Chrome Driver

Hi, I have the following code, where I am setting up a Proxy and creating an instance of WebDriver. Which means I cannot use WEBUI keywords. My question is it possible to set these arguments [Proxy and ChromeOptions ] without creating an external instance of WebDriver?

Proxy proxy = new Proxy();
proxy.setAutodetect(false);
proxy.setHttpProxy(“localhost”);

ChromeOptions opt = new ChromeOptions();
opt .setCapability(CapabilityType.PROXY, proxy);
opt .setCapability(CapabilityType.ACCEPT_SL, true);
opt .addArguments("–ignore-error");
WebDriver driver = new ChromeDriver(opt );

Why do you avoid setting Proxy by GUI Project settings ?

Hi Kazurayam
Thank you for the message, right now I was reading one of your solutions" [Unknown error: cannot find Chrome binary] " Which may help me to take a different approach for this problem. [However may not work with callTestCase], Thank you.

’Why do you avoid setting Proxy by GUI Project settings ?’ - The proxy configuration is required only for a single Test Case and configuring GUI setting will apply globally [ In past I have also read you suggestion to add Condition to as per Test case Id (i believe) ] which can also help me however I was just trying to keep it specific to TC.

Then I guess that you would want to create, by your test case code, an instance of WebDriver with custom Proxy, wouldn’t you?

If my guess is right, I do not see why you ask the following question.

Thank you, yes I have created it with my Test code and it’s working as desired.

‘I do not see why you ask the following question.’
I was just wondering if there is anything that can be achieved by just configuring it in Setting, I was trying to it in Desired Cap [most probably I wasn’t configuring it right] which didn’t work, however, setting it up in code helped me. Once again thank you