Skip to main content

Posts

Showing posts from 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...

QTP - Object Identification - Prerequesties

While starting a new project or proof of concept or after new QTP installation, we would face the issue in identifying objects as QTP built objects like WinList, WebEdit, etc.; instead everything will be identified as WinObject. Here are some steps to ensure you did the environment setup RIGHT before start automating. Did you enabled required Add-ins only while launching Did you selected "Record >> Record and Run Settings" -  This should be based on what type of application you are working with Windows app - Windows >> Record and run test on any windows applications. Web app - Web >> Record and run test on any open browser. Did you tried to launch UFT/QTP and then AUT. If its web, ensure browser zoom level set to 100% Try disabling the protected mode in IE for web. Launch UFT and AUT using RUN AS ADMINISTRATOR Also see the Object Identification Methods if you are interested.

Handling auto populate, delayed masking and auto select fields

While doing automation, we could have come across the fields which will do the functionality like, 1. While entering some text, it will auto populate the matching values 2. While entering the text, it will mask the values i.e. convert to xxx.. or .... To simulate the functionality many of us could have faced problems while entering the values on the field; The value entered is not converting as masking text as it is doing while manual flow The form not accepting the entered values The entered/selected value not persists in the field after the simulation, etc. How to handle such controls effectively. Here we go; 1. WScript.Sendkeys Set shell = CreateObject ( "Script.Shell" ) Window ( "hwnd:=" & Browser ( "myApp" ) . GetROProperty ( "hwnd" ) ) . Activate 'if it's Browser obj . Set "" Wait 1 obj . FireEvent "OnFocus" Wait 1 shell . SendKeys "your value" , 1000 Wait 1 shell...

Error Handling in UFT - Contd...

See the basic post if you didn't. Error Handling in UFT Now you wonder, is there a way to implement inside our code. Here we go; Browser ( "myapp" ) . Page ( "myPage" ) . WebEdit ( "mytext1" ) . Set "someText1" If Err . Number < > 0 Then Reporter . ReportEvent micFail , "some step" , "some description" Err . Clear End If 'after handling the error, continue to next step Browser ( "myapp" ) . Page ( "myPage" ) . WebEdit ( "mytext2" ) . Set "someText2" If Err . Number < > 0 Then Reporter . ReportEvent micFail , "some step" , "some description" Err . Clear End If So the complexity is, we need to add the error check block after each step which is not good.So what can we do better is; Function CheckForError   Environment.Value("IsError") = False   If Err.Number <> 0 Then     Reporter.Repor...

Handling objects not visible on screen

Nowadays most of the web applications are built with different WEB 2.0 technologies and controls are loaded in different ways. While automating those pages, test developers normally will face the problems like; Object not Visible Not able to simulate the event on the object etc. If we debug the object, UFT's Exist or Selenium's elementPresent will return TRUE always but actually the control will not be in the screen. SO what is the deal here? Let us discuss how developers are loading the controls. 1. Basically developers will use Style property to make a control visible on screen or to hide like; control.Style.Display = "block" or "inline" or "" or "null" But the control will be always available in the source XML structure and thus UFT's Exist will always returns TRUE. 2. Sometimes, the source XML itself not available in the code and dynamically they form the HTML structure using JQuery, JavaScript, etc. and display ...

Why Automation? Why Tools? Where is it useful?

Nowadays everywhere automation, automation, automation... Most of the QA people talking about or willing to learn about UFT, Selenium, Webdriver, Appium, Perfecto, BDD, Cucumber, Specflow, etc... Lot of common questions keep on asked by us... 1. Is manual testing replaced with AUTOMATION CODE? 2. Most of the recruiters asking Do you any tools in today's market?  3. Is everything can be achieved by automation?     and so on... Let's discuss with the information we have and feel free to post your comments as well. FACT: Manual testing never replaced with automation code UNDERSTANDING: We cannot implement or code whatever a human tester will think or his intuitions: how a requirement should work. Automation will be useful where; 1. Bulk set of repeated tests to be executed for each release 2. Test should be executed for multiple set of inputs 3. Validation or comparison kind of task with huge set of data 4. Data generation, etc. Doing repeated tasks s...