Skip to content

Commit

Permalink
Merge branch 'master' into Feature/CentralizedDBReportLinkForALMs
Browse files Browse the repository at this point in the history
  • Loading branch information
Maheshkale447 authored Jun 8, 2024
2 parents ced2558 + a67dc09 commit 029ebff
Show file tree
Hide file tree
Showing 50 changed files with 2,978 additions and 152 deletions.
46 changes: 40 additions & 6 deletions Ginger/Ginger/Agents/AddAgentWizardLib/AddAgentDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Ginger="clr-namespace:Ginger"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="600"
Title="AddAgentDetailsPage">

<Grid Background="{StaticResource $BackgroundColor_White}">
<Grid.Resources>
<sys:Double
x:Key="HorizontalLabelWidth">65</sys:Double>
</Grid.Resources>
<StackPanel Margin="10,10,10,0" >
<StackPanel >
<Label Content="Name:" Style="{StaticResource @LabelStyle}"/>
Expand All @@ -22,19 +27,48 @@
</StackPanel>

<StackPanel x:Name="xDriverConfigStackPanel" Visibility="Visible">
<StackPanel Margin="0,10,0,0">
<Label Content="Platform :" Style="{StaticResource @LabelStyle}"/>
<StackPanel
Margin="0,10,0,0"
Orientation="Horizontal">
<Label
Content="Platform :"
Style="{StaticResource @LabelStyle}"
Width="{StaticResource HorizontalLabelWidth}" />
<ComboBox x:Name="xPlatformTypeComboBox" AutomationProperties.AutomationId="Platform Type AID" Width="250" HorizontalAlignment="Left" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="5,0,0,0" FontWeight="Bold" />
</StackPanel>

<StackPanel x:Name="xDriverTypeStackPanel" Margin="0,10,0,0">
<Label Content="Driver :" Style="{StaticResource @LabelStyle}"/>
<StackPanel
x:Name="xDriverTypeStackPanel"
Margin="0,10,0,0"
Orientation="Horizontal">
<Label
Content="Driver :"
Style="{StaticResource @LabelStyle}"
Width="{StaticResource HorizontalLabelWidth}" />
<ComboBox x:Name="xDriverTypeComboBox" AutomationProperties.AutomationId="Driver Type AID" Width="250" HorizontalAlignment="Left" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="5,0,0,0" FontWeight="Bold" />
</StackPanel>
<StackPanel x:Name="xDriverSubTypeStackPanel" Margin="0,10,0,0">
<Label Content="Type :" Style="{StaticResource @LabelStyle}"/>
<StackPanel
x:Name="xDriverSubTypeStackPanel"
Margin="0,10,0,0"
Orientation="Horizontal">
<Label
Content="Type :"
Style="{StaticResource @LabelStyle}"
Width="{StaticResource HorizontalLabelWidth}" />
<ComboBox x:Name="xDriverSubTypeComboBox" AutomationProperties.AutomationId="Driver SubType AID" Width="250" HorizontalAlignment="Left" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="5,0,0,0" FontWeight="Bold" />
</StackPanel>
<StackPanel
x:Name="BrowserTypePanel"
Margin="0,10,0,0"
Orientation="Horizontal"
Visibility="Collapsed">
<Label
Content="Browser :"
Style="{StaticResource @LabelStyle}"
Width="{StaticResource HorizontalLabelWidth}"/>
<ComboBox
x:Name="BrowserTypeComboBox" AutomationProperties.AutomationId="Browser Type AID" Width="250" HorizontalAlignment="Left" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="5,0,0,0" FontWeight="Bold" SelectionChanged="BrowserTypeComboBox_SelectionChanged" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
Expand Down
69 changes: 69 additions & 0 deletions Ginger/Ginger/Agents/AddAgentWizardLib/AddAgentDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ limitations under the License.

using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Drivers.CoreDrivers.Web;
using Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web;
using Amdocs.Ginger.CoreNET.RunLib;
using Amdocs.Ginger.Repository;
using GingerCore;
using GingerCore.GeneralLib;
using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib;
using GingerWPF.WizardLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -50,6 +55,7 @@ public AddAgentDetailsPage()
public void WizardEvent(WizardEventArgs WizardEventArgs)
{
mWizard = (AddAgentWizard)WizardEventArgs.Wizard;
PropertyChangedEventManager.AddHandler(mWizard.Agent, Agent_PropertyChanged, propertyName: string.Empty);
switch (WizardEventArgs.EventType)
{
case EventType.Init:
Expand Down Expand Up @@ -99,6 +105,28 @@ public void WizardEvent(WizardEventArgs WizardEventArgs)

}

private void Agent_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (string.Equals(e.PropertyName, nameof(Agent.DriverType)))
{
mWizard.Agent.AgentOperations.InitDriverConfigs();
if (mWizard.Agent.Platform == ePlatformType.Web && DriverSupportMultipleBrowsers(mWizard.Agent.DriverType))
{
PopulateBrowserTypeComboBox();
BrowserTypePanel.Visibility = Visibility.Visible;
}
else
{
BrowserTypeComboBox.Items.Clear();
BrowserTypePanel.Visibility = Visibility.Collapsed;
}
}
}

private bool DriverSupportMultipleBrowsers(eDriverType driverType)
{
return driverType == eDriverType.Selenium || driverType == eDriverType.Playwright;
}

private void xPlatformTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Expand All @@ -122,6 +150,47 @@ private void UpdateDriverTypeCombobox()
//mWizard.Agent.DriverInfo = DriversforPlatform[0];
xDriverTypeComboBox.SelectedItem = xDriverTypeComboBox.Items[0];
}

if (mWizard.Agent.Platform == ePlatformType.Web)
{
PopulateBrowserTypeComboBox();
BrowserTypePanel.Visibility = Visibility.Visible;
}
else
{
BrowserTypePanel.Visibility = Visibility.Collapsed;
BrowserTypeComboBox.Items.Clear();
}
}

private void PopulateBrowserTypeComboBox()
{
BrowserTypeComboBox.Items.Clear();
foreach (WebBrowserType browserType in GingerWebDriver.GetSupportedBrowserTypes(mWizard.Agent.DriverType))
{
BrowserTypeComboBox.Items.Add(new ComboEnumItem()
{
text = browserType.ToString(),
Value = browserType
});
}
BrowserTypeComboBox.SelectedValuePath = nameof(ComboEnumItem.Value);
BrowserTypeComboBox.SelectedIndex = 0;
}

private void BrowserTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count <= 0)
{
return;
}

WebBrowserType selectedBrowserType = (WebBrowserType)BrowserTypeComboBox.SelectedValue;
DriverConfigParam browserTypeParam = mWizard.Agent.GetOrCreateParam(nameof(GingerWebDriver.BrowserType));
if (!string.Equals(browserTypeParam.Value, selectedBrowserType.ToString()))
{
browserTypeParam.Value = selectedBrowserType.ToString();
}
}

private void xDriverTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down
6 changes: 3 additions & 3 deletions Ginger/Ginger/Agents/AgentDriverConfigPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ private void InitAgentDriverConfigs()
}
}

private void SetDriverConfigsPageContent()
public void SetDriverConfigsPageContent()
{
DriverBase driver = (DriverBase)TargetFrameworkHelper.Helper.GetDriverObject(mAgent);

if (driver.GetDriverConfigsEditPageName(mAgent.DriverType) != null)
if (driver.GetDriverConfigsEditPageName(mAgent.DriverType, mAgent.DriverConfiguration) != null)
{
DriverConfigurationGrid.Visibility = System.Windows.Visibility.Collapsed;
DriverConfigurationFrame.Visibility = System.Windows.Visibility.Visible;

//Custome edit page
string classname = "Ginger.Drivers.DriversConfigsEditPages." + driver.GetDriverConfigsEditPageName(mAgent.DriverType);
string classname = "Ginger.Drivers.DriversConfigsEditPages." + driver.GetDriverConfigsEditPageName(mAgent.DriverType, mAgent.DriverConfiguration);
Type t = Assembly.GetExecutingAssembly().GetType(classname);
if (t == null)
{
Expand Down
6 changes: 5 additions & 1 deletion Ginger/Ginger/Agents/AgentEditPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Grid Background="{StaticResource $BackgroundColor_White}">
<Grid.RowDefinitions>
<RowDefinition Height="160"/>
<RowDefinition Height="240"/>
<RowDefinition Height="260"/>
<RowDefinition Height="240*"/>
</Grid.RowDefinitions>

Expand Down Expand Up @@ -51,6 +51,10 @@
<Label Style="{StaticResource $LabelStyle}" Content="Driver Type:" Margin="0,0,0,0" VerticalAlignment="Center"/>
<ComboBox x:Name="xDriverTypeComboBox" Width="250" HorizontalAlignment="Left" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="25,0,0,0" FontWeight="Bold"/>
</StackPanel>
<StackPanel x:Name="BrowserTypePanel" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0" Visibility="Collapsed">
<Label Style="{StaticResource $LabelStyle}" Content="Browser Type:" Margin="0,0,0,0" VerticalAlignment="Center"/>
<ComboBox x:Name="BrowserTypeComboBox" Width="250" HorizontalAlignment="Left" Style="{StaticResource $FlatInputComboBoxStyle}" Margin="25,0,0,0" FontWeight="Bold" SelectionChanged="BrowserTypeComboBox_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0" x:Name="xVirtualAgentsPanel" Visibility="Visible">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Label Style="{StaticResource $LabelStyle}" Content="Support Virtualization:" Margin="0,0,0,0" VerticalAlignment="Center"/>
Expand Down
91 changes: 88 additions & 3 deletions Ginger/Ginger/Agents/AgentEditPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ limitations under the License.

using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Drivers.CoreDrivers.Web;
using Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Web;
using Amdocs.Ginger.Repository;
using Ginger.UserControlsLib;
using GingerCore;
using GingerCore.GeneralLib;
using GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using static GingerCore.Agent;
using System.Linq;

namespace Ginger.Agents
{
Expand All @@ -38,7 +42,7 @@ namespace Ginger.Agents
/// </summary>
public partial class AgentEditPage : GingerUIPage
{
Agent mAgent;
private Agent mAgent;
ePlatformType mOriginalPlatformType;
string mOriginalDriverType;
bool IsReadOnly, IsEnabledCheckBox;
Expand All @@ -58,6 +62,7 @@ public AgentEditPage(Agent agent, bool isReadOnly = false, bool ignoreValidation
if (agent != null)
{
mAgent = agent;
PropertyChangedEventManager.AddHandler(mAgent, Agent_PropertyChanged, propertyName: string.Empty);
CurrentItemToSave = mAgent;
xShowIDUC.Init(mAgent);
BindingHandler.ObjFieldBinding(xAgentNameTextBox, TextBox.TextProperty, mAgent, nameof(Agent.Name));
Expand Down Expand Up @@ -113,7 +118,30 @@ public AgentEditPage(Agent agent, bool isReadOnly = false, bool ignoreValidation
}
}
}

private void Agent_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (string.Equals(e.PropertyName, nameof(Agent.DriverType)))
{
mAgent.AgentOperations.InitDriverConfigs();
if (mAgent.Platform == ePlatformType.Web && DriverSupportMultipleBrowsers(mAgent.DriverType))
{
PopulateBrowserTypeComboBox();
BrowserTypePanel.Visibility = Visibility.Visible;
}
else
{
BrowserTypeComboBox.Items.Clear();
BrowserTypePanel.Visibility = Visibility.Collapsed;
}
}
}

private bool DriverSupportMultipleBrowsers(eDriverType driverType)
{
return driverType == eDriverType.Selenium || driverType == eDriverType.Playwright;
}

private void BetaFeatures_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if(e.PropertyName == nameof(BetaFeatures.ShowHealenium))
Expand All @@ -134,7 +162,19 @@ private void BetaFeatures_PropertyChanged(object? sender, System.ComponentModel.

private void UpdateHealeniumUI()
{
if (mAgent.DriverType == eDriverType.SeleniumRemoteWebDriver)
bool isSeleniumDriver = mAgent.DriverType == eDriverType.Selenium;
WebBrowserType? browserType = null;
if (mAgent.DriverConfiguration != null)
{
DriverConfigParam? browserTypeParam = mAgent.DriverConfiguration.FirstOrDefault(p => string.Equals(p.Parameter, nameof(GingerWebDriver.BrowserType)));
if (browserTypeParam != null && Enum.TryParse(browserTypeParam.Value, out WebBrowserType result))
{
browserType = result;
}
}
bool isRemoteBrowser = browserType.HasValue && browserType.Value == WebBrowserType.RemoteWebDriver;

if (isSeleniumDriver && isRemoteBrowser)
{
xHealeniumcheckbox.IsEnabled = true;
BindingHandler.ObjFieldBinding(xHealeniumcheckbox, CheckBox.IsCheckedProperty, mAgent, nameof(Agent.Healenium));
Expand Down Expand Up @@ -189,6 +229,16 @@ private void xPluginIdComboBox_SelectionChanged(object sender, SelectionChangedE

private void SetDriverInformation()
{
if (mAgent.Platform == ePlatformType.Web && DriverSupportMultipleBrowsers(mAgent.DriverType))
{
BrowserTypePanel.Visibility = Visibility.Visible;
PopulateBrowserTypeComboBox();
}
else
{
BrowserTypeComboBox.Items.Clear();
BrowserTypePanel.Visibility = Visibility.Collapsed;
}
List<object> lst = new List<object>();
foreach (eDriverType item in Enum.GetValues(typeof(eDriverType)))
{
Expand All @@ -213,6 +263,42 @@ private void SetDriverInformation()
}
}

private void PopulateBrowserTypeComboBox()
{
BrowserTypeComboBox.Items.Clear();

foreach (WebBrowserType browser in GingerWebDriver.GetSupportedBrowserTypes(mAgent.DriverType))
{
BrowserTypeComboBox.Items.Add(new ComboEnumItem()
{
text = browser.ToString(),
Value = browser
});
}
BrowserTypeComboBox.SelectedValuePath = nameof(ComboEnumItem.Value);
BrowserTypeComboBox.SelectedValue = Enum.Parse<WebBrowserType>(mAgent.GetParamValue(nameof(GingerWebDriver.BrowserType)));
}

private void BrowserTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count == 0)
{
return;
}

DriverConfigParam browserTypeParam = mAgent.GetParam(nameof(GingerWebDriver.BrowserType));
browserTypeParam.Value = ((WebBrowserType)BrowserTypeComboBox.SelectedValue).ToString();
if (xAgentConfigFrame.Content is AgentDriverConfigPage driverConfigPage)
{
driverConfigPage.SetDriverConfigsPageContent();
}

if (WorkSpace.Instance.BetaFeatures.ShowHealenium)
{
UpdateHealeniumUI();
}
}


private void driverTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Expand Down Expand Up @@ -243,7 +329,6 @@ private void driverTypeComboBox_SelectionChanged(object sender, SelectionChanged
else
{
mOriginalDriverType = xDriverTypeComboBox.SelectedItem.ToString();
mAgent.AgentOperations.InitDriverConfigs();
}
}
if (WorkSpace.Instance.BetaFeatures.ShowHealenium)
Expand Down
Loading

0 comments on commit 029ebff

Please sign in to comment.