Saturday, 21 December 2024

UFT Lesson Learnt

1. Where scripts are stored

Answer : Inside Action1 --> Script.mts

2. Where Password encoder tool is placed 

Answer : Start --> Program --> Micro Focus --> Micro Focused Unified Functional Testing --> Testing --> Tools --> Password Encoder 

3. Save the code before you run the code always because autosave feature is not available in UFT

4. Syntex of If Then Else

Answer : 

If  condition Then 

      statement 

ElseIf  condition Then

Else (optional)

End If

Tip : (1) use two tab indent for clear view of code

        (2) Each If should have one End If 

5.  Do not right click and select "execute from this line" inside a for loop

6.  .TSR is shared repository

7. To identify issue in the code / OR  run in maintenance  mode/Debug mode

8. If object spy is not able to recognize the element on the webpage do below 

    (1) Check proper add-ins are selected used in application

    (2) Ensure "Micro Focus Functional Testing Agent" is installed and enabled in browser

    (2) Restart the UFT  first 

    (3) Then Restart the application under test 

    (4) Reset the IE browser -->  Advance  -->  reset to default


9. Always Open shared OR in edit mode to add elements to it

10. Keep the naming conventions of OR objects consistent otherwise a lot of issues will occur later

Browser  - br

Page  - pg

Window -wn

Dialog - dg

Element - eml

Frame - frm

Table  - tbl 

Link - lnk

Button -btn

WebList - wl

TextBox - txt

CheckBox - chkBox

Image - img 


11. Update Run Mode : In case if Object Identification setting have been changed after adding object to the repository and if we want to reflect new settings on the existing objects instead of running manually you run in update mode mode. 

a) This works in the local repository only 

b) If  UFT is able to recognize the object, the new properties will not be updated.


12. To delete browser History --> Ctrl + Shift + Delete 

13. Use Wait(1) after each item selection from WebList to avoid sync issue

14. Create reusable function for 

  a) Navigation of all menus and Tree View

  b) fEnterData_BusinessCustomer()


15. Steps to automate 

a) Get all the test cases to automate 

b) Execute the test case manually two Times with same test data following the Jira steps to check the correctness of Jira steps and data dependency. If Jira steps are not correct ask the manual team to update the steps

c) Check the feasibility of automation of the test case . Remove from automation list if not feasible 

d) After creating the script, share the execution result with the manual team every day and get the signoff. If you receive any review comments, update the script accordingly and share the results again. 

e) First day execute first script , second day execute first and second script , third day execute first , second and third script in batch execution. This way keep executing the scripts to ensure all the previously developed scripts are working fine. 

16. Study all the scripts created by good team members and learn their reusable functions and style of coding. 

17. Meet with your automation team and show the reusable functions you created and scripts you created and discuss the issue you faced. 

18. If you are facing any issue or chanalge like technical , team issue, personal, emotional  ask for help in the team . 

19. If you see any error , try to find its root cause for eg. while running the script browser was crashing and trying to login again in Aperio application. and I was assuming it was coding error. 

20. How to toggle value in dropdown during each test. 

Answer (1) :  

CurrentDropDownValue = Browser("").Page("").WebList("").getROProperties("value")

If CurrentDropDownValue = "Medium" Then 

    NewSelection = "Low"

Else 

     NewSelection = "Medium"

End If

 

Browser("").Page("").WebList("").Select NewSelection 

Answer (2) :  SelectByIndex

Browser("").Page("").Select fGetRandNumerWithRange(1,15)

21. For each test result generate the test result in a separate file.  Do not create one bulk execution report. because separate test results are needed to upload in JIRA with each test case. Also, up to 10MB files can be uploaded in Jira. 

22. How to pass available value from  one function to another function

Answer : 

'Save value to Global Dictionary.

objDataDict("EmpName") = "Ravi"


'To Get Value from Global dictionary

strName = objDataDict("EmpName")


Tip: in fFunctionName(objDataDict) is must 


23. How to get future date 

Answer : DateAdd function

24. How to convert Date from one format to another format

Answer : create a function for that


25. After getting function date using 

DateAdd("m","4","MMDDYYYY")

the result will come with # like #12/22/2024#

to remove # use new date = CStr(DateWithHashHere)


26. Convert String to Double 

resultValue  = CDbl (StringValue)


