@@ -332,6 +332,35 @@ public void TestOpenWithDefaultProgramByButton()
332332 ClosePeekAndExplorer ( ) ;
333333 }
334334
335+ /// <summary>
336+ /// Test copying file path to clipboard by clicking the copy path button
337+ /// </summary>
338+ [ TestMethod ( "Peek.CopyPath.ClickButton" ) ]
339+ [ TestCategory ( "Copy Path" ) ]
340+ public void TestCopyPathByButton ( )
341+ {
342+ string zipPath = Path . GetFullPath ( @".\TestAssets\7.zip" ) ;
343+
344+ // Open zip file with Peek
345+ var peekWindow = OpenPeekWindow ( zipPath ) ;
346+
347+ // Find and click the "Copy path" button
348+ var copyPathButton = FindCopyPathButton ( ) ;
349+ Assert . IsNotNull ( copyPathButton , "Copy path button should be found" ) ;
350+
351+ // Click the button to copy path to clipboard
352+ copyPathButton . Click ( ) ;
353+
354+ // Wait a moment for the clipboard operation to complete
355+ Thread . Sleep ( 500 ) ;
356+
357+ // Note: We can't directly test clipboard contents in UI tests due to security restrictions
358+ // The test verifies that the button exists and can be clicked without exceptions
359+ // The actual clipboard functionality is tested through the underlying ClipboardHelper
360+
361+ ClosePeekAndExplorer ( ) ;
362+ }
363+
335364 /// <summary>
336365 /// Test opening file with default program by pressing Enter key
337366 /// </summary>
@@ -862,4 +891,32 @@ private Element FindPeekWindow(string filePath, int timeout = 5000)
862891
863892 return null ;
864893 }
894+
895+ /// <summary>
896+ /// Helper method to find the copy path button with different AccessibilityIds depending on window size
897+ /// </summary>
898+ /// <returns>The copy path button element</returns>
899+ private Element ? FindCopyPathButton ( )
900+ {
901+ try
902+ {
903+ // Try to find button with ID for larger window first
904+ var button = Find ( By . AccessibilityId ( "CopyPathButton_Text" ) , 1000 ) ;
905+ if ( button != null )
906+ {
907+ return button ;
908+ }
909+ }
910+ catch
911+ {
912+ // Try to find button with ID for smaller window
913+ var button = Find ( By . AccessibilityId ( "CopyPathButton" ) , 1000 ) ;
914+ if ( button != null )
915+ {
916+ return button ;
917+ }
918+ }
919+
920+ return null ;
921+ }
865922}
0 commit comments