@@ -117,12 +117,13 @@ export async function setWindow(this: NovaWindowsDriver, nameOrHandle: string):
117117 const elementId = await this . sendPowerShellCommand ( AutomationElement . rootElement . findFirst ( TreeScope . CHILDREN , condition ) . buildCommand ( ) ) ;
118118
119119 if ( elementId . trim ( ) !== '' ) {
120+ this . log . info ( `Found window with name '${ name } '. Setting it as the root element.` ) ;
120121 await this . sendPowerShellCommand ( /* ps1 */ `$rootElement = ${ new FoundAutomationElement ( elementId ) . buildCommand ( ) } ` ) ;
121122 trySetForegroundWindow ( handle ) ;
122123 return ;
123124 }
124125
125- this . log . info ( `Failed to locate window. Sleeping for 500 milliseconds and retrying... (${ i } /20)` ) ; // TODO: make a setting for the number of retries or timeout
126+ this . log . info ( `Failed to locate window with name ' ${ name } ' . Sleeping for 500 milliseconds and retrying... (${ i } /20)` ) ; // TODO: make a setting for the number of retries or timeout
126127 await sleep ( 500 ) ; // TODO: make a setting for the sleep timeout
127128 }
128129
@@ -149,12 +150,14 @@ export async function changeRootElement(this: NovaWindowsDriver, pathOrNativeWin
149150
150151 const path = pathOrNativeWindowHandle ;
151152 if ( path . includes ( '!' ) && path . includes ( '_' ) && ! ( path . includes ( '/' ) || path . includes ( '\\' ) ) ) {
153+ this . log . debug ( 'Detected app path to be in the UWP format.' ) ;
152154 await this . sendPowerShellCommand ( /* ps1 */ `Start-Process 'explorer.exe' 'shell:AppsFolder\\${ path } '${ this . caps . appArguments ? ` -ArgumentList '${ this . caps . appArguments } '` : '' } ` ) ;
153155 await sleep ( 500 ) ; // TODO: make a setting for the initial wait time
154156 for ( let i = 1 ; i <= 20 ; i ++ ) {
155157 const result = await this . sendPowerShellCommand ( /* ps1 */ `(Get-Process -Name 'ApplicationFrameHost').Id` ) ;
156158 const processIds = result . split ( '\n' ) . map ( ( pid ) => pid . trim ( ) ) . filter ( Boolean ) . map ( Number ) ;
157159
160+ this . log . debug ( 'Process IDs of ApplicationFrameHost processes: ' + processIds . join ( ', ' ) ) ;
158161 try {
159162 await this . attachToApplicationWindow ( processIds ) ;
160163 return ;
@@ -166,6 +169,7 @@ export async function changeRootElement(this: NovaWindowsDriver, pathOrNativeWin
166169 await sleep ( 500 ) ; // TODO: make a setting for the sleep timeout
167170 }
168171 } else {
172+ this . log . debug ( 'Detected app path to be in the classic format.' ) ;
169173 const normalizedPath = normalize ( path ) ;
170174 await this . sendPowerShellCommand ( /* ps1 */ `Start-Process '${ normalizedPath } '${ this . caps . appArguments ? ` -ArgumentList '${ this . caps . appArguments } '` : '' } ` ) ;
171175 await sleep ( 500 ) ; // TODO: make a setting for the initial wait time
@@ -176,6 +180,7 @@ export async function changeRootElement(this: NovaWindowsDriver, pathOrNativeWin
176180 const processName = executable . endsWith ( '.exe' ) ? executable . slice ( 0 , executable . length - 4 ) : executable ;
177181 const result = await this . sendPowerShellCommand ( /* ps1 */ `(Get-Process -Name '${ processName } ' | Sort-Object StartTime -Descending).Id` ) ;
178182 const processIds = result . split ( '\n' ) . map ( ( pid ) => pid . trim ( ) ) . filter ( Boolean ) . map ( Number ) ;
183+ this . log . debug ( `Process IDs of '${ processName } ' processes: ` + processIds . join ( ', ' ) ) ;
179184
180185 await this . attachToApplicationWindow ( processIds ) ;
181186 return ;
@@ -195,6 +200,7 @@ export async function changeRootElement(this: NovaWindowsDriver, pathOrNativeWin
195200
196201export async function attachToApplicationWindow ( this : NovaWindowsDriver , processIds : number [ ] ) : Promise < void > {
197202 const nativeWindowHandles = getWindowAllHandlesForProcessIds ( processIds ) ;
203+ this . log . debug ( `Detected the following native window handles for the given process IDs: ${ nativeWindowHandles . map ( ( handle ) => `0x${ handle . toString ( 16 ) . padStart ( 8 , '0' ) } ` ) . join ( ', ' ) } ` ) ;
198204
199205 if ( nativeWindowHandles . length !== 0 ) {
200206 const elementId = await this . sendPowerShellCommand ( AutomationElement . rootElement . findFirst ( TreeScope . CHILDREN , new PropertyCondition ( Property . NATIVE_WINDOW_HANDLE , new PSInt32 ( nativeWindowHandles [ 0 ] ) ) ) . buildCommand ( ) ) ;
0 commit comments