Exist is always coming TRUE in UFT when using index to identify Browser - ui-automation

I've to get the number of opened browsers having some title. The approach that I used was using the index. But the problem is, whatever index I pass, Exist function is always returning true.
Browser("openurl:=.*something.*", "index:=0").Exist => True
when i change the index to 10 or some other number, it still returns me True even if there is only one browser window. My problem statement is to find any new browser window opened after a click of a button, this window can be a pdf or csv file. After identifying the window (by using index in my case) I've to get the visible text of the window.
PS: I'm new to UFT, have worked on automation using selenium tool.

The index (or any ordinal identifier like CreationTime) are used only if the description matches multiple Browsers, if the description you supply only matches one object it will be ignored.
I tried with two open tabs and got the following results:
Print Browser("opentitle:=.*", "index:=10").Exist ' => False
Print Browser("opentitle:=.*Example*", "index:=10").Exist ' => True
If you're seeing different results I would suggest try using the undocumented function Highlight to see which Browser UFT thinks matches your description.

Related

Trouble with VB6 form location (top,left) and value type (i.e., integer)

VB6 will REPORT a LEFT location greater than max integer when the form is in an auxiliary screen. However, I cannot assign that value as a LEFT specification.
I manually drag frmSecondary to the secondary monitor (located to the right of my primary monitor).
I click a button within frmSecondary in order to write the value of frmSeconday.Left to a file. It writes 49950.
I close the program, then re-open.
I read the value from the file (and the value IS 49950).
I try to programmatically assign that value to frmSecondary.Left
Failure (works OK if the value is less than "largest integer").
Expected result: I should be able to assign the value that was written to file. Better yet, any ideas of how to programmatically place frmSecondary at it's "proper" location on the secondary monitor?
I simply read the value from file:
Input #fnum, frmSecondary.left
I've tried, without success:
Dim lft as variant
Input #fnum, lft
frmSecondary.left = lft
I have confirmed that the value being read from file is, in fact, 49950. I do this confirmation two ways...one is by looking at the file; the second is by putting a "stop" in the program and showing the value of lft.
TOTAL NONSENSE
Ignore this entire post. I just discovered my error -- it's so embarrassing, I don't even want to describe it. Nothing quite like spending an entire afternoon (to say nothing of YOUR time) chasing garbage.

** No sls-discount record is available. (91)

/*
sls-discount i sthe database name
*/Good day. I have another problem in regards again to value change of a specific browse.
my code for Add Button:
FIND CURRENT {&FIRST-TABLE-IN-QUERY-DIALOG-FRAME} NO-LOCK NO-ERROR.
IF AVAIL {&FIRST-TABLE-IN-QUERY-DIALOG-FRAME} THEN DO:
ASSIGN mode = 3.
ASSIGN BROWSE BROWSE-13:READ-ONLY = NO
sls-discount.dsc-amount:READ-ONLY IN BROWSE BROWSE-13 = NO
sls-discount.dsc-discount:READ-ONLY IN BROWSE BROWSE-13 = NO
sls-discount.log:READ-ONLY IN BROWSE BROWSE-13 = NO.
{&OPEN-QUERY-BROWSE-13}
IF BROWSE-13:num-iterations ne 0 then
BROWSE BROWSE-13:SELECT-FOCUSED-ROW().
BROWSE BROWSE-13:INSERT-ROW("BEFORE"). /*will cause value-change in browse*/
APPLY 'entry' TO sls-discount.dsc-discount IN BROWSE BROWSE-13.
RUN disp-enable.
END.
my code for browse-13:
ASSIGN xpromo-no = {&FIRST-TABLE-IN-QUERY-BROWSE-13}.promo-no
mdlrid = {&FIRST-TABLE-IN-QUERY-BROWSE-13}.record-id.
MESSAGE xpromo-no mdlrid VIEW-AS ALERT-BOX INFO.
OPEN QUERY BROWSE-16 FOR EACH sls.sls-disccount-model WHERE sls.sls-disccount-model.promo-no = xpromo-no
AND sls.sls-disccount-model.record-id = mdlrid NO-LOCK,
EACH sls.sls-model WHERE sls.sls-model.car-model = sls.sls-disccount-model.car-model NO-LOCK.
if I uncomment the entire value-change in a browse, it will display the message "** No DBName record is available. (91)" when clicking the add button. but if commented/removed, it will not display the message.
hope you can help me again .. Thanks
You've doubtless run into the infamous "partial field auto-completion" feature / bug. What that means is - if you cite a variable with no local definition for it, the Progress compiler will search all the available tables for a field that starts with the same sequence of letters and use that instead.
What the error is telling you is that the compiler associated a field with something in the "DBName" table, and when the code tries to access that variable, the DBName buffer isn't in scope - which is understandable since accessing it wasn't your intention.
My guess is that you've mis-specified a BROWSE construct. Looking at your first set of constructs, you've got two different forms:
BROWSE BROWSE-13:READ-ONLY = NO
sls-discount.dsc-amount:READ-ONLY IN BROWSE BROWSE-13 = NO
I'll bet one of these is wrong, and the compiler is associating the illegal "browse" citation with a field in DBName that starts with "Browse".
If you compile the code to an XREF file, it'll tell you which variable it's trying to associate with the DBName table. Correct that, and you'll be good to go.
I figure out what the problem on the code.. on click of Add button, the row inside browse-13 was arrange because of the {&OPEN-QUERY-BROWSE-13}. after that, because of BROWSE BROWSE-13:SELECT-FOCUSED-ROW(), it focused on the TOP date on browse and last, BROWSE BROWSE-13:INSERT-ROW("BEFORE"), created a blank data row at the very top. thus triggering value-changed of browse-13. on my value-changed on browse-13, the beginning of the code was to get current browse-13. since it was focused on the blank row, it resulted in an error with no query being found. sorry if i did not include the syntax get current in my first example.

