parent & child browsers view got switched during automated execution by HP UFT - hp-uft

I am facing a strange issue with my test automation scripts when executed through HP UFT 12.01
Our AUT is a web based application developed in actimize. During my test flow, lets say at 5th step i need to invoke a popup browser (child) from my main page. The new popup browser will not have any menus or back/fwd buttons.
3 out of 10 executions, during 5th step my main browser gets refreshed to invoke the popup and when popup rendered fully, contents and views got switched now. i.e., main browser has the contents which are supposed to display in popup window (with menu bar and back/fwd buttons) and pop-up window has main page contents (without menu bar, back/fwd buttons) & state when i performed click operation.
This is strange and i could not really conclude if its browser issue or UFT issue. I have also checked with functional team and they never faced, so this is happening only through UFT execution and speculating it could be UFT issue.. any help pls?

This sounds like it could be either:
1) an actual bug in your UAT
2) a problem with QTP object identification.
If it's #2, here's some things to check. First, make sure that QTP can correctly and reliably identify the two different "browsers". (i.e. while both are on the screen, use the "Highlight in Application" button found the Object Repository window while each of the objects is selected. I would try this for both a normal run and immediately after the browsers get switched (use a break point if necessary)
If there is a problem with QTP identifying the windows incorrectly, then you might want to add additional Description properties to the test object in the OR so that it can lock onto the right one more reliably. I usually use GUISpy to spy on something on the page, then in Object hierarchy I click on the top object (the browser), then click "Copy identification properties to the Clipboard" button, then paste the results into a notepad. Find one of those properties that uniquely identifies the browser objects from anything else. Sometimes I have to use the URL property (with some REGEX magic to isolate the specific page without making it TOO specific)

Related

Selectors only work when webpage is opened in Internet Explorer

I created a login sequence and my selectors for the input email, password, click login and element exists are valid. But only when I have the Internet Explorer page open on the website I'm working with.
I did that sequence again, and I ran it, initially it worked but when I ran the hole project it broke again, I tried "repair" and "indicate", I tried to eliminate the title but nothing is working.
As far as I can see, you are using selector attribute:
"title=ACME System 1 - Dashboard"
Try using a wildcard: title='ACME System 1*', so it can work when you leave the dashboard.
This worked for me when I took those UiPath Academy courses.
In order to automate tasks within a browser with UiPath, the browser must be open. There is an activity called Open Browser that's included in the default activities for every project. You need to add this activity to the beginning of your sequence and pass in the appropriate parameters, (ie. URL, browser type) you can then pass the outputted browser variable to an attach browser sequence and execute your browser automation acivities within that.
Browser activity sceenshot
In addition, the selector that you have shared does not look like a stable selector. There may be other 'H1' elements on the screen that will cause your automation to fail. I would use the UI explorer to help you build a better, more stable selector.
Did you initially use IE to indicate screen elements and then changed the BrowserType property to use a different browser? Please share the sequence to suggest you a fix for your issue.
I would also suggest you to modify the selector to 'title='ACME System *'.
In order for selector to work the application needs to be open and the desired element needs to be available. So when you close the browser the selector disappears.
You may consider swithching to 'Modern Design Experience' and use 'Use Application/Browser' scope to make this more intuitive, and it will also automatically open the browser for you if it is closed.

Is it possible to disable "Display hidden-mode notification tooltip" programmatically on UFT?

I'm trying to run some automation tests in my application but the UFT Hidden-mode notification tooltip is coming in front of the objects in the screen, preventing my tests to run.
I know I can un-check the option "Display hidden-mode notification tooltip" in Remote Agent Settings to fix this issue and it works fine on my machine after I do this, but these tests are executed in other machines, by other users in my company, and it would be a real effort to tell each and everyone of them to change this setting on their machine.
Is it a way to disable this checkbox programmaticaly instead?
EDIT:
Here is a little more detail on where this is affecting me:
I'm testing a Web application and in some of my test cases I need to download a file from this application. I do that by clicking on "Save As" in the context menu which is displayed on a notification bar at the bottom of the browser.
Following is the portion of code to perform such operation:
Dim brwBottom
Set brwBottom = Browser("brw_Bottom_Save_As")
If brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Exist Then
brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Click
brwBottom.WinMenu("wm_Selector").Select "Save As"
End If
This works fine on my machine because UFT notification is not being displayed, but in other machines where the UFT Notification is displayed, it overlaps the menu and my script is unable to select the "Save As" option. So, in case it is not possible to programmatically close this notification at runtime, is there any alternative solution to click on the "Save As" button, even with this notification overlapping it?
I managed to identify the UFT Notification tooltip and close it. With this, there is no more objects in front of the button I need to click and my script can be executed successfully.
Following is the code used. I'm not marking this as the acceptable answer yet because I am still waiting for my team to accept the solution, but this works.
Dim brwBottom
Set brwBottom = Browser("brw_Bottom_Save_As")
' To close UFT Notification Tooltip, if exists
If Window("regexpwndtitle:=NotificationWindow").Exist(2) Then
If InStr(Window("regexpwndtitle:=NotificationWindow").GetROProperty("nativeclass"),"UFTRemoteAgent") > 0 Then
Window("regexpwndtitle:=NotificationWindow").Close
End If
End If
If brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Exist Then
brwBottom.WinObject("wo_Notification").WinButton("wb_Selector").Click
brwBottom.WinMenu("wm_Selector").Select "Save As"
End If
Create UFT GUI test and include these three lines:
extern.Declare micLong, "WritePrivateProfileString", "kernel32.dll", "WritePrivateProfileString", micString, micString, micString, micString
extern.WritePrivateProfileString "RemoteAgent", "ShowBallon", "0", Environment("ProductDir") + "\bin\mic.ini"
systemutil.CloseProcessByName "UFTRemoteAgent.exe"
From ALM, run it on all your UFT machines.
Notes:
This will switch the flag that controls such tooltip to be off, so next time Remote Agent launches will read it and won't display the tooltip anymore.
The third line will kill UFT's remote agent for GUI testing which is in charge of the communication between UFT and ALM Client and this will cause an error in ALM's Automatic Runner (The RPC server is unavailable)... just ignore it. We need to kill it so it is re-launched next time we try to run a test from ALM (as mentioned above, new value for tooltip will be read)
EDIT:
I just found something interesting: this flag is actually saved in two locations:
mic.ini
RemoteAgentGUISettings.xml
but the one that actually makes the change effective is RemoteAgentGUISettings.xml (it seems they're switching from .ini files to .xml... which makes sense). In this case, the code will change a little, but the idea is the same:
filePath = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%appdata%") + "\Hewlett-Packard\UFT\Persistence\Dialogs\RemoteAgentGUISettings.xml"
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.load filePath
Set nNode = xmlDoc.selectsinglenode ("//SettingsViewModel/IsShowBalloon")
nNode.text = "false"
strResult = xmldoc.save(filePath)
systemutil.CloseProcessByName "UFTRemoteAgent.exe"
This time I made sure it works ;)
I totally understand your pain because my projects also need to interact with IE download bar. Usually, I use SendKeys to handle download activity in different projects.
When download bar comes out, you can send ALT+N first to set focus on download bar, then send some tab keys to select on Save, and some Down Arrow key to select SaveAs.
In this way, you don't need to bother handle UFT notifications...
Sample SendKeys codes can be easily Googled.
Can you activate the desired browser with the following, and then try to do Save as
hwnd = Browser("title:=.*").GetROProperty("hwnd")
Window("hwnd:=" & hwnd).Activate

UFT - Object Identification not working on Run Time

I have written a code for Web page. The process requires me to click on a weblink which opens up a new window, then perform some operations on the browser window. Then I close the new browser. This is repeated multiple times in the code. All the elements on all the browser windows are normally identifiable using the object spy. However, intermittently during run time when a new browser window opens up the elements on the page are not getting recognized (hence it throws errors). When i go into the debug mode and try using the object spy the maximum identification i can capture is Browser(<>).Page(<>). Nothing in the page is getting recognized.
Now if i close this browser and reopen it and check again, the elements on the page are getting captured by the object spy and i can continue with my script execution. Sometimes I have to close and reopen multiple times for it to work.
Is there any way to handle this scenario. check for object identifications on the run time maybe. Dunno if it this is any relevant but i am not making use of the OR in my project.
Thanks in advance.
This sounds like a bug in UFT and you should contact HP's support.
A workaround if you know where the problem is probable to appear is to add Browser("<name>").RefreshWebSupport. This is an undocumented feature of UFT that sometimes helps in cases like this.

Firefox extension - Share common state between two or more windows

I am developing firefox extension.
Problem is that when i open second window (Ctrl + N) my extension has new state for new opened window.
If I reacts or changes on second window it never affect on first window or vice versa.
Ex
Installed extension on Firefox
first window opened. My extension proper functioning, change state, login, view data etc
then opened second. My extension goes new state I cant get previous states (first window states).
How can maintain same state between first and second or other firefox opened windows.?
Am I correct to assume you're developing a XUL overlay add-on, and not an SDK add-on?
One way to share state between windows is to use Javascript code modules. A code module will only be loaded once (unless explicitly unloaded) and therefore will expose the same data to multiple windows. Be sure to read the "Sharing objects using code modules"., However, please note that therefore when closing a window, any state associated with it and stored within the code module must be cleaned up, or would leak otherwise.
If you're using the SDK instead, your main.js module is already the equivalent of a code module. Content scripts may use message passing to store and retrieve state from your module.

Questions about tombstoning in Windows Phone 7

I have a weird probleme : I navigate to a view, I check one or more CheckBox and navigate back (I didn't override the navigateFrom method). Then I navigate to my view again, and the checkbox aren't checked.
Is this even normal behavior ? I this part of the tombstonning "feature" of Windows Phone 7 ? If yes, does that mean that whenever I navigate from a view, even if its within my app, I need to save state ? (I yes, that sucks...)
It sounds like what you're doing is:
Navigate to a page
Change something on the UI of that page(the checkbox)
Go back from that page
Return to that page again
If that's what you're doing, here's what's happening.
In point 3 the page is destroyed. If you didn't save something then the sytem won't have magically saved it for you.
In point 4 a brand new page is created. If you haven't written any code to set up the UI state then it will be the default.
Presumably the checked state of the checkbox is representative of something else in your app. You should therefore probably look at binding it's checked state to the underlying setting.
Because the system can't know what is a change you want persisting and what isn't, it leaves this up to you.
It's normally best to save data or setting changes as soon as they are made. Regardless of navigating within your application, your app could get tombstoned at any point and you'll probably want to preserve the app and it's data/state so that the user doesn't lose anything or get confused as a result of tombstoning.

Resources