Skip to main content

Posts

Showing posts from June, 2015

Handling Objects not recognized as standard type

While doing automation on UI, we will face lot of scenarios like Object not identified as expected type and will scratch our head how to simulate such object set, click, etc. We have some options to simulate actions on such controls using WScript.Shell or Mercury.DeviceReplay The only thing, we need to instruct the those APIs at whichposition exactly it need to perform the actions. You can do with absolute poistion: x = yourObject . GetROProperty ( " abs_x " ) + ( yourObject . GetROProperty ( " width " ) / 2 ) y = yourObject . GetROProperty ( " abs_y " ) + ( yourObject . GetROProperty ( " height " ) / 2 ) Set MerRply = CreateObject ( " Mercury.DeviceReplay " ) MerRply . MouseClick x + 5, y, LEFT_MOUSE_BUTTON You can use relative position: x = yourObject . GetROProperty ( " width " ) / 2 y = yourObject . GetROProperty ( " height " ) / 2 yourObject . Click x, y, LEFT_MOUSE_BUTTON If

UFT - Take full page screenshot by scrolling the page

'######################################################################################## 'This is navigate through the full page and taking individual screenshot of visible area '######################################################################################## Function TakeScreenshot Dim intScrolls, intScroll, strScrollPos Set pgApp = Browser ( " " ) .Page ( " " ) intScrolls = Round ( pgApp . RunScript ( " document.documentElement.scrollHeight / (screen.height) " ) , 2 ) If intScrolls < 1 Then intScrolls = - 1 pgApp . RunScript " window.scrollTo(0, 0); " Wait 1 Browser ( " " ) .CaptureBitmap " C:\screenshot0.png " , True For intScroll = 0 To intScrolls If Environment . Value ( " Browser " ) = " CHROME " Then strScrollPos = " scrollY " Else strScrollPos = " document.documentElement.scrollTop " End If If p