UFT interview questions and answers

UFT exist method not working

In one of the projects, I found that even though element was present, exist method was returning true. So I was confused as to why UFT was showing this behaviour. Also exist method timeout argument was also not working.

It turns out that exist method will return false if multiple objects are found with matching description and also timeout will not work in this case. So to fix the issue, I updated object properties so that UFT was able to identify the object uniquely.

SAP object not identified

Automation object model



Set uftApp = CreateObject("QuickTest.Application") 
  uftApp.Launch ' Start UFT One
  uftApp.Visible = True
  uftApp.Options.Run.RunMode = "Fast"
  uftApp.Open "C:guitest1", True 

'run settings 
Set uftTest = uftApp.Test
uftTest.Settings.Run.OnError = "NextStep"  
              

How to filter and export tests in ALM

In ALM 12.0 onwards, you can click on any folder in test plan. Then You will see Live analysis tab on right hand side. You can click on create graph link and then generate graph of tests based on fields like priority, assigned fields etc.

This operation can not be performed during run time

When you try to load library files in UFT using automation, you may encounter error saying "This operation cannot be performed during a run session". Sample code is given below which may throw this error.


Set qtApp = CreateObject("QuickTestApplication")
Set qtLibraries = qtApp.TestSettings.Resources.Libraries
If qtLibraries.Find("xyz.qfl") = -1 Then
  qtLibraries.Add "xyz.qfl", 1
End If 
              

To fix this issue, you can use LoadFunctionLibrary('xyz.qfl') function. Please do not use executefile function as it may behave incorrectly. Debugging is also better with LoadFunctionLibrary()

How to schedule tests for execution overnight

How to fix Synchronization issues

You can write a function like waitUntilElementIsDisplayed() that can wait for certain property value to become as desired one. e.g. We can wait until visible property of element changes from false to true.

How to load external environment file in uft


<Environment>
<Variable>
    <Name>UserName</Name>
    <Value>Salunke, Sagar</Value>
</Variable>
</Environment> 
              
You can load above file using below syntax.

Environment.LoadFromFile("C:ExtVariables.xml")
'then access it like below
val = Environment.Value("UserName") 
    

getROProperty not working when object is passed to function

getROProperty(propertyName) method is used to get property value at runtime. But when you pass the object to function and then call this method, you may get incorrect value. To fix this issue, do not pass the actual object to function. Instead pass the description object or Object name in OR and then inside the function, access the object and call getROProperty method.

Unable to select swingx.JavaList items

When trying to select an item from Swingx.JavaList, you get error saying "object is disabled".

How to fix "enable third party browser extensions" issue

When running tests on apps and browsers other than IE, you may encounter issue where test will fail saying "enable third party browser extension" option is not selected in Internet explorer. Steps performed on this browser may have unexpected results. It is recommended to select "tools - internet options - advanced - Enable third party browser extensions" option in Internet Explorer.

How to print all RO properties

To get more information of runtime object, you can use below code to print all properties and values of object.

set props = Browser("B1").GetAllROProperties()
For i = 0 To props.count - 1
  Print props(i).Name & ": " & props(i).Value
Next
              

What if you are unable to enter data in editbox

Sometimes what happens is after you enter text in editbox, suggestion list should be displayed. So this works manually but with UFT, you face issue that app assumes that data is not entered and says please enter data or error message like " this is a required field" is displayed. You can try below options.
  • Click editbox before entering data
  • Use Wscript.shell object's sendkeys method
  • Use fireevent method to fire onblur or onchange or oninput or onkeypress event
  • Press Tab key after setting the data in editbox
  • Scroll to element using Browser.Page.Webedit.Object.scrollIntoView(), then wait for 1 sec and then enter values using set method of webedit.
  • Record the editboxes using UFT and then use those recorded objects from OR

If click is not working, what would you do?

You can try below solutions.
  • You can try Browser.Page.Webedit.Object.scrollIntoView()
  • Try Setting the ReplayType to Mouse - Setting.WebPackage("ReplayType") = 2
  • Try this statement before click - Browser(browser).Sync
  • Try firing event - WebButton("name:=xyz").FireEvent "onclick"
  • Try clicking on parent element
  • Most of the times, click does not work due to synching issue. So UFT tries to click when page is loading. In such cases, element is clicked but click event is not fired. You can also try adding wait statement. e.g. Wait 5

How do you fix can not identify object error in UFT

Often we come across error saying "Cannot identify the object "xyz" (of class WebEdit). Verify that this object's properties match an object currently displayed in your application." You can try below solutions.
  • Obivous reason is that UFT is unable to find the object. So you need to check the object's properties and values in Object repository or check description properties are correct.
  • Sometimes, object propeties are correct but object's parent's properties are incorrect. So for example, if UFT is unable to find out the webedit, you need to check the properties/values of webedit, webpage (is title matching), frame (is element inside an Iframe), browser (is uft referring correct browser) etc.
  • Check object class is correct. e.g. is object's class Webedit or webelement?
  • In case you are using inline description programming, property values are by default considered as regular expressions. To mark value as "Not a regualr expression", you can try to use Description.Create() syntax as shown below.
    
    Set desc = Description.Create()
    desc("title").Value = "xyz*"
    desc("title").RegularExpression = false
                  

How to return object from function in vbscript

You need to use set keyword.
  • To return objects - set FunctionName = MyObject
  • To return primitives - FunctionName = value

UFT is executing script very slowly

Try below solutions.
  • Unload unused add-ins
  • Disable smart identification
  • Tools - Options - GUI Testing - Test Runs - Run mode set to Fast

How to fix - UFT identifying the chrome or edge browser as Object: Legacy window

You can try below things.
  • If browser's dev tools is open and then you spy the elements in page, UFT will identify the browser window as winobject chrome legacy window. To fix this, just close dev tools window.
  • Make sure that UFT extension is installed and enabled for the browser
  • First open UFT and then Browser

How to integrate the UFT with ALM?

Launch UFT using admin account(Run as an administrator). Then click on ALM connection in top menu. After that, you will need to enter the ALM credentials. If everything goes well, you will be connected to ALM successfully.

But in some cases, due to security policies at company, you will see error saying "failed to update components from server..failed hosting spider activex" This error occurs because sometimes system fails to install ALM platform loader msi file during first connection. In such case, you need to ask system administrator to whitelist this file so that installation is done correctly and at right place (program files). If you install platform loader in local data folder, it will still throw same error. So make sure that ALM platform loader msi file is whitelisted and installed in program files (C:\program files(x86)\Micro focus\ALM-platform Loader 16.0X).

How to save UFT test in ALM?

You will need to first integrate UFT with ALM as explained in answer of above question. Once ALM connection is successful, just click save as and then in dialog click ALM. It will show test plan directory in ALM. You can then save your test there.

Web development and Automation testing

solutions delivered!!