UFT does not recognize webfile object - hp-uft

Application:
Recorded step:
Browser("DocumentIndex_2").Page("DocumentIndex").WebFile("files[]").Set "kk"
Object Repo:
Run time error:
Error Details Run Error - Step Cannot identify the object "files[]"
(of class WebFile). Verify that this object's properties match an
object currently displayed in your application. Description Cannot
identify the object "files[]" (of class WebFile). Verify that this
object's properties match an object currently displayed in your
application.
Object's physical description: miccommentproperty = Mercury Class =
WebFile Html Tag = INPUT
_xpath = //DIV/DIV/DIV/DIV/SPAN[normalize-space()="Select files"]/INPUT1 |Visible = -1 Type = file Name = files[] Html Id =
DHTML Class =
In Object Repository, I was able to highlight the object. I am not sure why UFT would not click the object during run time. How can I instruct UFT to click the object?

Related

how to invoke or get the sub-property value from Properties Tab in cypress

How to invoke the sub-property value from the properties tab. I need to get the value of the error.JPG in from Properties Tab
I tried with these different codes changes
cy.get('div [data-text-as-pseudo-element="error.JPG"]').invoke('prop','dataset').should('contain','error.JPG')
cy.get('div [data-text-as-pseudo-element="error.JPG"]').invoke('prop','dataset').should('contain','DOMStringMap')
cy.get('[data-text-as-pseudo-element="error.JPG"]').invoke('prop', 'dataset').then(dataset,()=>{
cy.wrap(dataset).invoke('prop','textAsPseudoElement').should('contain','error.JPG')
})
I'm getting Assertion Error
Timed out retrying after 4000ms: object tested must be an array, a map, an object, a set, a string, or a weakset, but domstringmap given
From HTMLElement.dataset
The dataset read-only property of the HTMLElement interface provides read/write access to custom data attributes (data-*) on elements. It exposes a map of strings (DOMStringMap) with an entry for each data-* attribute.
Your Cypress test can just treat it as a conventional attribute
cy.get('my-selector')
.should('have.attr', 'data-text-as-pseudo-element', 'error.JPG')
The tests you propose above are already complete with just this
cy.get('div[data-text-as-pseudo-element="error.JPG"]')
because the browser guarantees the attribute will be added to dataset.
If you want to work further with dataset in Javascript just chain the properties, e.g
cy.get('div[data-text-as-pseudo-element="error.JPG"]')
.should($el => {
const attrValue = $el[0].dataset.textAsPseudoElement
expect(attrValue).to.eq('error.JPG')
})

Any ar js multimarkers learning tutorial?

I have been searching for ar.js multimarkers tutorial or anything that explains about it. But all I can find is 2 examples, but no tutorials or explanations.
So far, I understand that it requires to learn the pattern or order of the markers, then it stores it in localStorage. This data is used later to display the image.
What I don't understand, is how this "learner" is implemented. Also, the learning process is only used once by the "creator", right? The output file should be stored and then served later when needed, not created from scratch at each person's phone or computer.
Any help is appreciated.
Since the question is mostly about the learner page, I'll try to break it down as much as i can:
1) You need to have an array of {type, URL} objects.
A sample of creating the default array is shown below (source code):
var markersControlsParameters = [
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-hiro.patt',
},
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-kanji.patt',
}]
2) You need to feed this to the 'learner' object.
By default the above object is being encoded into the url (source) and then decoded by the learner site. What is important, happens on the site:
for each object in the array, an ArMarkerControls object is created and stored:
// array.forEach(function(markerParams){
var markerRoot = new THREE.Group()
scene.add(markerRoot)
// create markerControls for our markerRoot
var markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, markerParams)
subMarkersControls.push(markerControls)
The subMarkersControls is used to create the object used to do the learning. At long last:
var multiMarkerLearning = new THREEx.ArMultiMakersLearning(arToolkitContext, subMarkersControls)
The example learner site has multiple utility functions, but as far as i know, the most important here are the ArMultiMakersLearning members which can be used in the following order (or any other):
// this method resets previously collected statistics
multiMarkerLearning.resetStats()
// this member flag enables data collection
multiMarkerLearning.enabled = true
// this member flag stops data collection
multiMarkerLearning.enabled = false
// To obtain the 'learned' data, simply call .toJSON()
var jsonString = multiMarkerLearning.toJSON()
Thats all. If you store the jsonString as
localStorage.setItem('ARjsMultiMarkerFile', jsonString);
then it will be used as the default multimarker file later on. If you want a custom name or more areas - then you'll have to modify the name in the source code.
3) 2.1.4 debugUI
It seems that the debug UI is broken - the UI buttons do exist but are nowhere to be seen. A hot fix would be using the 'markersAreaEnabled' span style for the div
containing the buttons (see this source bit).
It's all in this glitch, you can find it under the phrase 'CHANGES HERE' in the arjs code.

JavaEdit search function not locating visible element

I've got two library functions:
Function searchWindow(title)
Set searchWindow = Window("title:=" + title)
End Function
And
Function searchField(label)
Set searchField = JavaEdit("attached text:=" + label)
End Function
Here I'm testing them:
Environment.Loadfromfile("C:\UFTConstants\constants.ini")
Set loginFrame = searchWindow(Environment.Value("frameLogin"))
loginFrame.Click
Set userField = searchField("User ID / Ci-Usager")
userField.Set "test"
The first function works fine, and it's title property matches that of the application. However, the second will not find the text field, despite properties matching:
The error:
I've tried other properties as well, tagname, various class properties, as well as combinations of all three, and none are producing a find.
Any ideas?
First Update
As per request, full spy screencap:
The full line generated by the recording tool:
JavaWindow("Application Name").JavaDialog("Window Title").JavaEdit("User ID / Ci-Usager").Set "user"
However, when I try to re-create this programmatically, I get the same error, only for JavaWindow instead:
"Cannot identify the object [JavaWindow] of (class JavaWindow)..."
Possible Java set-up issue? This would not explain why recording can still locate Java objects, however.
Second Update
Here are the recognition properties:
I have ensured that all properties are set, still unable to locate.
Final Update
Ok, I've reduced the code to absolute barebones. No external constant file, no external library calls. I've copied the full extent of what is recorded in recording mode. I've printed each variable to ensure accuracy. I've included the full object hierarchy:
Set objWin = JavaWindow("label:=<redacted>")
objWin.SetTOProperty "to_class", "JavaWindow"
objWin.SetTOProperty "toolkit class", "javax.swing.JFrame"
MsgBox objWin.GetTOProperty("label")
MsgBox objWin.GetTOProperty("to_class")
MsgBox objWin.GetTOProperty("toolkit class")
Set objDialog = objWin.JavaDialog("label:=<redacted>")
objDialog.SetTOProperty "to_class", "JavaDialog"
objDialog.SetTOProperty "toolkit class", "<redacted>.LoginDialog"
MsgBox objDialog.GetTOProperty("label")
MsgBox objDialog.GetTOProperty("to_class")
MsgBox objDialog.GetTOProperty("toolkit class")
Set objEdit = objDialog.JavaEdit("attached text:=User ID / Ci-Usager")
objEdit.SetTOProperty "to_class", "JavaEdit"
objEdit.SetTOProperty "toolkit class", "javax.swing.JTextField"
MsgBox objEdit.GetTOProperty("attached text")
MsgBox objEdit.GetTOProperty("to_class")
MsgBox objEdit.GetTOProperty("toolkit class")
objEdit.Set "test"
Note the redacted text is to remove identifying elements from the code. They have been triple-checked on my side and are correct.
This still does not work.
However, recording the same does. What gives?
I think you have to mention the full hierarchy while working with the Javaedit field. Try re-writing the code for the function searchField as :
Function searchField(label)
Dim objFrame
Set objFrame = searchWindow(Environment.Value("frameLogin"))
Set searchField = objFrame.JavaEdit("attached text:=" + label) 'Javaedit should be the child of the login window. You had to mention the full hierarchy here
End Function

Getting model value and generated ID from within simple_form custom input

I'm trying to make a custom input type with simple_form that will implement combobox-type functionality using jQuery-Autocomplete
. What I need to do is output a hidden field that will hold the ID of the value selected and a text field for the user to type in.
Here's what I have so far:
class ComboboxInput < SimpleForm::Inputs::Base
def input
html = #builder.hidden_field(attribute_name, input_html_options)
id = '' #what?
value = '' #what?
return "#{html}<input class='combobox-entry' data-id-input='#{id}' value='#{value}'".html_safe
end
end
I need to get the ID of the hidden field that simple_form is generating to place as an HTML attribute on the text entry to allow the JavaScript to "hook up" the two fields. I also need to get the value from the model to prepopulate the text input. How do I do this from within my custom input?
I'm looking for the id as well, but I did get the value:
def input
current_value = object.send("#{attribute_name}")
end
I just found a hokey id workaround:
html = #builder.hidden_field(attribute_name, input_html_options)
id = html.scan(/id="([^"]*)"/).first.first.to_s
I know it's a hack, but it does work. Since we don't have access directly to this type of resolution, it is likely to keep working even if the underlying id creation code changes.

visual relation Identifier in QTP

i am using visual relation Identifier in QTP for setting a value in webedit.Here is my code
Set rc = VisualRelations.Create
Set relation = rc.Add
relation.relatedobjectpath = "Browser(""ABC"").Page(""XYZ"").WebElement(""innertext:=E-Mail ID"")"
relation.relativeposition = micRelLeft
relation.setargument micrelinline, True
Set des=Description.Create
des.Add "micclass","WebEdit"
des.Add "visual relations",rc
Browser("ABC").Page("XYZ").WebEdit(des).set "qtpuser#abc.com"
Set relation = Nothing
Set rc = Nothing
The problem is when i use description programming for webElement in Line 3 the QTP showing an error message "Cannot find "webedit" objects parent". But, when i store webelement "E-Mail id" in OR, the code is working fine without any error.
Can u please tell me what can i do in this case to resolve the issue.
Thanks in Advance:)
There seems to be a limitation in QTP that the anchor test object in VRI must be in the object repository.
Thankfully there is a workaround, you can create a dummy anchor test object in the OR with a description of a blank innertext (by using the Define New Test Object button).
Then use SetTOProperty to get the dynamic behaviour you can achieve with descriptive programming.
Set rc = VisualRelations.Create
Set relation = rc.Add
Browser("ABC").Page("XYZ").WebElement("Anchor").SetTOProperty "innertext", "E-Mail ID"
relation.relatedobjectpath = "Browser(""ABC"").Page(""XYZ"").WebElement(""Anchor"")"
relation.relativeposition = micRelLeft
relation.setargument micrelinline, True
Set des=Description.Create
des.Add "micclass","WebEdit"
des.Add "visual relations",rc
Browser("ABC").Page("XYZ").WebEdit(des).set "qtpuser#abc.com"
Set relation = Nothing
Set rc = Nothing
When you store the WebElement "E-Mail id" in OR, its parent Page(""XYZ"") will also be stored into OR.
The problem is that OR way is used to identify Page, but the DP way is used to identify the WebElement. If you delete the WebElement "E-Mail id" but remain the Page("XYZ"), the script should work well.

Resources