Warning- "SAPEdit" description mismatch, " The object was not found using the test object description.Check the object properties - hp-uft

I'm a new entrant to UFT and while i'm trying to access the columns of a webtable, to identify the test object "SAPEdit", UFT takes a longer time and throws a warning "SAPEdit" -description mismatch. The object was not found using the test object description.Check the object's properties. Kindly suggest me a workaround to clear this warning and speed up the test object identification. BTW, i'm not using descriptive programming.
Code follows:
strPENXPath = strTblXPath & "/TBODY[1]/TR[" & iRow & "]/TD[1]/SPAN[1]/INPUT[1]"
Browser("SAP Transaction iView").Page("SAP Transaction iView").SAPFrame("Child Care Quota Program_2").SAPEdit("SAPEdit").SetTOProperty "xpath", strPENXPath
oPersonnelNo = Browser("SAP Transaction iView").Page("SAP Transaction iView").SAPFrame("Child Care Quota Program_2").SAPEdit("SAPEdit").GetROProperty("value")
If iPersonnelNo <> oPersonnelNo Then
strMessage=strMessage & "Failed -Personnelno Type "
End If

This means that the object's description doesn't match an object in your application.
There are several ways to fix this problem.
Probably the simplest one is to Maintenance Run Mode.
From the Run menu select Maintenance Run Mode... then when UFT will see an object it can't find it will ask you to point at the object and then it will suggest a solution.

Related

UFT Report is broken

Lately we are getting more and more often confronted with problems with UFT. Many API components can't executed anymore, but there are 2 possible outputs:
UFT gives a message from "object reference not set to an instance of an object" without even starting the test, let alone reporting. The Output Pane contains the following message:
Start
object reference not set to an instance of an object
End
when we execute a test using ALM we get a KeyNotFoundException:
2020-01-22 12:04:38,039 HP.ST.Fwk.ReporterFWK.Reporter [ 1] ERROR Problem in writing Step Xml
System.Collections.Generic.KeyNotFoundException: The specified key was not listed in the dictionary.
For System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
for HP.ST.Fwk.ReportCreator.QTPEngine.Utils.GetNodeInfo(Object stepId, XmlDocument xmlDoc, IReportDataContainer reportData)
for HP.ST.Fwk.ReportCreator.QTPEngine.CPNodeWriter.CreateOuterCheckpointsXML(Object stepId, XmlDocument doc, XmlNode node, String innerCheckpointsFileName, String childId, IReportDataContainer reportDataContainer)
for HP.ST.Fwk.ReportCreator.QTPEngine.CPNodeWriter.CreateFileForReferencedValues(XmlDocument doc, XmlNode& reportNode, Object stepId, IReportDataContainer reportDataContainer)
for HP.ST.Fwk.ReportCreator.QTPEngine.CPNodeWriter.CreateXmlFile(Dictionary`2 nodeInfo, Object stepId, XmlDocument doc, IReportDataContainer IReportDataContainer)
for HP.ST.Fwk.ReporterFWK.Reporter.WriteStepToDisk(String stepId, String fileName)
for HP.ST.Fwk.ReporterFWK.Reporter.<>c__DisplayClass36_0.<FlushReport>b__0()
for System.Threading.Tasks.Task.InnerInvoke()
for System.Threading.Tasks.Task.Execute()
We've tried every direction, reinstalling UFT, patching... all to no avail. The behavior seems to be present in both UFT 14.53 and UFT 14.53 Patch 1 - 3. UFT One is also affected.
The UFT support could not help us at all, you know how they are.

How can we get the value of textbox in QTP?

I am executing the automated test scripts in UFT 12.5 I am new to UFT. Not very familiar with codes.There is an edit box wherein i have to type the value "S05292". Example:
Browser(Browsername").Page("Pagename").WebEdit("ctl00$ConBody$txtPDNumber").Set "S05292"
The problem is my script fails at this step and does not type the value. Can somebody provide me with a solution which is easy to understand. I tried the below two methods
Method (1)
a=Browser().page().webedit(ctl00$ConBody$txtPDNumber).getroproperty("value")
if a=="S05292" then
msgbox ("displayed message is S05292")
else
msgbox ("msg is not S05292")
end if
Method (2)
x = Browser("Browsername").Page("Pagename").Webedit("ctl00$ConBody$txtPDNumber").GetROProperty("value")
msgbox x
The error message that displays is
Cannot identify the object "ctl00$ConBody$txtPDNumber" (of class WebEdit).
Verify that this object's properties match an object currently displayed in your application.
Use the Object Spy to get the properties of that text box at run time and then make sure they match up to the properties of that text box in your object repository that you defined. Perhaps that don't match up or you didn't uniquely identify that text box.
If you don't want to use an object repository then you have to pass it a property at run time to uniquely identify it. Some thing like:
Browser().page().webedit("developer name:=PDNumber").
Instead of a .set you can do a .type to set/type the value into the text box

Need help for HP UFT -- Vb Script code

Firstly, I will give you some idea about what I am doing. I writing a few test cases without a framework, so for this I am creating a VBS file in which have written a code for launching of the UFT and opening of the action have created. Code is like this:
Set qtApp= CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True
Set qtTest = qtApp.Test
'And then call your scripts one after another
qtApp.Open "D:\UFT\TestScript\Function_Demo",true
Set qtTest = qtApp.Test
qtTest.Run
Also have created functions for each scenario which are associated with this Action, so whenever VBS file will be triggered by third system it will launch UFT and open the Action in which I am calling all the functions, so here comes my first question
How can I set the priority of the function so that it will run in sequence?
Also I wanted to write code for the result status as pass and fail and depending on the pass and fail status I wants to update the XML specific nodes with the status and also along with this wants to capture the screenshot of the test case whenever it's failed and for this also have to update the path in XML nodes.
As I am very new to the UFT so was not sure how to do this can someone please help me with this? How to write the code and what all things will be required?
Quick response will be appreciated.
Regarding Function Priority :-
Function in Test Action always takes priority over any other function with same name in any other function libs.
Second Priority is Function from Lib which is executed last[if u using loadfunctionlib or executefunctionlib]
Regarding XML specific nodes :-
Look for Res/Report/results.xml Summary Node
ex :- Summary sTime="*************" eTime="**************" passed="128" failed="2" warnings="36" /Summary
Question 2: UFT provides a function to update the results:
Reporter.ReportEvent micPass, "Step 1", "This step has passed. The object was found"
Reporter.ReportEvent micFail, "Step 1", "This step has failed. The object was not found"
it also provides a function to store the screenshot of the enire desktop
Desktop.CaptureBitmap "C:\Temp\HP-UFT-Test.png",true
Reporter.ReportEvent micFail, "Step", msg, "C:\Temp\HP-UFT-Test.png"
Its also possible to capture a screenshot of specific, objects for instance:
WpfWindow("SAP Work Manager").CaptureBitmap "C:\Temp\HP-UFT-Test.png",true
Reporter.ReportEvent micFail, "Step", msg, "C:\Temp\HP-UFT-Test.png"

Creating a view and agent in multiple databases

The problem I am encountering is that some of the messages are not accessible by the user ID file, I would like to skip these files instead of the agent crashing out. The error message received is as follows:
Using the view approach if this happened I was able to delete the document temporarily and re-run the agent but if there is a way to skip documents it would be a great help.
Thanks for the help guys.
Ok I have amended the code to a point where I am almost comfortable with it.
Sub Initialize
Dim s As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim doc As notesdocument
Dim nextdoc As notesdocument
Set db = s.currentdatabase
If view Is Nothing Then
Set view = db.CreateView("Encrypted",{Encrypt="1"})
End If
Set doc = view.getfirstdocument
On Error Goto ErrorHandler
While Not doc Is Nothing
nextDocument:
Set nextdoc = view.getnextdocument(doc)
'The below loop is mandatory to ensure that all $File entries are unecrypted
Forall i In doc.items
If i.isencrypted Then
i.isencrypted=False
End If
End Forall
'Must have at least 1 field encrypted in order to call Encrypt method
Dim temp As New NotesItem(doc,"tempjunk","temp")
temp.IsEncrypted=True
Call doc.encrypt
Call doc.save(True, False)
'This portion can now remove the fields relative to encrypting the
'single token encrypted field.
Call doc.removeitem("$Seal")
Call doc.removeitem("$SealData")
Call doc.removeitem("SecretEncryptionKeys")
Call doc.removeitem("Encrypt")
Call doc.removeItem("tempjunk")
Call doc.save(True, False)
Set doc = nextdoc
Wend
Exit Sub
ErrorHandler:
On Error Resume nextDocument
Exit Sub
End Sub
The error handling is not playing nice;
On Error Resume nextDocument is showing up as an error.
I have tried suppressing all of the error warnings which seems to attempt to strip the encryption but I think they body of the messages is being destroyed as a result.
It is no problem to create an agent in a container database and let that agent access documents in all "target" databases and modify them accordingly - No need to copy that agent to all databases.
Only restriction: If the databases are on another server, then on the server security tab of the target server you have to enter the server with the container database as trusted server.
AND: If your agent runs longer than the allowed maximum run time for agents on the server, then it will be killed prematurely.
There is no need to create views in the target databases, you can use NotesDatabase.Search() to get the corresponding documents in the databases...
You can create views by copying them from another database. Say you create a view "Encrypted" in your db with the agent.
Then add a piece of code to get a handle of this view as a NotesDocument:
Dim dbThis As NotesDatabase
Dim viewTemplate As NotesView
Dim docView As NotesDocument
Set dbThis = s.currentDatabase
Set viewTemplate = dbThis.getView("Encrypted")
Set docView = dbThis.Getdocumentbyunid(viewTemplate.Universalid)
In the agent loop, test if view Encrypted exists, if not copy the "view template":
Set view = db.getview("Encrypted")
If view Is Nothing Then
Call docView.Copytodatabase(db)
Set view = db.getview("Encrypted")
End If
Finally, if you insist, a similar procedure might be used to copy the agent to all databases, but for me the idea of running the agent in one db sounds better.
Edited: In the view of full disclosure - of course you can create a view (I guess that was the original question).
If view Is Nothing Then
Set view = db.Createview("Encrypted", {Encrypt="1"})
End If
Or do one-shot dbSearch suggested by Torsten, with a good re-mark of Richard - if you intend to run your code several times - say if encrypted documents might get created again or re-encrypted, rather go for the view.
My method is a bit old fashioned (pre-dates availability of createView) and works well if you need more than selection formula, so you can pre-build a complicated view for re-use.
Performance-wise: whatever method you will choose either creating view using createView or copying from other db or doing dbSearch there is going to be a certain slow-down while the view gets built or dbSearch executes. Karl-Henry's approach will avoid this search/view build, but will be relatively slow if there are not many encrypted documents.
Whichever method you choose - here is a small tip to boost performance. Make your loops like this to release memory as you go; for example, assuming Karl-Henry's approach:
Dim doc1 as NotesDocument
Set doc = col.GetFirstDocument()
Do Until doc Is Nothing
Set doc1 = col.GetNextDocument(doc)
formname = doc.GetItemValue("Form")(0)
If IsElement(exclude(formname))=False Then
Call RemoveEncryption(doc) '*** Your function to remove encryption
End If
' releasing memory when processing thousands of documents improves performance and avoids crashes
Delete doc
Set doc = doc1
Loop
Now again, as you are talking only about migration (so one shot) of 20+ databases, the speed or implementation details should not be that critical.
If you have to process all (or almost all) documents in each database, you can use db.AllDocuments. It is more efficient than using db.Search() with an #All formula.
If you want to exclude certain documents, perhaps based on the form name, I would build a list of forms to exclude, and then use IsElement to check each document being processed against that list.
Dim exclude List As Boolean
exclude("FormA")=True
exclude("FormB")=True
Set col = db.AllDocuments
Set doc = col.GetFirstDocument()
Do Until doc Is Nothing
formname = doc.GetItemValue("Form")(0)
If IsElement(exclude(formname))=False Then
Call RemoveEncryption(doc) '*** Your function to remove encryption
End If
Set doc = col.GetNextDocument(doc)
Loop
Something like that. By the way, you can create the list as any data type. I just choose Boolean as it is a small data type, and that it makes the code easier to read. The IsElement() function just check if the element exists, it does not use the value you set.
You would wrap the code above in a function and call it once per database.
Appended answer, based on additional info in original question:
That should not be hard, just add error handling to your code.
Before you start to loop throung the document:
On Error Goto errHandler
Before you get the next document in the loop:
nextDocument:
At the end of your code:
Exit Sub
errHandler:
Resume nextDocument
End Sub
Try that.

QTP - if object exists in object repository

In QTP is there any way in the code to check to see if a specific object exists in the object repository. I have tried the following code:
If JavaWindow(className).JavaDialog(dialogName).Exist Then
doThisStuff
Else
doThisStuffInstead
End If
But from what I have gleamed from the Internets, this is similar to a isVisible method, only resulting in true if the specified object is currently visible. When I use the above code I receive a "JavaDialog object was not found in the Object Repository." Is there a method or any way to prevent this very error and check to see if the object does indeed exist?
Thank you for your time
I'm not sure what you're trying to accomplish here, one typically knows if an object exists in the object repository before using it. The doubt is usually whether there is a corresponding control in the AUT (Application Under Test).
If you really face the situation that sometimes the object is in the repository and sometimes it isn't (I can think of several ways for this to happen but none of them make much sense) then you can use VBScript's error handling mechanism.
On Error Resume Next ' Turn off error handling
' Just check if object is in repository, there's no need to do anything with it
Dim Exists: Exists=JavaWindow(className).JavaDialog(dialogName).Exist
If Err.Number <> 0 Then
doThisStuff 'Exists is still empty
Else
doThisStuffInstead ' Exists is properly set
End If
On Error Goto 0 ' Resume regular error handling
So, from the error you get, either the dialog that appears is different from the one you've stored in the repository or you don't have it there.
Have you checked it is really present in the Repository? You can try to just locate this element button.
Using the method of "if object not in the repository - skip the step" is not really a good idea. 1. Why would you want to skip the test/part of the test if the object was not saved in the repository?
2. If it's not there, so you need to make sure to store it.
I would assume that this "missing" object might have some values by which it's matched to the object from the repository different from test to test. You can tune the "matching" mechanism by manually setting the values by which you want QTP to locate it.

Resources