27.  जब संकट में हों तो आगे और पीछे का विचार न करके जब जो एक काम करना है जो सबसे ज्यादा जरुरी है सिर्फ उसी पर ध्यान दो | एक एक करके सब काम हो जायेंगे और संकट दूर हो जाएगा | 


28.  If object is getting recognized from OR but while running the code it is not then create a new test  copy the code into it and run. 

29. Before the demo or delivery of the script run it continuously two times with the same test data without changing anything


30. User click OK button until navigated to given screen

Answer : 

do { Webutils.clickOKButton( button);

       }

While (WebUtils.CheckPageDisplay(Screen)!= True)


31.  Not able to select item from dropdown. Getting error after selecting the item. 

Answer : 

obj.WebList("Gender").Select "Male"

obj.WebList("Gender").FireEvent "onchange"


32. If object is not being recognized 

Answer : 

a) Enable Smart Identification in OR

b) Visual Relation Identifier in OR 


33. How to get the numeric number out of the below string 

str =  "902848   ravinder 16/12/1957"

Answer :  FirstPart = Split( str, " ") (0)

here output will be FirstPart  = 902848


34. Replace multiple spaces with single space 

Answer : 

cleanedStr = replace (inputStr , " ", " ")

'Replace until there are no more double spaces 

Do While InStr( cleanedStr , " ") > 0 

     cleanedStr  =  Replace ( cleanedStr , " " " ")

Loop


' Split the cleaned string and get the second part 

secondPart  = Split (cleanedStr , " ") (1)


35.  Pick a test you want to work on. Start the reverse timer and try to complete the task in the estimated time. This will keep you focused on the task.  Find out how much extra time you took then estimated and why. 

36. Keep a record of all the scripts you created with 

a) Start and End date 

b) Function used /created 

c) Issue / Pending items

d) Similar test scripts using a common function which can impact if changes are done in a common function. 


37. To find a string that exists in another string 

Answer : 

If InStr ( str1, str2) > 0  Then 

    msgbox "str2 found in str1"

End If


38. What should be the approach of refactoring 

Answer: Categorize the code in modules according to functionality like Navigation, entering data, put the code into functions with required parameters. Try to use a select case statement. 


39. While Entering data in the form contactName field data gets reset and not taking new data 

Answer:  Put 5 seconds wait after entering a value in each text field. 


40. Identify steps of a Test case, and create an independent function of each step . Call them as per requirement in the main function. 


41. Learn fast, Learn to Learn Fast 

42. To test a piece of code, place the code just after the loading of library files and excel sheet. It will save time by not executing the whole flow. 


43. Before Comparing two variables always Trim (UCase (CStr (variableName)))

44. Never assume that the script will run fine without executing continuously two times 

45. How to compare two variables with values 135 and 135.00

Answer : 

Trim ( CDbl (variable1)) = Trim (CDbl(variable2))


46. Open the Object repository only from the left-side tree view. Do not open from the Top menu > Resource > OR 


47. In a function fCreateUser contains multiple screens and in each screen, we have to enter values. In another case we need the same function but with one extra checkbox checked. What are the options to avoid creating a copy of the existing function to cater to the small change? 

Answer: 

a) Use a dictionary 

objDataDict("checkbox") = CheckboxON

If CheckboxON then 

  statement 

End If 


b) use Excel Input flag 

objDataDict.Item("checkbox") = "ON"

If objDataDict.Item("checkbox") = "ON" then 

  statement 

End If 

c) Use Wrapper Class 


48.  How to find a function being used in which all test scripts 

Answer: Go to script folder  --> Command prompt 

--> FindStr  /i /s "FunctionName"  *.mts


49. How to use the same function two times in a script that takes input data from an Excel sheet. While using the function a second time it takes a different set of data. 

FunctionName ("ProductName")

FirstTime  use of excel data   objDataDict("Name")


use the below line before calling the function again

SecondTime  use of excel data   objDataDict("Name1") = objDataDict("Name2")


50. Regular expression to have keyboard SAVINGS in a string is   

.* SAVINGS.*


51. While entering data in a text box it is working in debug mode but not working while running the script. Adding wait is also not working. The text box is also getting highlighted. 

Answer:  Add the text box again in OR. 

52. Do not use i=i+1 in the FOR NEXT  loop if not required

53. Do not touch the code written by others. It might break the working code written by others. 

 


No comments:

Post a Comment