Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Appium Operations #4074

Merged
merged 18 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:UserControlsLib1="clr-namespace:Ginger.UserControlsLib" xmlns:Activities="clr-namespace:Ginger.Activities"
xmlns:UserControlsLib1="clr-namespace:Ginger.UserControlsLib" xmlns:Activities="clr-namespace:Ginger.Activities" xmlns:UserControls="clr-namespace:Ginger.UserControls"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Namespace usage seems correct.
Ensure “UserControlsLib1” is the final intended name and isn’t leftover from a temporary reference.

xmlns:Actions="clr-namespace:Ginger.Actions"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Expand All @@ -15,9 +15,9 @@
<UserControlsLib1:UCComboBox x:Name="xOperationNameComboBox" VerticalAlignment="Top" Width="250" Margin="10,0,0,0"/>
</StackPanel>

<StackPanel x:Name="xInputPnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="5,10,0,0" Visibility="Collapsed">
<StackPanel x:Name="xInputPnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="7,10,0,0" Visibility="Collapsed">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Panel visibility
“xInputPnl” margin was updated. Ensure consistent margin usage across other panels for a uniform look.

<Label x:Name="xInputLabelVE" Style="{StaticResource $LabelStyle}" Content="Input:"/>
<Actions:UCValueExpression x:Name="xInputVE" VerticalAlignment="Top" Width="320"/>
<Actions:UCValueExpression x:Name="xInputVE" VerticalAlignment="Top" Width="330"/>
Comment on lines +23 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Check margin consistency for xInputPnl.
Margin is set to “7,10,0,0,” differing slightly from other panels (often “5,10,0,0”). Consider standardizing for a uniform UI.

</StackPanel>

<StackPanel x:Name="xKeyPressPnl" HorizontalAlignment="Left" Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,10,0,0" Visibility="Collapsed">
Expand Down Expand Up @@ -61,9 +61,9 @@
<UserControlsLib1:UcLabel Content="Note: Andoid device will simulate FingerPrint, iOS devices will simulate FaceID" FontSize="9"></UserControlsLib1:UcLabel>
</StackPanel>

<StackPanel x:Name="xAppPnl" HorizontalAlignment="Left" Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,10,0,0" Visibility="Collapsed">
<StackPanel x:Name="xAppPnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="6,10,0,0" Visibility="Collapsed">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

AppPnl container
Make sure the panel’s margin and visibility logic remain consistent with other panels.

<Label Style="{StaticResource $LabelStyle}" Content="Application package:"/>
<Actions:UCValueExpression x:Name="xAppPackageVE" VerticalAlignment="Top" Width="205"/>
<Actions:UCValueExpression x:Name="xAppPackageVE" HorizontalAlignment="Left" VerticalAlignment="Center" Width="330" Margin="-1,5,0,0"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Refine negative margin
Using a negative margin can lead to unpredictable layout shifts.

- Margin="-1,5,0,0"
+ Margin="5,5,0,0"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Actions:UCValueExpression x:Name="xAppPackageVE" HorizontalAlignment="Left" VerticalAlignment="Center" Width="330" Margin="-1,5,0,0"/>
<Actions:UCValueExpression x:Name="xAppPackageVE" HorizontalAlignment="Left" VerticalAlignment="Center" Width="330" Margin="5,5,0,0"/>

</StackPanel>

<StackPanel x:Name="xPressPnl" HorizontalAlignment="Left" Orientation="Horizontal" DockPanel.Dock="Top" Margin="0,10,0,0" Visibility="Collapsed">
Expand All @@ -86,6 +86,30 @@
<Activities:UCValueExpression x:Name="xSwipeDurationTxtBox" HorizontalAlignment="Left" VerticalAlignment="Center" Width="160"/>
</StackPanel>
</StackPanel>

<StackPanel x:Name="xDeepLinkPnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="0,10,0,0" Visibility="Collapsed">
<Label Style="{StaticResource $LabelStyle}" Content="URL:" Margin="2,0,0,0"/>
<Activities:UCValueExpression x:Name="xURLPathTxtBox" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,0,0" Width="330"/>
</StackPanel>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

New Deep Link panel
This panel is well-labeled. Confirm that it only appears for “OpenDeeplink” action.

