Skip to content

Commit

Permalink
Merge pull request #3735 from Ginger-Automation/Feature/ByPassProxy
Browse files Browse the repository at this point in the history
By Pass Proxy Feature
  • Loading branch information
manas-droid authored Jun 7, 2024
2 parents c55c8e8 + 26078bf commit 3eb8bdb
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Ginger/Ginger/Agents/AgentDriverConfigPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ limitations under the License.
using GingerCore;
using GingerCore.Drivers;
using GingerCore.GeneralLib;
using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib;
using System;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -45,6 +47,23 @@ public AgentDriverConfigPage(Agent agent, General.eRIPageViewMode viewMode = Gen
InitializeComponent();

mAgent = agent;

if (Agent.GetDriverPlatformType(mAgent.DriverType).Equals(ePlatformType.Web) && !mAgent.DriverConfiguration.Any((driverConfig)=>string.Equals(nameof(SeleniumDriver.ByPassProxy), driverConfig.Parameter)))
{
MemberInfo memberInfo = typeof(SeleniumDriver).GetMember(nameof(SeleniumDriver.ByPassProxy))[0];
var userConfigDesc = Attribute.GetCustomAttribute(memberInfo, typeof(UserConfiguredDescriptionAttribute), false) as UserConfiguredDescriptionAttribute;
var defaultVal = Attribute.GetCustomAttribute(memberInfo, typeof(UserConfiguredDefaultAttribute), false) as UserConfiguredDefaultAttribute;

mAgent.DriverConfiguration.Insert(1, new DriverConfigParam()
{

Parameter = nameof(SeleniumDriver.ByPassProxy),
Value = defaultVal?.DefaultValue ?? string.Empty,
Description = userConfigDesc?.Description ?? string.Empty,
});
}


mAgent.PropertyChanged += Agent_PropertyChanged;
_viewMode = viewMode;
InitAgentDriverConfigs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,23 @@ public override string GetDriverConfigsEditPageName(Agent.eDriverType driverSubT
}
}


[UserConfigured]
[UserConfiguredDescription("Proxy Server:Port")]
public string Proxy { get; set; }


[UserConfigured]
[UserConfiguredDefault("http://127.0.0.1;http://localhost;")]
[UserConfiguredDescription("Set multiple By Pass Proxy URLs separated with ';'|| By Pass Proxy works only when Proxy URL is mentioned")]
public string ByPassProxy { get; set; }


[UserConfigured]
[UserConfiguredDescription("Proxy Auto Config Url")]
public string ProxyAutoConfigUrl { get; set; }


[UserConfigured]
[UserConfiguredDefault("false")]
[UserConfiguredDescription("EnableNativeEvents(true) so as to perform native events smoothly on IE ")]
Expand Down Expand Up @@ -442,6 +451,11 @@ public override void StartDriver()
mProxy.SslProxy = Proxy;
mProxy.SocksProxy = Proxy;
mProxy.SocksVersion = 5;

if (!string.IsNullOrEmpty(ByPassProxy))
{
mProxy.AddBypassAddresses(AddByPassAddress());
}
}
else if (string.IsNullOrEmpty(Proxy) && AutoDetect != true && string.IsNullOrEmpty(ProxyAutoConfigUrl))
{
Expand All @@ -459,6 +473,7 @@ public override void StartDriver()
}
}


if (ImplicitWait == 0)
{
ImplicitWait = 30;
Expand Down Expand Up @@ -1124,21 +1139,35 @@ private string DriverServiceFileName(string fileName)
}
}

private string[] AddByPassAddress()
{
return ByPassProxy.Split(';');
}

private void SetProxy(dynamic options)
{
if (mProxy == null)
{
return;
}

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


options.Proxy = proxy;

switch (mProxy.Kind)
{
case ProxyKind.Manual:
options.Proxy.Kind = ProxyKind.Manual;
options.Proxy.HttpProxy = mProxy.HttpProxy;
options.Proxy.SslProxy = mProxy.SslProxy;

if (!string.IsNullOrEmpty(ByPassProxy))
{
options.Proxy.AddBypassAddresses(AddByPassAddress());
}

//TODO: GETTING ERROR LAUNCHING BROWSER
// options.Proxy.SocksProxy = mProxy.SocksProxy;
break;
Expand Down

0 comments on commit 3eb8bdb

Please sign in to comment.