Visual Studio Coded UI: recording AND adding assertions - visual-studio-2010

I'm very, very new to this tool and I'm just starting to experiment with it.
I want to test a simple web page. When I create a new Test, I'm asked to record it. I fire up IE, click the record button on the popup and type in an address (eg google.com). The problem is that the "Add Assertion" button is grayed out as soon as i press record.
So how can I record the act of browsing to www.google.com and asserting that, for example, there is a button with the label "Search"? Seems like I can either record or make assertions and this doesn't make sense to me, as I want to automate performing various actions and checking for specific results.

There isn't a way to record and do an assertion at the same time. With coded UI tests I have found it is best to keep my recorded actions relatively short and specific. Fill out a form and click to next page make assertions about the next page, record a new action for that page. Longer action recordings seem to break more often and are harder to update.

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.

parent & child browsers view got switched during automated execution by 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)

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.

How to inspect the flow of events with Firebug (or something like that)?

I'm facing an issue with inputs loosing focus. The issue is like this:
I send an AJAX request to load a form, when loaded I display it with in a modal.
Now if I click on any of the inputs it gains focus and blurs immediately, so I need to click it again (and this time it stays focused).
I need a tool that traces the event flow and dispatching in Firebug's console (or some similar tool), so that I can detect the culprit for this odd behavior and fix it.
I have tried Eventbug and FireQuery; but I haven't be able to find the code that causes this.
You may go to scripts panel of Firebug, then hover your mouse over the input, then click ALTCTRLB from the keyboard to activate "Break on next", then click the input, and it should hit a breakpoint in the onclick handler of the input, then you can go through the code to find potential calls that cause blur (provided that you don't do any aggressive polling via setInterval/setTimeout in your javascript for some reason, or the framework you use doesn't; then it'll likely pause in that code).
You may also want to execute some code at the very beginning of the page to override the addEventListener method so that you hijack it: log any calls to it, and forward execution to the original function; see slides 13-14 of my presentation (I do it in Greasemonkey, but it's not relevant here; just make sure this is executed at the very beginning of the page).

Explicit save vs. implicit save - what to prefer when?

I'm currently developing a wp7 app (don't want to tell too much ;), but I'm struggling a little with the user interaction.
The main question, I'm not sure about is: Should I offer an explicit save button in dialogs and use the phone back button as cancel, or should I save implicit the time the user taps the phone back button ...
The more I think about, the more I'm unsure about the best user experience.
I already read the user experience and interaction guide from Microsoft, but there isn't any advice in there about that issue ...
Thx alot for your suggestions.
On page 68 of the Windows Phone 7 UI Design and Interaction Guide it states:
Changes to Application Settings should be immediately implemented. This means that a "Done", "OK", or other confirming dialog is not neededd. In some cases, even though the change has happened immediately, the user may not have feedback that the change has occurred until an ongoing event is completed or a future event occurs. Examples would be joining a secure Wi-Fi network or changing the frequency of alarms.
Keeping Application Settings brief and clear should be a design goal. Complex, multi-page, multi-level Application Settings can frustrate or confuse users into thinking that they have entered another application entirely.
Although the same page also goes on to say:
Immediately implement user-selected Application Settings without a confirming dialog box and provide a feedback method to indicate that the change has occurred.
Avoid creating Application Settings that have more than 2 pages (screens). Settings that require more than a single screen should use overlying half screens to avoid losing context when
the SIP Keyboard is displayed.
If a task cannot be undone, always provide the user with an option to cancel. Text entry is an example. Actions that overwrite or delete data, or are irreversable must have a “Cancel” button.
When using additional screens with commit and cancel buttons, clicking those buttons should perform the associated action and return the user to the main settings screen.
To keep the heading of settings control panels consistent, the heading for the settings page should look as follows:
SETTINGS
<CPL Name/ Application Name>
Applications that fetch data over the network must have an option to disable data usage.
So, I think you only get in to questions over explicit vs. implicit if you have multiple pages for settings, and if you do it sounds like the explicit would be the way to go with sub-pages, but implicit for the initial page.
You should use explicit saving of settings.
However, for data entered it will depend on the application and the data being entered.
It's typcial to include a save button (or equivalent) otherwise there's (probably) no way for the user to cancel out of a partially entered form. This can also cause issues if there are validation issues which would prevent the saving of the partially entered data.
It depends on the app though. There is no universal rule for this.

Resources