<StackPanel x:Name="xPushToDevicePnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="5,10,0,0" Visibility="Collapsed">
<Label Style="{StaticResource $LabelStyle}" Content="Device Target Folder:" Margin="-4,0,0,0"/>
<Actions:UCValueExpression x:Name="xPushFileNameTxtBox" HorizontalAlignment="Left" Margin="0,0,0,0" Width="330"/>
<Label Style="{StaticResource $LabelStyle}" Content="Local File Path:" Margin="-2,2,0,0"/>
<Actions:UCValueExpression x:Name="xPushtoDeviceFolderTxtBox" HorizontalAlignment="Left" VerticalAlignment="Center" Width="340" />
</StackPanel>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

PushToDevice panel
Consider standardizing the control names (e.g., “xPushFileNameTxtBox” vs “xPushtoDeviceFolderTxtBox”) for clarity.

<StackPanel x:Name="xPullFromDevicePnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="5,10,0,0" Visibility="Collapsed">
<Label x:Name="xFileNamebl" Style="{StaticResource $LabelStyle}" Content="Device File Path:" Margin="-4,0,0,0"/>
<Actions:UCValueExpression x:Name="xFileNameTxtBox" HorizontalAlignment="Left" Margin="0,0,0,0" Width="330"/>
<Label x:Name="xFilePathbl" Style="{StaticResource $LabelStyle}" Content="Local Target Folder:" Margin="-3,0,0,0"/>
<Actions:UCValueExpression x:Name="xPulltoFolderTxtBox" Width="340" />
</StackPanel>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

PullFromDevice panel
Check margin consistency and reevaluate naming (e.g., “xFileNameTxtBox” vs “xPulltoFolderTxtBox”).

<StackPanel x:Name="xSpecificPerformanceDataPnl" HorizontalAlignment="Left" Orientation="Vertical" DockPanel.Dock="Top" Margin="0,2,0,0" Visibility="Collapsed">
<Label Style="{StaticResource $LabelStyle}" Content="Data Type:" Margin="0,0,0,0"/>
<UserControlsLib1:UCComboBox x:Name="xDataTypeComboBox" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="4,-6,0,0" Width="250"/>
</StackPanel>
Comment on lines +97 to +100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Use consistent margins for xSpecificPerformanceDataPnl.
Currently set to “0,2,0,0,” which is slightly out of step with other default “5,10,0,0” or “5,5,0,0” usage.

<StackPanel x:Name="xDeviceRotationPnl" HorizontalAlignment="Left" Orientation="Horizontal" DockPanel.Dock="Top" Margin="5,10,0,0" Visibility="Collapsed">
<Label Style="{StaticResource $LabelStyle}" Content="Choose State: "/>
<UserControlsLib1:UCComboBox x:Name="xDeviceRotateComboBox" VerticalAlignment="Top" Margin="0,-2,0,0" Width="241"/>
</StackPanel>
</DockPanel>
</Page>

102 changes: 95 additions & 7 deletions Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ limitations under the License.

using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.CoreNET.Drivers.CoreDrivers.Mobile;
using Amdocs.Ginger.CoreNET.Drivers.DriversWindow;
using Amdocs.Ginger.Repository;
using Ginger.Actions.UserControls;
using Amdocs.Ginger.UserControls;
using Ginger.Drivers.DriversWindows;
using GingerCore;
using GingerCore.Actions;
using GingerCore.Drivers;
using GingerCore.GeneralLib;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;


namespace Ginger.Actions
{
/// <summary>
Expand All @@ -39,22 +45,25 @@ public partial class ActMobileDeviceEditPage : Page
ActMobileDevice mAct;
Context mContext;
bool isValueExpression;


public ActMobileDeviceEditPage(ActMobileDevice Act)
{
InitializeComponent();

mAct = Act;
mContext = Context.GetAsContext(Act.Context);

BindControls();
SetControlsView();
}

private void BindControls()
{
xOperationNameComboBox.Init(mAct, nameof(mAct.MobileDeviceAction), typeof(ActMobileDevice.eMobileDeviceAction), ActionNameComboBox_SelectionChanged);



xInputVE.Init(Context.GetAsContext(mAct.Context), mAct.ActionInput, nameof(ActInputValue.Value));

xAuthResultComboBox.Init(mAct, nameof(mAct.AuthResultSimulation), typeof(ActMobileDevice.eAuthResultSimulation), AuthResultComboBox_SelectionChanged);
Expand All @@ -66,9 +75,26 @@ private void BindControls()
xX2TxtBox.Init(Context.GetAsContext(mAct.Context), mAct.X2, nameof(ActInputValue.Value));
xY2TxtBox.Init(Context.GetAsContext(mAct.Context), mAct.Y2, nameof(ActInputValue.Value));

xPhotoSumilationTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(nameof(ActMobileDevice.SimulatedPhotoPath)), true, true, UCValueExpression.eBrowserType.File, "*", ValueTextBox_ClickBrowse);
xPhotoSumilationTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.GetOrCreateInputParam(nameof(ActMobileDevice.SimulatedPhotoPath)), true, true, UCValueExpression.eBrowserType.File, "*");


