Selenium & Java - specified proxy ignored

I am learning selenium testing and have encountered my first problem after few hours :D

Objective: add a proxy into my selenium program so that it will not access the internet straight from my router.

(Proxy- running tor browser on localhost. Works with other web scrapers smoothly)

The problem is, it seems like program does not see proxy settings or goes around it. Navigating program to "check ip" websites shows original ip, not changed one by proxy.

My code: [as in documentation https://www.selenium.dev/documentation/webdriver/http_proxies/]

Proxy proxy = new Proxy();
proxy.setHttpProxy("127.0.0.1:9150");
ChromeOptions options = new ChromeOptions();
options.setCapability("proxy", proxy);

Then I tried several other approaches found online (including a deprecated one)

/*String proxy = "127.0.0.1:9150";
ChromeOptions options = new ChromeOptions().addArguments("--proxy-server=http://" +proxy);
*/
            
/*String proxy = "localhost:9150";
Proxy p = new Proxy();
p.setHttpProxy(proxy);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, p);
*/

and then it goes into driver parameter (commented ones are using options and cap) WebDriver driver = new ChromeDriver(options);

Using the documentation code I do not get any error. It just does not change ip.

I tried everything I could think of but without success.

Notes:

  1. ip & port are correct
  2. websites are accessed after setting up proxy.
  3. using commented code (first block, two lines) returns "This site can’t be reached" in chrome and " org.openqa.selenium.WebDriverException: unknown error: net::ERR_TUNNEL_CONNECTION_FAILED" in console
  4. same code as note 3) but protocol changed to https "...https://" +proxy);" returns "No internet" in browser and "org.openqa.selenium.WebDriverException: unknown error: net::ERR_PROXY_CONNECTION_FAILED" in console
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum