首页 > 其他分享 >Selenium proxy setting for Chrome did not work

Selenium proxy setting for Chrome did not work

时间:2023-02-17 18:01:12浏览次数:41  
标签:settings Chrome work Selenium proxy using your

To set the proxy for Chrome using Selenium in C#, you can use the following code:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

var proxy = new Proxy
{
    Kind = ProxyKind.Manual,
    HttpProxy = "your_proxy:port",
    SslProxy = "your_proxy:port"
};

var options = new ChromeOptions();
options.Proxy = proxy;

var driver = new ChromeDriver(options)

Here, you create a Proxy object and set its HttpProxy and SslProxy properties to the host and port of your proxy server. Then, you create a ChromeOptions object and set its Proxy property to the Proxy object you just created. Finally, you create a ChromeDriver object and pass the ChromeOptions object to its constructor.

 

The proxy did not work, as Chrome is using proxy settings from your administrator

If you are seeing the message "Chrome is using proxy settings from your administrator" when trying to set the proxy settings in Selenium, it means that your Chrome browser is already configured to use a proxy server by your system administrator, and you won't be able to change the proxy settings using Selenium.

In this case, you have a few options:

  1. If you have access to the proxy server, you can try to configure it to allow traffic from your IP address without requiring authentication.

  2. You can try running your Selenium script on a machine that doesn't have a proxy configured in the system settings.

  3. You can try using a different browser or browser profile that doesn't have a proxy configured.

  4. You can contact your system administrator and ask them to either allow you to change the proxy settings or to provide you with a different IP address that is not restricted by the proxy server.

But there is no exception or warning from Selenium, I find this message from Chrome setting

If you're not seeing any exceptions or warnings in Selenium, but you're seeing the "using proxy settings from your administrator" message in Chrome, it's possible that the proxy settings are being set correctly in your Selenium code, but that there's another issue preventing Chrome from using them.

One possibility is that there are other proxy settings configured on your system that are taking precedence over the settings you're setting in your Selenium code. For example, if you're using a corporate network, there may be group policy settings or other network settings that are overriding your browser's proxy settings.

Another possibility is that your Chrome browser is using a different user profile than the one you're specifying in your Selenium code, and the proxy settings are set differently in that profile. You can check which profile Chrome is using by typing "chrome://version" into the address bar, and then looking for the "Profile Path" field.

To ensure that your proxy settings are being applied correctly, you can try running your Selenium code on a different machine or network to see if the issue persists. You can also try using a different browser, such as Firefox or Edge, to see if the issue is specific to Chrome. Finally, you can check with your system administrator or IT department to see if there are any network or proxy settings that might be affecting your browser's behavior.

 

 

标签:settings,Chrome,work,Selenium,proxy,using,your
From: https://www.cnblogs.com/chucklu/p/17131083.html

相关文章