xDeviceRotateComboBox.Init(mAct, nameof(mAct.RotateDeviceState), typeof(ActMobileDevice.eRotateDeviceState), ActionNameComboBox_SelectionChanged);

xDataTypeComboBox.Init(mAct, nameof(mAct.PerformanceTypes), typeof(ActMobileDevice.ePerformanceTypes), ActionNameComboBox_SelectionChanged);

xPulltoFolderTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.LocalFile, nameof(ActInputValue.Value), true, true, UCValueExpression.eBrowserType.Folder, "*");

xPushtoDeviceFolderTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.LocalFile, nameof(ActMobileDevice.Value), true, true, UCValueExpression.eBrowserType.File, "*");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Improve naming consistency for folder textboxes.

The current names “xPulltoFolderTxtBox” and “xPushtoDeviceFolderTxtBox” partially use lowercase “to.” Renaming them to “xPullToFolderTxtBox” and “xPushToDeviceFolderTxtBox” would align better with typical CamelCase conventions.


xURLPathTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.ActionInput, nameof(ActInputValue.Value));

xFileNameTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.ActionInput, nameof(ActInputValue.Value));
xPushFileNameTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.ActionInput, nameof(ActInputValue.Value));

xAppPackageVE.Init(Context.GetAsContext(mAct.Context), mAct.ActionAppPackage, nameof(ActInputValue.Value));




xPressDurationTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.PressDuration, nameof(ActInputValue.Value));
xDragDurationTxtBox.Init(Context.GetAsContext(mAct.Context), mAct.DragDuration, nameof(ActInputValue.Value));
Expand Down Expand Up @@ -127,13 +153,14 @@ private void ValueTextBox_LostFocus(object sender, RoutedEventArgs e)
{
UpdateBaseLineImage();
}



private void ValueTextBox_ClickBrowse(object sender, RoutedEventArgs e)
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
string filePath = UpdateBaseLineImage();
ImportPhotoToSolutionFolder(filePath);
}
Comment on lines +144 to 148
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Add error handling for BrowseButton_Click.

Currently, the method silently fails if filePath is invalid or unreadable. Consider adding basic error handling or user feedback to manage such scenarios more gracefully:

private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
    string filePath = UpdateBaseLineImage();
+   if (string.IsNullOrEmpty(filePath))
+   {
+       Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "File path is invalid. Please recheck.");
+       return;
+   }
    ImportPhotoToSolutionFolder(filePath);
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
string filePath = UpdateBaseLineImage();
ImportPhotoToSolutionFolder(filePath);
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
string filePath = UpdateBaseLineImage();
if (string.IsNullOrEmpty(filePath))
{
Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "File path is invalid. Please recheck.");
return;
}
ImportPhotoToSolutionFolder(filePath);
}


private string UpdateBaseLineImage(bool firstTime = false)
{
string FileName = General.GetFullFilePath(xPhotoSumilationTxtBox.ValueTextBox.Text);
Expand Down Expand Up @@ -210,6 +237,16 @@ private void SetControlsView()
xDragPnl.Visibility = Visibility.Collapsed;
xSwipePnl.Visibility = Visibility.Collapsed;
xInputPnl.Visibility = Visibility.Collapsed;
xDeepLinkPnl.Visibility = Visibility.Collapsed;
xPushToDevicePnl.Visibility = Visibility.Collapsed;
xPullFromDevicePnl.Visibility = Visibility.Collapsed;
xSpecificPerformanceDataPnl.Visibility = Visibility.Collapsed;
xDeviceRotationPnl.Visibility = Visibility.Collapsed;






switch (mAct.MobileDeviceAction)
{
Expand Down Expand Up @@ -259,16 +296,67 @@ private void SetControlsView()
case ActMobileDevice.eMobileDeviceAction.SimulateBiometrics:
xAuthSimulationPnl.Visibility = Visibility.Visible;
break;
case ActMobileDevice.eMobileDeviceAction.OpenDeeplink:
xAppPnl.Visibility = Visibility.Visible;
xDeepLinkPnl.Visibility = Visibility.Visible;

break;
case ActMobileDevice.eMobileDeviceAction.CloseApp:
case ActMobileDevice.eMobileDeviceAction.OpenApp:
case ActMobileDevice.eMobileDeviceAction.IsAppInstalled:
case ActMobileDevice.eMobileDeviceAction.RemoveApp:
case ActMobileDevice.eMobileDeviceAction.QueryAppState:
xAppPnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.SetContext:
xInputLabelVE.Content = "Context to Set:";
xInputPnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.RunScript:
xInputLabelVE.Content = "Script:";
xInputPnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.StartRecordingScreen:
xInputLabelVE.Content = "Note: Max duration recording: 30 min.";
xInputVE.Visibility = Visibility.Collapsed;
xInputPnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.GetDeviceLogs:
case ActMobileDevice.eMobileDeviceAction.StopRecordingScreen:
xFileNamebl.Visibility = Visibility.Collapsed;
xFileNameTxtBox.Visibility = Visibility.Collapsed;
xFilePathbl.Content = "Save to Folder\\File:";
xPullFromDevicePnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.PushFileToDevice:
xPushToDevicePnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.PullFileFromDevice:
xFileNamebl.Visibility = Visibility.Visible;
xFileNameTxtBox.Visibility = Visibility.Visible;
xPullFromDevicePnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.SetClipboardText:
xInputLabelVE.Content = "Text:";
xInputPnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.GetSpecificPerformanceData:
xAppPnl.Visibility = Visibility.Visible;
xSpecificPerformanceDataPnl.Visibility = Visibility.Visible;
break;

case ActMobileDevice.eMobileDeviceAction.RotateSimulation:
xDeviceRotationPnl.Visibility = Visibility.Visible;
break;

}
}

Expand Down
26 changes: 21 additions & 5 deletions Ginger/Ginger/Drivers/DriversWindows/MobileDriverWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ limitations under the License.
using System.Windows.Media;
using System.Windows.Media.Imaging;


namespace Ginger.Drivers.DriversWindows
{
/// <summary>
Expand All @@ -62,12 +63,13 @@ public partial class MobileDriverWindow : Window
bool mWindowIsOpen = true;
bool IsRecording = false;

ObservableList<DeviceInfo> mDeviceDetails = [];

ObservableList <DeviceInfo> mDeviceDetails = [];

public MobileDriverWindow(DriverBase driver, Agent agent)
{
InitializeComponent();

mDriver = (IMobileDriverWindow)driver;
mAgent = agent;

Expand All @@ -78,7 +80,7 @@ public MobileDriverWindow(DriverBase driver, Agent agent)
SetDeviceDetailsGridView();
SetDeviceMetricsGridView();
}

private async void RefreshDetailsTable(object sender, RoutedEventArgs e)
{
await this.Dispatcher.InvokeAsync(async () =>
Expand Down Expand Up @@ -201,7 +203,13 @@ private void RemoveRectangle()
xHighlighterBorder.Height = 0;
xHighlighterBorder.Visibility = Visibility.Collapsed;
}

public void UpdateRotateIcon()
{
Dispatcher.Invoke(() =>
{
SetOrientationButton();
});
}
public void UpdateRecordingImage(bool ShowRecordIcon)
{
Dispatcher.Invoke(() =>
Expand Down Expand Up @@ -267,6 +275,13 @@ await this.Dispatcher.InvokeAsync(async () =>
}
break;

case DriverBase.eDriverMessageType.RotateEvent:


UpdateRotateIcon();

break;

case DriverBase.eDriverMessageType.RecordingEvent:
IsRecording = sender != null && (bool)sender;

Expand Down Expand Up @@ -1301,7 +1316,7 @@ private void AlloworDisableControls(bool toAllow)
}
}

private void SetOrientationButton()
public void SetOrientationButton()
{
try
{
Expand All @@ -1323,6 +1338,7 @@ private void SetOrientationButton()
}
}


private void DoContinualDeviceScreenshotRefresh()
{
Task.Run(() =>
Expand Down
1 change: 1 addition & 0 deletions Ginger/Ginger/Ginger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@
<ProjectReference Include="..\GingerPlugIns\GingerPlugIns.csproj" />
<ProjectReference Include="..\GingerUtils\GingerUtils.csproj" />
<ProjectReference Include="..\GingerWin64OsSupport\GingerWin64OsSupport.csproj" />
<ProjectReference Include="..\GingerWPFDriverWindow\GingerWPFDriverWindow.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading