@@ -4857,23 +4857,33 @@ public override void TakeScreenShot(ActScreenShot act)
48574857 {
48584858 try
48594859 {
4860- //TODO: Implement Multi window capture
4861- //not in use
48624860 if ( act . WindowsToCapture == Act . eWindowsToCapture . AllAvailableWindows )
48634861 {
4864- //FIXME
4865- }
4866- else
4867- {
4868- if ( CurrentWindow != null )
4862+ List < AppWindow > windows = GetListOfDriverAppWindows ( ) ;
4863+ foreach ( AppWindow aw in windows )
48694864 {
4870- using ( Bitmap tempBmp = GetCurrentWindowBitmap ( ) )
4865+ using ( Bitmap bmp = GetAppWindowAsBitmap ( aw ) )
48714866 {
4872- act . AddScreenShot ( tempBmp ) ;
4867+ if ( bmp != null )
4868+ {
4869+ act . AddScreenShot ( bmp ) ;
4870+ }
48734871 }
4872+ List < Bitmap > dialogs = GetAppDialogAsBitmap ( aw ) ;
4873+ foreach ( Bitmap dialogBmp in dialogs )
4874+ {
4875+ act . AddScreenShot ( dialogBmp ) ;
4876+ }
4877+ dialogs . Clear ( ) ;
4878+ }
4879+ }
4880+ else if ( CurrentWindow != null )
4881+ {
4882+ using ( Bitmap tempBmp = GetCurrentWindowBitmap ( ) )
4883+ {
4884+ act . AddScreenShot ( tempBmp ) ;
48744885 }
48754886 }
4876- return ;
48774887 }
48784888 catch ( Exception ex )
48794889 {
@@ -5039,66 +5049,66 @@ public UIAuto.AutomationElement GetLastFocusedElement()
50395049 public override async Task < List < ElementInfo > > GetVisibleControls ( )
50405050 {
50415051 return await Task . Run ( async ( ) =>
5042- {
5043-
5044- List < ElementInfo > list = [ ] ;
5045- List < ElementInfo > HTMLlist ;
5046-
5047- //TODO: find a better property - since if the window is off screen controls will not show
5048- try
5049- {
5050- UIAuto . Condition cond = new UIAuto . PropertyCondition ( UIAuto . AutomationElement . IsOffscreenProperty , false ) ;
5051- UIAuto . AutomationElementCollection AEC = CurrentWindow . FindAll ( Interop . UIAutomationClient . TreeScope . TreeScope_Descendants , cond ) ;
5052- string IEElementXpath = "" ;
5053-
5054- foreach ( UIAuto . AutomationElement AE in AEC )
5055- {
5056- if ( StopProcess )
5057- {
5058- break ;
5059- }
5060-
5061- UIAElementInfo ei = ( UIAElementInfo ) GetElementInfoFor ( AE ) ;
5062- if ( AE . Current . ClassName . Equals ( "Internet Explorer_Server" ) )
5063- {
5064- ei = ( UIAElementInfo ) GetElementInfoFor ( AE ) ;
5065- IEElementXpath = ei . XPath ;
5066- InitializeBrowser ( AE ) ;
5067- HTMLlist = await HTMLhelperObj . GetVisibleElement ( ) ;
5068- list . Add ( ei ) ;
5069- if ( HTMLlist != null && HTMLlist . Count > 0 )
5070- {
5071- list . AddRange ( HTMLlist ) ;
5072- }
5073- //foreach(ElementInfo e1 in HTMLlist)
5074- //{
5075- // list.Add(e1);
5076- //}
5077- }
5078-
5079-
5080- if ( String . IsNullOrEmpty ( IEElementXpath ) )
5081- {
5082- list . Add ( ei ) ;
5083- }
5084- else if ( ! ei . XPath . Contains ( IEElementXpath ) )
5085- {
5086- //TODO: Here we check if automation element is child of IE browser element
5087- // If yes then we skip it because we already have HTML element for this
5088- // Checking it by XPath makes it slow , because xpath is calculated for this element at runtime
5089- // Need to find a better way to speed up
5090- list . Add ( ei ) ;
5091- }
5092-
5093- }
5094- }
5095- catch ( Exception ex )
5096- {
5097- Reporter . ToLog ( eLogLevel . ERROR , "Failed to Get Controls" , ex ) ;
5098- }
5099-
5100- return list ;
5101- } ) ;
5052+ {
5053+
5054+ List < ElementInfo > list = [ ] ;
5055+ List < ElementInfo > HTMLlist ;
5056+
5057+ //TODO: find a better property - since if the window is off screen controls will not show
5058+ try
5059+ {
5060+ UIAuto . Condition cond = new UIAuto . PropertyCondition ( UIAuto . AutomationElement . IsOffscreenProperty , false ) ;
5061+ UIAuto . AutomationElementCollection AEC = CurrentWindow . FindAll ( Interop . UIAutomationClient . TreeScope . TreeScope_Descendants , cond ) ;
5062+ string IEElementXpath = "" ;
5063+
5064+ foreach ( UIAuto . AutomationElement AE in AEC )
5065+ {
5066+ if ( StopProcess )
5067+ {
5068+ break ;
5069+ }
5070+
5071+ UIAElementInfo ei = ( UIAElementInfo ) GetElementInfoFor ( AE ) ;
5072+ if ( AE . Current . ClassName . Equals ( "Internet Explorer_Server" ) )
5073+ {
5074+ ei = ( UIAElementInfo ) GetElementInfoFor ( AE ) ;
5075+ IEElementXpath = ei . XPath ;
5076+ InitializeBrowser ( AE ) ;
5077+ HTMLlist = await HTMLhelperObj . GetVisibleElement ( ) ;
5078+ list . Add ( ei ) ;
5079+ if ( HTMLlist != null && HTMLlist . Count > 0 )
5080+ {
5081+ list . AddRange ( HTMLlist ) ;
5082+ }
5083+ //foreach(ElementInfo e1 in HTMLlist)
5084+ //{
5085+ // list.Add(e1);
5086+ //}
5087+ }
5088+
5089+
5090+ if ( String . IsNullOrEmpty ( IEElementXpath ) )
5091+ {
5092+ list . Add ( ei ) ;
5093+ }
5094+ else if ( ! ei . XPath . Contains ( IEElementXpath ) )
5095+ {
5096+ //TODO: Here we check if automation element is child of IE browser element
5097+ // If yes then we skip it because we already have HTML element for this
5098+ // Checking it by XPath makes it slow , because xpath is calculated for this element at runtime
5099+ // Need to find a better way to speed up
5100+ list . Add ( ei ) ;
5101+ }
5102+
5103+ }
5104+ }
5105+ catch ( Exception ex )
5106+ {
5107+ Reporter . ToLog ( eLogLevel . ERROR , "Failed to Get Controls" , ex ) ;
5108+ }
5109+
5110+ return list ;
5111+ } ) ;
51025112
51035113 }
51045114
0 commit comments