Requesting member of node_element results in "undefined"

I'm using Opa for a school project in which there has to be some synchronization of a textfield between several users. The easy way to solve this, is to transmit the complete field whenever there is a change performed by one of the users. The better way is of course to only transmit the changes.
My idea was to use the caret position in the textfield. As a user types, one can get the last typed character based on the caret position (simply the character before the caret). A DOM element has an easy-to-use field for this called selectionStart. I have this small Javascript for this:
document.getElementById('content').selectionStart
which correctly returns 5 if the caret stands at the fifth character in the field. In Opa, I cannot use selectionStart on either a DOM or a dom_element so I thought I'd write a small plugin. The result is this:
##extern-type dom_element
##register jsGetCaretPosition: dom_element -> int
##args(node)
{
return node.selectionStart;
}
This compiles with the opp-builder without any problem and when I put this small line of code in my Opa script:
#pos = %%caret.jsGetCaretPosition%%(Dom.of_selection(Dom.select_id("content")));
that also compiles without problems. However, when I run the script, it always returns "undefined" and I have no idea what I'm doing wrong. I've looked in the API and Dom.of_selection(Dom.select_id("content")) looked like the correct way to get the corresponding dom_element typed data to give to the plugin. The fact that the plugin returns "undefined" seems to suggest that the selected element does not know the member "selectionStart" eventhough my testcode in Javascript suggest otherwise. Anyone can help?
In Opa dom_element are the results of jQuery selection (i.e. an array of dom nodes). So if I well understood your program you should write something like node[0].selectionStart instead of node.selectionStart.
Moreover you should take care of empty selection and selection which doesn't contains textarea node (without selectionStart property). Perhaps the right code is tmp == undefined ? -1 : tmp = node[0].selectionStart == undefined ? -1 : tmp

MS Access implenting hyperlink like behavior for records to switch between forms

I'm currently working on a Database which requires the following functionality:
For example given a specific project, I have a series of structures which belong to that project, which are displayed in a datasheet view on the project form. I am attempting to allow the user to on double click to navigate to that specific structure which is displayed on another form. Currently I am using filters to implement this behavior, however, this results in the filter being left on, and when I manually turn off the filter, the form I switch to returns back to the first entry.
I am using the current code on the datasheet:
Private Sub struct_name_DblClick(Cancel As Integer)
LookupValue = Me.struct_ID
Form_frm_control.pg_structure.SetFocus
Form_frm_control.subform_structure.Form.Filter = "struct_ID = " & LookupValue
Form_frm_control.subform_structure.Form.FilterOn = True
End Sub
Any help would be greatly appreciated. Thanks in advance.
It all depends on what you need to do.
If you want to display all records and navigate to the selected record, then you can use bookmark navigation:
With Forms!MyOtherForm
.RecordsetClone.FindFirst "struct_ID = " & Me!struct_ID
If Not .RecordsetClone.NoMatch Then
If .Dirty Then
.Dirty = False
End If
.Bookmark = .RecordsetClone.Bookmark
End If
End With
This assumes that the other form is open with all the records loaded.
Another approach to this problem, which I find more useful for popup situations like this, is to just open the other form as a dialog and require it be closed before returning to the calling context. In that case, you'd do this:
DoCmd.OpenForm "MyOtherForm", , , "struct_ID = " & Me!struct_ID, , acDialog
You'd then have to close the other form to get back to the original context.
You might think that with large numbers of records this would be inefficient, but it's actually very fast, as this operation is highly optimized within Access (moreso than filtering an already open form, in fact).

JQuery UI Autocomplete returning all values

I have the following code:
$("#auto").autocomplete({
source: "js/search.php",
minLength: "3" });
This code is assign to an input text box where i type a name and after 3 letters it should return the ones that have similar letters. For my case it is returning all values, even those not related to the 3 letters already typed. My question is:
How to send my search.php file the value inside the input so it should know what to search for. For the moment it searches for everything. I checked the value that was going to php and it was empty. Since the query to mysql uses LIKE '%VARIABLE%' and the variable is empty it searches for '%%' which is all cases.
How can i send the correct informacion from JS to PHP with the simplest form.
Here is the explanation :
http://www.simonbattersby.com/blog/jquery-ui-autocomplete-with-a-remote-database-and-php/
Regards